code_junkie

How to get AD User Groups for user in Asp.Net?

Nov 10th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. ArrayList groups = new ArrayList();
  2. foreach (System.Security.Principal.IdentityReference group in System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups)
  3. groups.Add(group.Translate(typeof(System.Security.Principal.NTAccount)));
  4.  
  5. DirectoryEntry dirEnt = new DirectoryEntry("LDAP://my_domain_controller");
  6. DirectorySearcher srch = new DirectorySearcher(dirEnt);
  7. srch.Filter = "(objectClass=Group)";
  8. var results = srch.FindAll();
Add Comment
Please, Sign In to add comment