Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Get User Roles?


    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 Guest

  2. Similar Questions and Discussions

    1. Can user roles by transferred to new web server?
      Our ISP moved our files to a new web server since we were running out of room on their old server. However, our user roles did not get transferred....
    2. Backing up User Roles and other
      I have Contribute 3. From my research, the _mm/Contribute.xml and !@#$%.csi are supposed to contain the User Roles and other config data. This is...
    3. user roles corrupted
      Why all the created user roles can disappeare in 2-3 days and I have to recreate all keys again? Is _mm folder should be displayed in Dreamweaver...
    4. Switch User Roles
      Hi all, Is there any way to switch from Administrator role to normal user role without deleting settings?? Thanks. Kevin.
    5. User Roles - Global.asax
      I have the following code in global.asax, which picks up a logged in users roles from a db. if (not(HttpContext.Current.User is Nothing))...
  3. #2

    Default Re: Get User Roles?

    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" <anonymous@discussions.microsoft.com> wrote in message
    news:0aeb01c4f382$5beb93c0$a601280a@phx.gbl...
    >
    > 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\) Guest

  4. #3

    Default Re: Get User Roles?

    Have a look at one of my articles located here
    [url]http://aspalliance.com/articleViewer.aspx?aId=553&pId=2[/url] 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 ([url]www.aspinsiders.com[/url])


    "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
    in message news:%23w5ZyH68EHA.3260@TK2MSFTNGP10.phx.gbl...
    > 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" <anonymous@discussions.microsoft.com> wrote in message
    > news:0aeb01c4f382$5beb93c0$a601280a@phx.gbl...
    > >
    > > 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] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139