Active directory call failing
Hi All,
I am trying to add an account into the active directory and then delete it after some time.
Iam able to add the account successfully into the Domain controller, but, while trying to delete this account iam facing a few problems.
THe following call is returning S_ ADS_NO_MORE_ROWS even though the account that was created previously is still there in DC.
hRes = piDS->GetNextRow(hSearch) returns S_ADS_NO_MORE_ROWS.
I tried to capture the ADsGetLastError output and it says that there is no more data.
Please advice.
Regards,
Harish Reddy.
Re: Active directory call failing
There is no such a code: S_ADS_NO_MORE_ROWS.
You probably meant S_ADS_NOMORE_ROWS :confused:
There are some examples in MSDN section "Platform SDK: Directory Services" showing how to perform a directory search... Did you use some of them?
Re: Active directory call failing
Hello Victor,
Thank you for the reply. I have followed the correct procedure of carrying out the AD search as per MSDN. In my case when iam having a sindle DC for the domain, i am able to properly add and delete account in the AD. But, when iam having more than one domain controller, the deletion operation fails "some times".
Regards,
Harish.
Re: Active directory call failing
Sorry. I can't help you in this problem... :sick:
Regards,
Victor
Re: Active directory call failing
Quote:
Originally Posted by mharishkumarreddy
Hello Victor,
Thank you for the reply. I have followed the correct procedure of carrying out the AD search as per MSDN. In my case when iam having a sindle DC for the domain, i am able to properly add and delete account in the AD. But, when iam having more than one domain controller, the deletion operation fails "some times".
Regards,
Harish.
There must be some error return, do you see any error box ?
Re: Active directory call failing
Let me paste a code snippet for you so that you can better understand the issue:
IADs* piObject = NULL;
hRes = ADsGetObject(sCN.data(),
IID_IADs,
(PVOID*)&piObject); // sCN is a String
If hRes is SUCCESS,
hRes = piObject->QueryInterface(IID_IDirectorySearch, (PVOID*)&piDS);
If hRes is SUCCESS,
hRes = piDS->ExecuteSearch((LPWSTR)sFilter.data(),NULL,
(DWORD)-1,&hSearch);
If hRes is SUCCESS,
hRes = piDS->GetNextRow(hSearch))
Here, even though the account name is present in the Active directory,
piDS->GetNextRow(hSearch) is returning S_ADS_NOMORE_ROWS in hRes.
Please advice,
Thanks,
Harish Reddy.
Re: Active directory call failing
Looking at the code, you try to bind to the domain and then search for the account you created. If that is correct.......
In the value for sCN.data() value, do you specify a target domain controller or are you using a serverless bind?
Domain Controller Specified:
LDAP: // servername/path to user container
or Serverless:
LDAP: // path to user container
{ ignore the extra whitespace in between the LDAP: and the // - I did not want it to show up as a link }
If you are using a serverless bind, your issue could be nothing more than replication between your two domain controllers. Because it is possible that on the first call you talk to DC1 and then on the second call you talk to DC2.
If this is not the case, please post the bind dn - sCN.data() and the search criteria - sFilter.data().
HTH