views:

740

answers:

2

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.

A: 

Try:

dirt -u username -n 

dsconfigad -show

Further reference:

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

+1  A: 

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.

Ken