Trying to set "User cannot change password" option using ADSI
COM
1
Posts
1
Posters
0
Views
1
Watching
-
Hi, I am trying to set the "User cannot change password" option using ADSI. The code is as follows. if(PWNoChange.GetCheck() == 1) { VariantInit(&var); CComBSTR sbstrUserFlags = "userFlags"; hr = pUser->Get(sbstrUserFlags, &var); if(FAILED(hr)) { AfxMessageBox(_T("Get Failed")); return; } V_I4(&var) |= ADS_UF_DONT_EXPIRE_PASSWD; hr = pUser->Put(sbstrUserFlags, var); if(FAILED(hr)) { AfxMessageBox(_T("put Failed")); return; } VariantClear(&var); } When I am running the code , I am getting the message "Get Failed". Could you plz let me know where I am going wrong?
Taruni