Find Active Directory users home folder from login hook script in OS X

别等时光非礼了梦想. 提交于 2019-12-24 20:01:44

问题


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.

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.

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.


回答1:


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.




回答2:


Try:

dirt -u username -n 

dsconfigad -show 

Further reference:

http://www.mactech.com/articles/mactech/Vol.20/20.11/ActiveDirectory/index.html



来源:https://stackoverflow.com/questions/1139499/find-active-directory-users-home-folder-from-login-hook-script-in-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!