Extension Attribute help with Active Directory Query

shakim
New Contributor III

Seeking assistance with creating an extension attribute that will collect the following info:
For OS X 10.8
sudo defaults read /Library/Preferences/OpenDirectory/DynamicData/Active Directory/mydomain.plist | grep host

This command returns the "last used servers" for the Global Catalog server and domain server.

Can someone guide me with the best way to achieve this with an extension attribute? Also, how can I achieve the same for OS X lion?

1 REPLY 1

justinrummel
Contributor III

If your "defaults read" is correct:

#!/bin/bash

lastGC=`sudo defaults read /Library/Preferences/OpenDirectory/DynamicData/Active Directory/mydomain.plist | grep host`
[ "${lastGC}" != "" ] && { echo "<result>${lastGC}</result>"; } || { echo "<result>None</result>"; }