C# Resolve Windows Identity Group ID To Name

  • Thread starter Thread starter Hrrglburf
  • Start date Start date
H

Hrrglburf

WindowsIdentity wi = WindowsIdentity.GetCurrent();
Concerning 'wi.Groups'
will get me 'id'-like values such as
"S-1-5-21-141028557-4071250340-2647578567-1028"

Anyone know how I can resolve that to get the groups name? rather than
this long string identifier?
 
Hello Hrrglburf,

Use Translate method of the IdentityReference class

WindowsIdentity wi = WindowsIdentity.GetCurrent();

foreach (IdentityReference identRef in wi.Groups)
{
IdentityReference account = identRef.Translate(typeof (NTAccount));
Console.WriteLine(account.Value);
}

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


H> WindowsIdentity wi = WindowsIdentity.GetCurrent();
H> Concerning 'wi.Groups'
H> will get me 'id'-like values such as
H> "S-1-5-21-141028557-4071250340-2647578567-1028"
H> Anyone know how I can resolve that to get the groups name? rather
H> than this long string identifier?
H>
 
Back
Top