Apple OS X manual Working with Records, Listing Records

Page 33

C H A P T E R 3

Working with Records

Using records is an essential part of using Open Directory. This chapter covers basic examples of how to interact with records.

Listing Records

The sample code in Listing 3-1(page 34) demonstrates how to list all records in a node. The sample code opens an Open Directory session and gets an Open Directory reference. Then it calls its MyOpenDirNode routine and passes to it the address of the node reference (nodeRef) that it has allocated. The MyOpenDirNode routine is described in the section “Opening and Closing a Node” (page 28).

The sample code then calls its ListRecord routine and passes to it the node reference (nodeRef) obtained by calling its MyOpenDirNode routine.

The GetRecordList routine calls dsDataBufferAllocate to allocate a buffer for storing the results of calling dsGetRecordList. It also builds three data lists for determining which records to include in the list: one for record names (recNames), one for record types (recTypes), and one for attribute types (attrTypes). It sets recName to kDSRecordsAll (to include all record of any name in the list), recTypes to kDSStdRecordTypeUsers to include standard user type records in the list, and sets attrTypes to kDSAttributesAll to include all attributes of the records in the list.

Then the GetRecordList routine calls dsGetRecordList to fill the data buffer with matching records and their attributes. By specifying eDSExact as the fourth parameter (inPatternMatchType), dsGetRecordList gets records that exactly match the requirements specified by the recNames parameter. By specifying false as the seventh parameter (inAttributeInfoOnly), dsGetRecordList gets attribute values as well as attribute information.

The dsGetRecordList function returns in its recCount parameter the count of the number of records returned in its dataBuffer parameter. Using recCount as a limit, the GetRecordList routine walks through the data buffer calling dsGetRecordEntry to get the record entry information for each record.

The record entry information contains an attribute count that GetRecordList uses as a limit to walk through the record’s attributes, calling dsGetAttributeEntry for each attribute. For each attribute entry, GetRecordList calls dsGetAttributeValue and prints the attribute’s value and its attribute ID.

The GetRecordList routine continues printing attribute values and attribute IDs until dsGetRecordList returns a context parameter that is NULL. It cleans up by calling dsDeallocAttributeEntry and dsDeallocAttributeValueEntry to reclaim the memory associated with the attribute entry and attribute value entry that were created by calling dsGetAttributeEntry and dsGetAttributeValueEntry. It also calls dsDeallocRecordEntry to reclaim the memory associated with the record entry. Before it returns, GetRecordList should call dsDataListDeallocate to reclaim the memory associated with the recNames, recTypes, and attrTypes data lists. It should also call dsDataBufferDeAllocate to deallocate the data buffer.

Listing Records

33

2007-01-08 © 2007 Apple Inc. All Rights Reserved.

Image 33
Contents Open Directory Programming Guide Apple Inc Contents N T E N T S Figures, Tables, and Listings G U R E S , T a B L E S , a N D L I S T I N G S See Also Organization of This DocumentIntroduction See Also Open Directory Overview Concepts1Flow of an Open Directory request Nodes2An Open Directory request over a network Record Types Search Policies and Search NodesConstant Description Standard attribute for storing a unique ID commonly found Standard Attribute TypesNative Attribute Types AuthenticationBasic Authentication Open Directory Overview Local Windows Hash Authentication Local Cached User Authentication Disabled User Authentication Directory Proxy Directory Native AuthenticationOpen Directory, lookupd, and NetInfo 3lookupd and NetInfo interaction when using SSH Debugging Directory Service Command Line UtilityListing Registered Nodes Working with NodesWorking with Nodes Finding a Node Opening and Closing a Node Authenticating a User to a Node Authenticating using directory native authentication Directory Native AuthenticationWorking with Nodes Working with Nodes Authenticating a User to a Node Listing Records Working with RecordsListing Records Working with Records Getting Information About a Record’s AttributeGetting Information About a Record’s Attribute Setting the Name of a Record Working with Records Listing 3-3Setting the name of a record Creating a Record and Adding an Attribute Void CreateRecord const tDirNodeReference inDirNodeRef Deleting a Record Working with Records Document Revision History Document Revision History
Related manuals
Manual 32 pages 7.58 Kb