Skip to content

Instantly share code, notes, and snippets.

@russm
Created April 7, 2010 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russm/358599 to your computer and use it in GitHub Desktop.
Save russm/358599 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/macruby
framework 'OpenDirectory'
# returns false, this means it's already been loaded when OpenDirectory.framework was loaded?
framework 'OpenDirectory.framework/Frameworks/CFOpenDirectory'
session = ODSession.defaultSession
# returns ["/BSD/local", "/Local/Default"] - looks like a good session
session.nodeNamesAndReturnError nil
node = ODNode.nodeWithSession session, name:"/Local/Default", error:nil
# throws "NameError: uninitialized constant KODRecordTypeUsers"
query = ODQuery.queryWithNode node, forRecordTypes:KODRecordTypeUsers, attribute:KODAttributeTypeRecordName, matchType:KODMatchContains, queryValues:"rus", returnAttributes:KODAttributeTypeStandardOnly, maximumResults:0, error:nil
# throws "NameError: undefined local variable or method `kODRecordTypeUsers' for main:TopLevel"
query = ODQuery.queryWithNode node, forRecordTypes:kODRecordTypeUsers, attribute:kODAttributeTypeRecordName, matchType:kODMatchContains, queryValues:"rus", returnAttributes:kODAttributeTypeStandardOnly, maximumResults:0, error:nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment