Get list of Roles for a user

K

Kishore Gopalan

I need to get a list of roles to which a User belongs. I tried using the
code,

IdentityReferenceCollection icol = WindowsIdentity.GetCurrent().Groups;

But it only returns SIDs. Is there a way I can get the actual roles to which
a User belongs..?

Thanks

Kishore
 
D

Dominick Baier [DevelopMentor]

Hello Kishore,

you have to convert the SIDs to the "friendly names" afterwards.

private static string[] getRoles(WindowsIdentity id)
{
List<string> groups = new List<string>();
IdentityReferenceCollection irc = id.Groups.Translate(typeof(NTAccount));

foreach (NTAccount acc in irc)
{
groups.Add(acc.Value);
}
return groups.ToArray();
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top