C H A P T E R 2

Working with Nodes

::memcpy(&(anAuthDataBuf->fBufferData[aCurLength]), &aTempLength, sizeof(long));

aCurLength += sizeof(long); ::memcpy(&(anAuthDataBuf->fBufferData[aCurLength]), inUserPassword,

aTempLength);

aCurLength += aTempLength;

anAuthBuff->fBufferLength = aDataBufSize;

aDirErr = dsDoDirNodeAuth(inDirNodeRef, anAuthType2Use, true, anAuthDataBuf, aAuthRespBuf, &aContinueData);

switch(aDirErr)

{

case eDSNoErr: aResult = true; break;

default:

//If any other error, assume the name or password is bad. aResult = false;

break;

}

// Clean up allocations.

aDirErr = dsDataBufferDeAllocate(inDirRef, anAuthDataBuf); anAuthDataBuf = NULL;

// Don't need to keep the response.

aDirErr = dsDataBufferDeAllocate(inDirRef, aAuthRespBuf); aAuthRespBuf = NULL;

//Don't need the authentication type value. Build a new one if needed

//later.

aDirErr = dsDataNodeDeAllocate(inDirRef, anAuthType2Use); anAuthType2Use = NULL;

//Return the result of the authentication. return (aResult);

}

Authenticating a User to a Node

31

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

Page 31
Image 31
Apple OS X manual Working with Nodes