查找在OS X登录钩子的Active Directory用户主文件夹 [英] Find Active Directory users home folder from login hook script in OS X

查看:216
本文介绍了查找在OS X登录钩子的Active Directory用户主文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要写一个OS X登录钩子脚本,知道用户的当前主文件夹中。由于用户是Active Directory用户,他们的主文件夹不存储在/用户,所以我不能简单地硬code的完整路径。

I need to write a OS X login hook script that is aware of the users current home folder. Since the users are Active Directory users, their home folders are not stored in /Users so I can't simply hard code the full path.

由于登录连接是由后台程序以root身份运行,我不能用$ HOME,〜等无论是。

Since the login hook is run by a daemon as root, I can not use $HOME, ~, etc either.

唯一的一块信息我是被传入作为参数传递给该脚本的用户名。

The only piece of info I have is the users name which is passed in as an argument to the script.

有没有什么办法可以解决考虑到所有这些限制了用户的主文件夹?该脚本并不需要是一个登录钩必然,但它确实需要运行该登录到本机的所有AD用户。

Is there any way to resolve the users home folder given all these restraints? The script does not need to be a login hook necessarily, but it does need to run for all AD users that log into the machine.

推荐答案

事实证明,这个命令的伟大工程:

It turns out this command works great:

finger $USER_NAME | grep Directory | expand | cut -d ' ' -f 2

是必要的,因为如果扩展的文件夹路径很长,手指会用一个选项卡分离的空间领域,而不是。

The expand is needed because if the folder path is long, finger will use a tab to separate the fields instead of a space.

这篇关于查找在OS X登录钩子的Active Directory用户主文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆