I am using C++ with the win32 Api and I want to get the password expiry date for a user using ADSI.
CoInitialize(NULL);
LPWSTR pszADsPath=L"LDAP://CN=arjun,CN=Users,DC=raja,DC=com";
//HRESULT hr;
IADsUser *pUser;
hr = ADsGetObject(pszADsPath, IID_IADsUser, (void**) &pUser);
if(SUCCEEDED(hr))
{
DATE expirationDate;
VariantInit(&var);
hr = pUser->get_PasswordLastChanged(&expirationDate);
hr = pUser->get_PasswordExpirationDate(&expirationDate);
if (SUCCEEDED(hr))
VariantTimeToSystemTime(expirationDate,&lpExpirationDate);
pUser->Release();
}
Calling get_PasswordLastChanged will give success and return last changed password date, but I need the expiration date.
Using get_PasswordExpirationDate, I get S_OK (success) but it also gives an error code of -2147463155.
Can anyone explain what is going wrong?
The error translates to ADS_PROPERTY_NOT_FOUND. Could it be that the password for this user doesn’t expire?