Looking up AD home directory locations from an AD-bound Mac
One of the occasional issues I’ve run into at work is that we don’t have one central location that stores all of our AD home directories. As a result, telling someone where it is can take some digging and delay. To help speed up the process, I worked with Peter Bukowinski to build an easy-to-use AppleScript that looks this information up. It should be pretty generic, but the only location I’ve tested it at is here at my workplace. Your milage may vary.
Assumptions: In order to work correctly, the script needs for the Mac to be bound to an AD domain. The AD-bound Mac also needs to be connected to the AD domain via a domain-reachable network connection or via VPN.
Using the script:
Launch the script and provide the username in the blank provided, then click OK.
The home folder will then be displayed in a dialog box. You’ll also be prompted to copy the home folder information to the Mac’s clipboard for pasting (if needed.) Click OK to dismiss the dialog without copying the information. Clicking either button will quit the script.
Update: Peter added some more functionality to the script by making the copying of the information to the clipboard optional and adding error checking for when an AD account was set up without having a home directory set in the account profile. Downloads and source code have been updated to reflect the changes.
Click here to download the script. Source code is beneath the jump.
sset result to text returned of (display dialog "Enter the Username whose home folder you want to look up:" default answer "")
if result is not false then
set userName to result
try
set the_output to (do shell script "/usr/bin/dscl localhost -read /Active\\ Directory/All\\ Domains/Users/" & userName & " SMBHome | awk '{gsub(/\\\\/,\"/\"); print $2}'")
if the_output is "" then
set the_output to "Home not configured in " & userName & "'s AD profile.
Ask a domain admin to fix it."
display dialog the_output buttons "OK"
else
set theDialog to display dialog the_output buttons {"OK", "Copy home folder data to clipboard"} default button "Copy home folder data to clipboard"
if button returned of theDialog is "Copy home folder data to clipboard" then
set the clipboard to the_output as string
end if
end if
on error errorText
display dialog "Cannot display home folder for " & userName & ":" & return & return & errorText with icon stop buttons {"OK"} default button "OK"
end try
end if
I cant download the PDF I think my formatting is wrong
Ah, it looks like the PDF was a victim of MobileMe going down. I have an updated PDF available at the following post:
https://derflounder.wordpress.com/2011/11/15/active-directory-home-directory-lookup-applescript-now-updated-for-10-7-x/
I have a shell-script version available on my GitHub repo as well. It’s available here:
https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Interactive_AD_Home_Folder_Lookup