How to get user domain group?
How to get name of domain group, that user belong?
I want to compare this in permission class, so ill be able to se开发者_StackOverflow中文版t same privileges to only specific user.
Here is an article on CodeProject that will show you exactly how to do it:
http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C
I've linked right to the code you will need. The code (in case the link ever breaks) is as follows:
public ArrayList Groups()
{
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)).ToString());
}
return groups;
}
精彩评论