Tuesday, May 10, 2011

View All the AD Group that you had been added in ASP.Net

I need to know all the group  that i had been assigned, then i can use 
the corrected AD group for my application test.

here is  the code sinppet that all the application to list all the AD group  
 
IdentityReferenceCollection IRCollection=((System.Security.Principal.WindowsIdentity)
(Context.User.Identity)).Groups;
 foreach (IdentityReference ir in IRCollection)
 {
 //Response.Write("<b>GroupName:" + ir.ToString() + "</b><br />"); 
 IdentityReference idRef = ir.Translate(typeof(NTAccount));
 Response.Write("AD Group Name:" + idRef.ToString() + "<br />");
 }

No comments:

Post a Comment