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.