Read more about System.DirectoryServices namespace and browse other threads in this forum, there are a lot of examples, similar to this:
DirectoryEntry de = new DirectoryEntry("LDAP://domain.corp:389/DC=domain,DC=corp");
DirectorySearcher ds = new DirectorySearcher(de);
ds.SearchScope = SearchScope.Subtree;
ds.Filter = "(sAMAccountName=john)"; // where john is current login (without domain)
SearchResult result = ds.FindOne();
foreach (string g in result.Properties["memberOf"])
{
Console.WriteLine(g);
}
mresanchez40
0 Points
1 Post
Lookup and Return a Users AD group Membership
Aug 11, 2011 08:47 PM|LINK
Does MVC provide an easy way to find out and return a list of a user's AD Group Membership?
After a users is authenticated via IIS/Integrated Auth, I want to query AD group and get a list/array of the user's AD Groups.
thoughts?
smirnov
All-Star
23436 Points
4029 Posts
Re: Lookup and Return a Users AD group Membership
Aug 12, 2011 09:56 AM|LINK
Read more about System.DirectoryServices namespace and browse other threads in this forum, there are a lot of examples, similar to this:
DirectoryEntry de = new DirectoryEntry("LDAP://domain.corp:389/DC=domain,DC=corp"); DirectorySearcher ds = new DirectorySearcher(de); ds.SearchScope = SearchScope.Subtree; ds.Filter = "(sAMAccountName=john)"; // where john is current login (without domain) SearchResult result = ds.FindOne(); foreach (string g in result.Properties["memberOf"]) { Console.WriteLine(g); }