I am trying to update a field pertaining to my own user object in Active Directory using ADSI and C++ app. The operating system is Windows Server 2012 Standard.
I am able to read, I am able to call Put without problems, but when I call SetInfo, it returns with "General access denied". I have confirmed that it's my own user object I'm trying to access.
I obtain my own FQDN like this:
GetUserNameEx(EXTENDED_NAME_FORMAT::NameFullyQualifiedDN, pszFullyQualifiedDN, &dwFullyQualifiedDN);
Then I use it like this:
LPTSTR pszObj = (LPTSTR)LocalAlloc(LPTR, dwMemToAlloc);
wcscpy_s(pszObj, dwMemToAlloc / sizeof(TCHAR), L"LDAP://");
wcscat_s(pszObj, dwMemToAlloc / sizeof(TCHAR), pszFullyQualifiedDN);
I bind to an object like this:
ADsGetObject(pszObj, IID_IADs, (LPVOID*)&pObject);
This call succeeds:
pObject->Get(CComBSTR("Description"), &var);
This call also succeeds:
VariantClear(&var);
V_BSTR(&var) = SysAllocString(L"Some new value");
V_VT(&var) = VT_BSTR;
hr = pObject->Put(CComBSTR("Description"), var);
Trying to commit the above change using the following:
pObject->SetInfo();
This is where it fails.
It returns E_ACCESSDENIED General access denied error.
As you can see, that is my own user object I am trying to update. To my understanding that is supposed to work provided I am a member of Domain Users group. Which I am.
What could possibly be the problem?