Apple OS X Server User Manual


 
Listing 3-3 Setting the name of a record
void main ( )
{
long dirStatus = eDSNoErr;
tDirNodeReference nodeRef = NULL;
dirStatus = dsOpenDirService( &gDirRef );
if ( dirStatus == eDSNoErr )
{
dirStatus = MyOpenDirNode( &nodeRef );
if ( dirStatus == eDSNoErr )
{
SetRecordName( nodeRef );
dsCloseDirNode( nodeRef );
}
}
if ( gDirRef != NULL )
{
dirStatus = dsCloseDirService( gDirRef );
}
}
void SetRecordName ( const tDirNodeReference nodeRef )
{
long dirStatus = eDSNoErr;
tRecordReference recRef = NULL;
tDataNodePtr recName = NULL;
tDataNodePtr newRecName = NULL;
tDataNodePtr recType = NULL;
recName = dsDataNodeAllocateString( gDirRef, "testuser" );
if ( recName != NULL )
{
recType = dsDataNodeAllocateString( gDirRef, kDSStdRecordTypeUsers );
if ( recType != NULL )
{
dirStatus = dsOpenRecord( nodeRef, recType, recName, &recRef );
if ( dirStatus == eDSNoErr )
{
newRecName = dsDataNodeAllocateString(gDirRef, "newtestname"
);
if ( newRecName != NULL )
{
dirStatus = dsSetRecordName( recRef, newRecName );
dsDataNodeDeAllocate( gDirRef, newRecName );
newRecName = NULL;
}
dirStatus = dsCloseRecord( recRef );
recRef = NULL;
}
dsDataNodeDeAllocate( gDirRef, recType );
recType = NULL;
}
dsDataNodeDeAllocate( gDirRef, recName );
recName = NULL;
}
} // SetRecordName
38
Setting the Name of a Record
2007-01-08 | © 2007 Apple Inc. All Rights Reserved.
CHAPTER 3
Working with Records