IADsUser *pUser;
BSTR bstrDescription;
BSTR bstrTitle;
VARIANT vHints;
//
// Bind to the user object.
//
ADsGetObject(TEXT("WinNT://MyDomain/Users/John"),
IID_IADsUser,
(void**)&pUser);
//
// Allocate the strings for the changes.
//
bstrDescription = SysAllocString(TEXT("Johnny"));
bstrTitle = SysAllocString(TEXT("General Manager"));
bstrPassword = SysAllocString(TEXT("PW.123"));
//
// Change the Description and title of the user. The changes
// are made in the local cache only.
//
pUser->put_Description(bstrDescription);
pUser->put_Title(bstrTitle);
//
// Call SetInfo to commit the changes to the network.
//
pUser->SetInfo();
//
// Now change the user's password - this non-property method
// executes immediately.
//
pUser->SetPassword(bstrPassword);
//
// Refresh the ADSI object with a call to GetInfo.
// No hints are specified.
//
VariantInit(&vHints);
V_VT(&vHints) = VT_EMPTY;
pUser->GetInfo(vHints);
//
// Clean up and reuse the strings.
//
SysFreeString(bstrDescription);
SysFreeString(bstrTitle);
SysFreeString(bstrPassword);
//
// Retrieve values from the object.
//
pUser->get_Description(&bstrDescription);
pUser->get_Location(&bstrTitle);
printf("%s, %s", bstrDescription, bstrTitle);
//
// Release all interfaces.
//
pUser->Release();