Introduction This article is about a C # program to an Active Directory - query groups to realize.
I want to find out whether the user is assigned a specific group in order to then execute a different action depending on the result can.
knowledge
If a user is assigned a group in Active Directory, you can view this as in Computer Management. Among users and groups will then apply to this group. In this guide we make a loop through all groups and wait until the group is looking for.function for reading the AD group
getGroupState public Boolean () {group state
Boolean = false;
foreach (System.Security.Principal.IdentityReference group in System.Security.Principal.WindowsIdentity.GetCurrent () groups. .)
{if ((group.Translate (typeof (System.Security.Principal.NTAccount))) ToString () == "domain \\ \\ AD-Group")
group {state = true;
break;}
else {
group state = false;} return
group state;}
group The state variable is given on whether the requested group exists. With the foreach loop the entire group directory by the given name is searched. Once the name is found, the loop is broken off and set the value of the group state to true.
Boolean = false;
foreach (System.Security.Principal.IdentityReference group in System.Security.Principal.WindowsIdentity.GetCurrent () groups. .)
{if ((group.Translate (typeof (System.Security.Principal.NTAccount))) ToString () == "domain \\ \\ AD-Group")
group {state = true;
break;}
else {
group state = false;} return
group state;}
0 comments:
Post a Comment