Mondyak
Mondyak

Reputation: 395

-2147016672 "An operations error occured" System.DirectoryServices.AccountManagement

Uisng this code

ArrayList myItems = new ArrayList();
UserPrincipal oUserPrincipal = GetUser(sUserName);

PrincipalSearchResult<Principal> oPrincipalSearchResult = oUserPrincipal.GetGroups(GetPrincipalContext(sOU));

foreach (Principal oResult in oPrincipalSearchResult)
{
    myItems.Add(oResult.Name);
}
return myItems;

I am getting an error -2147016672 "An operations error occured", tried to google it and I cannot find any answer. It happens on this line oUserPrincipal.GetGroups(GetPrincipalContext(sOU)) but it continues on to the foreach and does not throw any error and continues but if you dont place try and catch then it shows you the exception. Any ideas?

ADDITIONAL INFO

TO add into it if I use oUserPrincipal.GetGroups() without passing an OU, everything works fine.

Upvotes: 1

Views: 3373

Answers (2)

Raymund
Raymund

Reputation: 7892

That looks like a access right issue, try to change the Context Options when you try to instansiate a new PrincipalContext

Upvotes: 2

Michael Goldshteyn
Michael Goldshteyn

Reputation: 74330

You couldn't find any info, because the real error code to google was 0x80072020 (which is -2147016672 converted to hex). Basically it has to do with running under the iUSR_ServerTips account which does not have the access rights needed for the operation you are trying to perform. You can find more info at this link:

http://www.tek-tips.com/viewthread.cfm?qid=1192370&page=1

Upvotes: 2

Related Questions