View Open Directory ComputerGroup Membership with Applescript

by on November 27, 2010 » Add more comments.

The following Applescript will show a selectable, scrollable list of machine accounts in OD, then show which ComputerGroup(s) that computer belongs to. This is a quick way to confirm membership without having to open WorkGroup Manager, and especially handy to allow your techs to verify without being a directory admin in OD.

You can download the script here, or copy/paste the code below into AppleScript Editor. You only need to specify your OD server address.

-- Set the domain to your OD domain
set domain to "od.school.edu"
set computerList to paragraphs of (do shell script "dscl /LDAPv3/" & domain & space & "-list /Computers")
set computerName to choose from list computerList
set memberList to (do shell script "dscl /LDAPv3/ecod.as.emory.edu search /ComputerGroups Member" & space & computerName & space & "| grep Member | cut -f1-1")
 
display dialog memberList

The reason I show a list of computers, instead of asking for one to be typed is because it is case sensitive. So it’s more consistent to select from a list.

Find more like this: Directory Services, Mac, Open Directory, Scripting , , , , , , ,


3 Responses to View Open Directory ComputerGroup Membership with Applescript

  • carlo says:

    Hello, first of all, many thanks for the info you’re sharing here!
    I have tried testing the ComputerGroup Membership Applescript but as soon as I compile it, it give an error each “&” divider.
    I know very litlle of Applescript but perhaps it’s just a minor typo, copy/paste and the like…
    Many thanks again!
    Ciao
    Carlo (from Italy)

  • Patrick says:

    @carlo

    Yea, it’s a copy/paste problem. It’s copying extra garbage. Use the download link above to grab the zip file with the script.

  • Andrei says:

    Wow, would love this to work. I can choose the computer-entry from the list, but it returns jut an empty window with OK and Cancel-Buttons.

Leave a Reply

Your email address will not be published. Required fields are marked *