Nick Parker
My ramblings on .NET...

NT Groups in .NET 2.0

Saturday, 10 September 2005 12:43 by nickp

Yesterday, we needed to get the NT groups associated to an account. I have done this before, but now our team is working in .NET 2.0. It's worth noting that the value for each group returned from the WindowsIdentity is in the form of a SID, or a SecurityIdentifier which we can use to translate into a more human readable form, the NTAccount.

 

WindowsIdentity wi = WindowsIdentity.GetCurrent();
if
(wi != null)
{
foreach(IdentityReference group in wi.Groups)
{
if(group != null)
{
NTAccount acct
= group.Translate(typeof(NTAccount)) as NTAccount;
if
(acct != null)
{
Console.WriteLine(acct.Value)
;
}
}
}
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

August 20. 2008 03:15