c# - Error with UserPrincipal.GetAuthorizationGroups() method -


I am having an issue by using the GetAuthorizationGroups method of UserPrincipal class in a web application.

(ContextType.Domain, Null, "DC = MyCompany, DC = COM", "Username", "Password"); UserPrincipal p = UserPrincipal.FindByIdentity (reference, identity type, SamAccountName, "joe.blogs"); Var group = p. Gate authority group ();

I believe this code works to an extent.

  • When I see the reference object, I can see the server and the user name / password are corrected in the object
  • when I see the p object I can see, the advertisement details pop up like a phone, etc.

There is a stack trace by error here. [PrincipalOperationException: Authorization Groups, (5) done while trying to get an error.] System.DirectoryServices.AccountManagement.AuthZSet..ctor (byte [] userSid, NetCred credentials, ContextOptions contextOptions, String Flatuser authorization, Store CTX Usersto CTX, Object UserCustombasebase) +317279 System. Directory Services ACC Management AdStore CTX Grettsman Offage (Principal P) +441 System. Directory Services Account management User Principal. Entitlement Group Helper (+78) System. Directory Services Account management User Principal. GateAuthoring Group) +11

By changing the user name and password PrincipalContext and changing the applicationpool (in IIS7) to run the same details as the same user (username@mycompany.com) - . The following code works

  PrincipalContext reference = New PrincipalContext (ContextType.Domain, blank, "DC = MyCompany, DC = COM"); UserPrincipal p = UserPrincipal.FindByIdentity (reference, identity type, SamAccountName, "joe.blogs"); Var group = p. Gate authority group ();  

I need to get the code in the first instance of working - I do not want to run the application pool as the domain code to work for this code.

See discussion on the same question I have dealt with this problem.

The solution is down:

  Public list & amp; group; Group Pinyitham & gt; GetGroups (String Username) {var Result = New List & amp; group; Group Pinyitham & gt; (); PrincipalContacts CTX = GetContext (); To obtain domain reference / * function * / UserPriner user = UserPinnal FidbiIndentity (CTX, Username); If (user! = Null) {Principal Search Arslut & lt; Principal & gt; Group = user GetAuthorizationGroups (); Var iterGroup = groups.GetEnumerator (); {IterGroup.MoveNext ()) {try {Principal P = iterGroup.Current; result. Add (Group Princetonal) P); } Grip (Principal Operation Exception) {continued; }}}} Return result; }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -