Newbee question; form authentication

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

  1. #1

    Default Newbee question; form authentication

    Hello all,

    I have a problem with retrieving roles.

    In the login form, I do the following things;
    - Retrieve roles (string, format like "Administrator|User|Guest")
    - Create a FormsAuthenticationTicket with these roles as parameter
    - Crypt the thicket, create a cookie with this ticket
    - Store the cookie in the response / session

    (traced / debugged this part, works fine)

    In the global.asax.cs, method Application_AuthenticateRequest, I:
    - Retrieve the cookie, decrypt it, split the roles into an array
    - Create a new FormsIdentity object, IPrincipal object and store that one to
    Context.User

    For this, I followed the instructions in
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secmod/html/secmod18.asp[/url]

    In a all user forms, I can now extract the username via
    Context.User.Identity.Name
    That works fine.

    The problem is now that the roles are lost somewhere, somehow. It's like
    magic...
    Tracing everyting, retrieving and decrypting the cookie works fine, but
    authTicket.UserData is an empty string.

    Now where are my roles ?
    Any help would be greatly appriciated.

    Kind regards, Nico


    Nico den Boer Guest

  2. Similar Questions and Discussions

    1. newbee question
      Hi folks! i'm new to flash and started experimenting a little bit. I know by now how to create a button, and while surfing I came across this...
    2. Beginners question: Form based authentication
      Hello, the following question may be trivial, but after scrolling documentations on my screen for hours I'd absolutely appreciate your help: I...
    3. authenticate win32 form client with form based authentication web services
      (Type your message here) -------------------------------- From: kitchai yong Hi, Can you tell me how i authenticate the win32 form client...
    4. newbee help with php please
      hi I'm just started on the MySQL + PHP road. I have installed MySQL + MySQL_CC + dbtools and made a MySQL-database with all the data from one...
    5. Form based authentication question
      I understand that in the web.config file I can have the following: <location path="MembersOnly"> <system.web> <authorization> <allow...
  3. #2

    Default Re: Newbee question; form authentication

    Hi Nico,

    Perhaps your problem is with the max lenght of your user data string that
    you are storing inside the cookie.
    Here is a post that will show some details about this.
    [url]http://weblogs.asp.net/hernandl/archive/2004/07/30/FormsAuthRolesRev.aspx[/url]

    And there is another one that explains some perf. gains when using this
    approach for role authz with forms.
    [url]http://weblogs.asp.net/hernandl/archive/2004/08/05/FormsAuthRoles2.aspx[/url]

    Regards,
    Hernan.

    --
    Hernan de Lahitte
    [url]http://weblogs.asp.net/hernandl[/url]

    "Nico den Boer" <nicodenboer@home.nl> escribió en el mensaje
    news:uW%23KJUowEHA.4028@TK2MSFTNGP15.phx.gbl...
    > Hello all,
    >
    > I have a problem with retrieving roles.
    >
    > In the login form, I do the following things;
    > - Retrieve roles (string, format like "Administrator|User|Guest")
    > - Create a FormsAuthenticationTicket with these roles as parameter
    > - Crypt the thicket, create a cookie with this ticket
    > - Store the cookie in the response / session
    >
    > (traced / debugged this part, works fine)
    >
    > In the global.asax.cs, method Application_AuthenticateRequest, I:
    > - Retrieve the cookie, decrypt it, split the roles into an array
    > - Create a new FormsIdentity object, IPrincipal object and store that one
    > to
    > Context.User
    >
    > For this, I followed the instructions in
    > [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secmod/html/secmod18.asp[/url]
    >
    > In a all user forms, I can now extract the username via
    > Context.User.Identity.Name
    > That works fine.
    >
    > The problem is now that the roles are lost somewhere, somehow. It's like
    > magic...
    > Tracing everyting, retrieving and decrypting the cookie works fine, but
    > authTicket.UserData is an empty string.
    >
    > Now where are my roles ?
    > Any help would be greatly appriciated.
    >
    > Kind regards, Nico
    >
    >

    Hernan de Lahitte Guest

  4. #3

    Default Re: Newbee question; form authentication

    Thanks Hernan,

    I've read the articles, they are very useful !

    Kind regards,
    Nico


    Nico den Boer 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