Get User Roles?

I

Ivan Gibbs

In C#, I want to log in a user who has a specific role.
The role was originally "Cashier". However, now
the "Cashier" can be prefixed with anything, such
as "LS_Cashier". Since the role name is not known any
more, how can the user be logged in?

I have been working on getting all the role names and
checking if any contain "Cashier", but I have not found a
way to get a list of the current roles. There was some
discussion of TokenGroups, but this has not lead to a
solution for C#.

Any help would be appreciated.
 
J

Joe Kaplan \(MVP - ADSI\)

What is the type on the IPrincipal that you are checking? If it was a
WindowsPrincipal, the roles would be Windows groups and would be prefixed
with a domain or machine name like domain\cashier. If it isn't a
WindowsPrincipal, then it is likely some other type of IPrincipal that is
created in your code somewhere. If so, then you can probably add a Roles
property to the type and then enumerate them that way.

If it is a WindowsPrincipal, then there are a few options for getting the
groups. The Token property of WindowsIdentity in the Identity object can be
used to call into unmanaged code to get the token groups as SIDs. Then,
more unmanaged code can be used to convert them to names.

If you provide more details, we can help more.

Joe K.
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top