Home > Active Directory, AppleScript, Mac administration, Mac OS X > Active Directory home directory lookup AppleScript now updated for 10.7.x

Active Directory home directory lookup AppleScript now updated for 10.7.x

A while back, I had posted an AppleScript that Peter Bukowinski and I had built to provide an easy-to-use way to look up the location of an Active Directory home folder. With the changes to the Active Directory plug-in on Mac OS X 10.7.x, the script also needed to be updated so I’m posting the updated script and code. The script should be usable on AD-bound 10.6.x and 10.7.x Macs, and Peter has added some new functionality to display the correct fileshare connection information for both Macs and Windows boxes.

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’s address will then be displayed in a dialog box, with the correct fileshare information for both Windows and Mac. 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 any of the buttons will quit the script.

As before, it should be pretty generic but the only location I’ve tested it at is here at my workplace. If you’re planning to use it on 10.7.x AD-bound Macs, check the code as you will need to make some edits.

Click here to download the script

Click here to download the source as a PDF document

  1. Paul
    May 16, 2013 at 7:44 am

    Hi,
    neither of your download links/attachments are valid anymore. Could you please update them?
    Thanks
    Paul

    • May 16, 2013 at 2:57 pm

      Paul,

      Both were on MobileMe and went away when it did. I’ve posted the source code here:


      Look up AD home directory script
      Peter Bukowinski
      Rich Trouton
      this repeat loop prevents empty strings from being submitted
      set q to 0
      repeat while q is 0
      set result to text returned of (display dialog "Enter the Username whose home folder you want to look up:" default answer "")
      if result is not "" then
      set userName to result
      set q to 1
      end if
      end repeat
      talk to AD, convert results to both Mac and Win paths; catch any errors and display in an error dialog
      try
      if (system version of (system info)) < "10.7" then
      set win_path to (do shell script "/usr/bin/dscl localhost -read /Active\\ Directory/All\\ Domains/Users/" & userName & " SMBHome | awk '{print $2}'")
      set mac_path to (do shell script "/usr/bin/dscl localhost -read /Active\\ Directory/All\\ Domains/Users/" & userName & " SMBHome | awk '{gsub(/\\\\/,\"/\"); print \"smb:\"$2}'")
      else
      set win_path to (do shell script "/usr/bin/dscl localhost -read /Active\\ Directory/DOMAIN/All\\ Domains/Users/" & userName & " SMBHome | awk '{print $2}'")
      set mac_path to (do shell script "/usr/bin/dscl localhost -read /Active\\ Directory/DOMAIN/All\\ Domains/Users/" & userName & " SMBHome | awk '{gsub(/\\\\/,\"/\"); print \"smb:\"$2}'")
      end if
      on error errorText
      display dialog "Your Mac is having trouble communicating with the Janelia Active Directory system. Please contact the help desk at 4030.
      Error: " & errorText with icon stop buttons {"OK"} default button "OK"
      end try
      notify if no home is configured for the user
      if win_path is "" then
      set not_configured to "Home not configured in " & userName & "'s AD profile.
      Ask a domain admin to fix it."
      display dialog not_configured buttons "OK"
      else
      show dialog with both paths and option to copy either to clipboard
      set theDialog to display dialog "Windows location: " & win_path & "
      Mac location: " & mac_path buttons {"OK", "Copy Windows location", "Copy Mac location"} default button "Copy Mac location"
      if button returned of theDialog is "Copy Windows location" then
      set the clipboard to win_path as string
      else if button returned of theDialog is "Copy Mac location" then
      set the clipboard to mac_path as string
      end if
      end if

  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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: