Platform SDK: TAPI

Adding a User Object to an ILS Server

The following code fragment illustrates publishing a user object in an ILS server. Once a user object is published, remote parties can use the user object to make calls to the specified user.

This fragment assumes that connecting to an ILS server has already been performed.

// Automatically refresh user objects in the background so that they do not time out.
hr = pDirectory->EnableAutoRefresh(VARIANT_TRUE);

// Create a user object.
BSTR bUserName = SysAllocString(L"myname");
ITDirectoryObject * pDirectoryObject;
hr = pRend->CreateDirectoryObject(
        OT_USER, 
        bUserName, 
        &pDirectoryObject
        );
SysFreeString(bUserName);

// Get the user configuration interface.
ITDirectoryObjectUser * pUser;
hr = pDirectoryObject->QueryInterface(
        IID_ITDirectoryObjectUser, 
        (void **) &pUser
        );

// Set the IP "phone number" of this user.
BSTR bHostName = SysAllocString(L"mymachine.microsoft.com");
hr = pUser->put_IPPhonePrimary(bHostName);
SysFreeString(bHostName);

// Copy the user object to the server.
hr = pDirectory->AddDirectObject(pDirectoryObject);

See Also

ITDirectory, ITDirectoryObject, ITDirectoryObjectUser