Apple OS X manual Listing Records

Page 34

C H A P T E R 3

Working with Records

When the GetRecordList routine returns, the sample code in Listing 3-1 calls dsCloseDirNode to close the node that it opened in order to get the record list.

Listing 3-1Listing records in a node

void main ( )

{

long dirStatus = eDSNoErr; tDirNodeReference nodeRef = NULL; dirStatus = dsOpenDirService( &gDirRef ); if ( dirStatus == eDSNoErr )

{

dirStatus = MyOpenDirNode( &nodeRef ); if ( dirStatus == eDSNoErr )

{

GetRecordList(nodeRef); dsCloseDirNode( nodeRef );

}

}

if ( gDirRef != NULL )

{

dirStatus = dsCloseDirService( gDirRef );

}

}

long GetRecordList ( const tDirNodeReference nodeRef )

{

unsigned long i = 0; unsigned long j = 0; unsigned long k = 0; long dirStatus = eDSNoErr;

unsigned long recCount = 0; // Get all records. tDataBufferPtr dataBuffer = NULL; tContextData context = NULL; tAttributeListRef attrListRef = NULL; tAttributeValueListRef valueRef = NULL; tRecordEntry *pRecEntry = NULL; tAttributeEntry *pAttrEntry = NULL; tAttributeValueEntry *pValueEntry = NULL; tDataList recNames;

tDataList recTypes; tDataList attrTypes;

dataBuffer = dsDataBufferAllocate( gDirRef, 2 * 1024 ); // allocate a 2k buffer

if ( dataBuffer != NULL )

{

//For readability, the sample code does not check dirStatus after

//each call, but

//your code should.

dirStatus = dsBuildListFromStringsAlloc ( gDirRef, &recNames, kDSRecordsAll, NULL );

dirStatus = dsBuildListFromStringsAlloc ( gDirRef, &recTypes, kDSStdRecordTypeUsers, NULL );

dirStatus = dsBuildListFromStringsAlloc ( gDirRef, &attrTypes, kDSAttributesAll, NULL );

do

{

34Listing Records

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

Image 34
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 Organization of This Document See AlsoIntroduction See Also Concepts Open Directory OverviewNodes 1Flow of an Open Directory request2An Open Directory request over a network Search Policies and Search Nodes Record TypesConstant Description Standard Attribute Types Standard attribute for storing a unique ID commonly foundAuthentication Native Attribute TypesBasic Authentication Open Directory Overview Local Windows Hash Authentication Local Cached User Authentication Disabled User Authentication Directory Native Authentication Directory ProxyOpen Directory, lookupd, and NetInfo 3lookupd and NetInfo interaction when using SSH Directory Service Command Line Utility DebuggingWorking with Nodes Listing Registered NodesWorking with Nodes Finding a Node Opening and Closing a Node Authenticating a User to a Node Directory Native Authentication Authenticating using directory native authenticationWorking with Nodes Working with Nodes Authenticating a User to a Node Working with Records Listing RecordsListing Records Getting Information About a Record’s Attribute Working with RecordsGetting 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