Quick and Easy Security From Threads
Sometimes we can use Active Directory for our application security. There are a number of ways to attack the problem including the oft painful LDAP. If we need to check to see if the current user is a member of an AD group we can do it thus:
// We can start by making sure that our current principal is set correctly as it probably isn’t.
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
// Then we can save some time with an obvious check
// Now we have only to specify the name of the group in AD. Here I have
// the name “XXX_Administrators” refrenced from the resource file.