Tool: Get the path to an Active Directory user home

automator_iconWhen you need to look up the path to an Active Directory user’s home directory, there are a few ways to get the information:

That last bullet point is the most convenient way, particularly because I’m about to tell you how to do it. We’ll use Automator to create a Service that uses AppleScript to get the home directory location of a username via a dscl query, and show the path in a dialog box in both Mac and Windows-friendly formats. As a bonus, we’ll let either of the paths be copied to the clipboard for easy pasting.

Before you start, I should note that this will only work on Macs that meet the following requirements:

  • running Mac OS 10.6 or later
  • bound to Active Directory

Sound good? Let’s begin.

Note: If you want to skip the tutorial, you can download the completed Automator service here, unzip it, and drop it into your ~/Library/Services folder. To use it, right-click on a username – it has to be showing in a Mac app somewhere as selectable text – then select Get AD Home from the pop-up menu or its Services submenu.

Build the Automator Service

Open (found in /Applications) and choose Service from the new document types list.

make a new Service

The default service input settings shown at the top-right – “Service receives selected text in any application” – will work perfectly for our service. Now we need to add an action to act on our input. Type applescript into the search field as shown below and then drag the Run AppleScript item to the right.

add "run applscript"

Now replace the entire contents of the AppleScript area with the following code.

This is where all the automation happens. Note that on the “set PROTOCOL” line you can use either smb or afp. Use the one that matches how you mount homes in your environment. The rest should not need to be changed. (If you have any questions about the AppleScript code, ask me in a comment.) Now click the hammer icon to verify and compile the code. If everything checks out, you should see the code acquire syntax highlighting like this:

finished service

Save the Service as Get AD Home (or the name of your choice). Automator will save it into ~/Library/Services where it belongs.

How to Use the Service

To use your new service, simply right-click on a username – it could be in an email, on a webpage, or in a text document – and select Get AD Home from bottom section of the menu.


Your menu will look different depending on which program is displaying the username. If you see a Services item listed, you’ll need to select that first before you will see Get AD Home. Finally, if the username you selected matches a username in Active Directory, you’ll see a dialog box like this:


Clicking any button will dismiss the window, but you can copy whichever path you need by selecting the corresponding button.