Home > Active Directory, AppleScript, Mac administration > Looking up AD home directory locations from an AD-bound Mac

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

PDF with proper formatting available here.

  1. rob
    August 17, 2012 at 2:56 pm

    I cant download the PDF I think my formatting is wrong

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 161 other followers

%d bloggers like this: