newbie seeks User.Identity and Application_AuthenticateRequest help

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

  1. #1

    Default newbie seeks User.Identity and Application_AuthenticateRequest help

    I'm trying to understand how security works in a ASP.NET c# project.
    The global.asax has this code:

    protected void Application_AuthenticateRequest(Object sender,EventArgs e)
    {
    HttpCookie rolesCookie = Request.Cookies["roles"];
    if ((!(rolesCookie==null)) && (!(Context.User==null)))
    {
    GenericIdentity gi = new GenericIdentity(User.Identity.Name);
    GenericPrincipal gp = new GenericPrincipal(gi, rolesCookie.Value.Split('|'));
    Context.User = gp;
    }
    }

    and on another page, they get the user name from this code:

    string strUserName = HttpContext.Current.User.Identity.Name;

    Unfortunately, I'm missing the login screen.

    How is the user name being set?

    Is it possible to do something like:

    HttpContext.Current.User.Identity.Name = "johndoe";

    ?

    thanks
    Mad Scientist Jr Guest

  2. Similar Questions and Discussions

    1. Newbie Seeks Information
      I am NOT an IT professional - just a person trying to implement an idea. I am attempting to set up a DigiChat AV/IM v5.1 chat room and seek...
    2. Capturing identity of the user
      Hi... I have made a asp page that accepts some data from user and stores it in MS Access database. Now...I want to identify the user who filled...
    3. *** User.Identity.Name
      After a user logging on, User.Identity.Name contains domain/logon name of the current user. How to get other information of the current user such as...
    4. User.Identity.Name
      Hi, I am using Forms authentication -in which - I am trying to use User.Identity.Name, i am getting the user name in this field even after i...
    5. Old ASP Windows User Identity
      Is there a way in ASP (3.0, not .NET) for me to determine who the current windows users is (i.e. the user who was authenticated and who is...
  3. #2

    Default Re: newbie seeks User.Identity and Application_AuthenticateRequest help

    This article describes how to implement Forms Authentication with roles and
    a Generic Principal:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT04.asp[/url]

    I've implemented the example from the link above, and fixed a problem with
    persisting the cookie, using xml in the cookie's FormsAuthenticationTicket
    to store the "persist" setting plus the roles. Also extended the example
    with a user database. You can download my source + database from here:
    [url]http://www.geocities.com/gaupen/index.htm?NETStuff.htm[/url]

    The example is called GenericPrincipalApp.

    Sincerely
    Svein Terje Gaup

    "Mad Scientist Jr" <usenet_daughter@yahoo.com> wrote in message
    news:7a93f3c4.0405271022.75cb7ff2@posting.google.c om...
    > I'm trying to understand how security works in a ASP.NET c# project.
    > The global.asax has this code:
    >
    > protected void Application_AuthenticateRequest(Object sender,EventArgs e)
    > {
    > HttpCookie rolesCookie = Request.Cookies["roles"];
    > if ((!(rolesCookie==null)) && (!(Context.User==null)))
    > {
    > GenericIdentity gi = new GenericIdentity(User.Identity.Name);
    > GenericPrincipal gp = new GenericPrincipal(gi,
    rolesCookie.Value.Split('|'));
    > Context.User = gp;
    > }
    > }
    >
    > and on another page, they get the user name from this code:
    >
    > string strUserName = HttpContext.Current.User.Identity.Name;
    >
    > Unfortunately, I'm missing the login screen.
    >
    > How is the user name being set?
    >
    > Is it possible to do something like:
    >
    > HttpContext.Current.User.Identity.Name = "johndoe";
    >
    > ?
    >
    > thanks

    Svein Terje Gaup 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