}
}
void CreateRecord ( const tDirNodeReference inDirNodeRef )
{
long dirStatus = eDSNoErr;
tDataNodePtr recName = NULL;
tDataNodePtr recType = NULL;
tDataNodePtr attrName = NULL;
tDataNodePtr attrValue = NULL;
tRecordReference recRef = NULL;
recName = dsDataNodeAllocateString( gDirRef, "NewUserRecordName" );
if ( recName != NULL )
{
recType = dsDataNodeAllocateString( gDirRef, kDSStdRecordTypeUsers );
if ( recType != NULL )
{
dirStatus = dsCreateRecordAndOpen( inDirNodeRef, recType, recName,
&recRef );
if ( dirStatus == eDSNoErr )
{
attrName = dsDataNodeAllocateString(gDirRef,
kDS1AttrDistinguishedName );
if ( attrName != NULL )
{
attrValue = dsDataNodeAllocateString( gDirRef, "User Record's
Display Name");
if ( attrValue != NULL )
{
dirStatus = dsAddAttribute(recRef, attrName, NULL,
attrValue );
dirStatus = dsDataNodeDeAllocate( gDirRef, attrValue
);
attrValue = NULL;
}
dirStatus = dsDataNodeDeAllocate( gDirRef, attrName );
attrName = NULL;
}
dirStatus = dsCloseRecord( recRef );
recRef = NULL;
}
dirStatus = dsDataNodeDeAllocate( gDirRef, recType );
recType = NULL;
}
dirStatus = dsDataNodeDeAllocate( gDirRef, recName );
recName = NULL;
}
} // CreateRecord
Note that for this example to work, it would have to be run by a root process on the local NetInfo domain,
or by a user process that has called dsDoDirNodeAuth with the inDirNodeAuthOnlyFlag parameter set
to FALSE to get permission to make this change.
40
Creating a Record and Adding an Attribute
2007-01-08 | © 2007 Apple Inc. All Rights Reserved.
CHAPTER 3
Working with Records