C# Resolve Windows Identity Group ID To Name

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?
 
M

Michael Nemtsev

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top