Get User Roles?

Discussion in 'ASP .Net Security' started by Ivan Gibbs, Jan 5, 2005.

  1. Ivan Gibbs

    Ivan Gibbs Guest

    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.
     
    Ivan Gibbs, Jan 5, 2005
    #1
    1. Advertising

  2. 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.

    "Ivan Gibbs" <> wrote in message
    news:0aeb01c4f382$5beb93c0$...
    >
    > 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.
    >
    >
     
    Joe Kaplan \(MVP - ADSI\), Jan 6, 2005
    #2
    1. Advertising

  3. Have a look at one of my articles located here
    http://aspalliance.com/articleViewer.aspx?aId=553&pId=2 which is the second
    page in the article and contains a small routine to look at the roles
    contained within a Windows principal object. It will allow you to extract
    them into a string array and evaluate them from there.

    --

    - Paul Glavich
    ASP.NET MVP
    ASPInsider (www.aspinsiders.com)


    "Joe Kaplan (MVP - ADSI)" <> wrote
    in message news:%...
    > 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.
    >
    > "Ivan Gibbs" <> wrote in message
    > news:0aeb01c4f382$5beb93c0$...
    > >
    > > 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.
    > >
    > >

    >
    >
     
    Paul Glavich [MVP ASP.NET], Jan 7, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vic
    Replies:
    1
    Views:
    324
    Steve C. Orr [MVP, MCSD]
    Oct 29, 2003
  2. Techie
    Replies:
    2
    Views:
    1,018
    Techie
    Dec 30, 2004
  3. Jéjé
    Replies:
    0
    Views:
    242
    Jéjé
    Sep 27, 2005
  4. Kishore Gopalan

    Get list of Roles for a user

    Kishore Gopalan, Nov 14, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    208
    Dominick Baier [DevelopMentor]
    Nov 14, 2005
  5. Bob Sanders
    Replies:
    6
    Views:
    200
    Jacob Basham
    Nov 10, 2007
Loading...

Share This Page