I need to be able to get a list of groups the user is in, but I need to have one / several / all of the following properties:
- DistinguishedName
- name
- cn
- SamAccountName
Now I have a name, but not some of them (the names seem private, but not all match correctly. This is what I use:
ArrayList groups = new ArrayList(); foreach (System.Security.Principal.IdentityReference group in System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups) groups.Add(group.Translate(typeof(System.Security.Principal.NTAccount)));
As I said, the above works, but will not get me the proper names that I need for my program (the ones mentioned above). I need this to match the list that I get when I call all the groups in my domain:
DirectoryEntry dirEnt = new DirectoryEntry("LDAP://my_domain_controller"); DirectorySearcher srch = new DirectorySearcher(dirEnt); srch.Filter = "(objectClass=Group)"; var results = srch.FindAll();
naspinski Sep 18 '08 at 6:47 2008-09-18 06:47
source share