psychoric still trying to figure out what this blog is about

Happy new year to my family, beloved wife and friends all over the world! Love you all!
4Dec/081

Which group(s) am I in?

If you are working in an Active Directory environment and you do utilize it for authentication in your project, this snippet might come handy. It lists the group(s) that current authenticated user belongs to, so you can expand on this to do whatever you need to.

using System.Security.Principal; //do this to save time in typing
 
foreach (IdentityReference ref in WindowsIdentity.GetCurrent().Groups) //get current user group(s)
	Console.WriteLine(ref.Translate(typeof(NTAccount)).ToString()); //translate it to meaningful value
Comments (1) Trackbacks (0)
  1. Just found out you’ve a blog. Good works on the Coder’s Code. Why stop writing now?


Leave a comment


Trackbacks are disabled.