Forms Authentication problem with IsAuthenticated

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

  1. #1

    Default Forms Authentication problem with IsAuthenticated

    Hello All,

    I am trying to set up forms authentication for an ASP.NET web site. I
    programmed quite a bit of stuff with custom IPrincipal and IIdentity objects
    and everything only to find out that none of it worked. After fiddling
    around with things I decided to try a really basic example. A set some
    values in the web.config as follows...

    <authentication mode="Forms">
    <forms name=".ASPXAUTH" loginUrl="Login.aspx" />
    </authentication>
    <authorization>
    <deny users="?" />
    <allow users="*" />
    </authorization>

    I then created a simple login.aspx page and a default.aspx page with no
    implementation. The only thing I wanted to do was see if accessing the
    default.aspx page would bring up the login.aspx page as expected. Didnt
    work. Not only that, but on further inspection of the
    Context.User.Identity.IsAuthenticated property revealed that I am always
    authenticated. I cannot unauthenticate myself. Further, the
    Context.User.Identity.Name comes up as my login name for windows complete
    with network domain!

    Is there a configuration option I am missing somewhere? Is there something
    in IIS that needs to be set? Please help!!!

    Cheers,

    Bob Hansen
    JASCorp, L.L.C.
    [url]www.jasrx.com[/url]
    [url]www.jascorp.com[/url]




    Bob Hansen Guest

  2. Similar Questions and Discussions

    1. Problem in forms authentication
      Hi friends, We have an web application which contains several folders & we are trying to implement forms authentication. Login page for the...
    2. forms authentication problem
      I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying...
    3. Crypto API problem while using forms authentication
      Hi, I'm developing a webapplication. I would like to use forms authentication instead of integrated windows authentication because i don't like...
    4. Forms authentication in a subfolder problem, please help
      Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain...
    5. Problem with Forms Authentication
      I have an application using FormsAuthentication that does not persist the authentication cookie beyond the session so each time a user starts a...
  3. #2

    Default Re: Forms Authentication problem with IsAuthenticated

    hv u set the cookie in the login code
    just ad the
    if (HttpContext.Current.User != null)

    {

    if (Request.IsAuthenticated)

    {

    FormsAuthenticationTicket authTicket=null;

    string strCookieName=FormsAuthentication.FormsCookieName;

    HttpCookie authCookie=Context.Request.Cookies[strCookieName];


    if (authCookie==null)

    {

    return;

    }

    else

    {

    authTicket=FormsAuthentication.Decrypt(authCookie. Value);

    string[] strarrUserGroups=authTicket.UserData.Split(new char[]{'|'});


    FormsIdentity Id=new FormsIdentity(authTicket);

    GenericPrincipal principal=new GenericPrincipal(Id,strarrUserGroups);

    }

    }

    }

    and set cookie in login code with

    methods of sormsauth class

    and it will definatley work...

    mine is working




    --
    Thanks and Regards,

    Amit Agarwal
    Software Programmer(.NET)
    "Bob Hansen" <bhansen200@jascorp.com> wrote in message
    news:uRnAxF26DHA.3704@tk2msftngp13.phx.gbl...
    > Hello All,
    >
    > I am trying to set up forms authentication for an ASP.NET web site. I
    > programmed quite a bit of stuff with custom IPrincipal and IIdentity
    objects
    > and everything only to find out that none of it worked. After fiddling
    > around with things I decided to try a really basic example. A set some
    > values in the web.config as follows...
    >
    > <authentication mode="Forms">
    > <forms name=".ASPXAUTH" loginUrl="Login.aspx" />
    > </authentication>
    > <authorization>
    > <deny users="?" />
    > <allow users="*" />
    > </authorization>
    >
    > I then created a simple login.aspx page and a default.aspx page with no
    > implementation. The only thing I wanted to do was see if accessing the
    > default.aspx page would bring up the login.aspx page as expected. Didnt
    > work. Not only that, but on further inspection of the
    > Context.User.Identity.IsAuthenticated property revealed that I am always
    > authenticated. I cannot unauthenticate myself. Further, the
    > Context.User.Identity.Name comes up as my login name for windows complete
    > with network domain!
    >
    > Is there a configuration option I am missing somewhere? Is there
    something
    > in IIS that needs to be set? Please help!!!
    >
    > Cheers,
    >
    > Bob Hansen
    > JASCorp, L.L.C.
    > [url]www.jasrx.com[/url]
    > [url]www.jascorp.com[/url]
    >
    >
    >
    >

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.577 / Virus Database: 366 - Release Date: 2/3/2004


    .NET Follower Guest

  4. #3

    Default Re: Forms Authentication problem with IsAuthenticated

    Hi...

    Let me explain you some more details...

    Actually authentication and CustomPrincipal are little different topics...

    In the authentication process you validate the credentials of a user gaiants
    any authority.... Only when the user is authenticated, you can use this
    authentication information for further to maintain the context the current
    user....to achieve the role based security...

    For that you have to ceate the custom principal by implementting IPrincipal
    Interface. It takes identity and roles to creat the custom principal... and
    the setting the custom principal in global.asax.cs / vb page...in an event
    called application_authentication beginrequest...

    Thanks
    ".NET Follower" <amitagarwal-NET@SoftHome.net> wrote in message
    news:%23vMx%23nG7DHA.1852@TK2MSFTNGP10.phx.gbl...
    > hv u set the cookie in the login code
    > just ad the
    > if (HttpContext.Current.User != null)
    >
    > {
    >
    > if (Request.IsAuthenticated)
    >
    > {
    >
    > FormsAuthenticationTicket authTicket=null;
    >
    > string strCookieName=FormsAuthentication.FormsCookieName;
    >
    > HttpCookie authCookie=Context.Request.Cookies[strCookieName];
    >
    >
    > if (authCookie==null)
    >
    > {
    >
    > return;
    >
    > }
    >
    > else
    >
    > {
    >
    > authTicket=FormsAuthentication.Decrypt(authCookie. Value);
    >
    > string[] strarrUserGroups=authTicket.UserData.Split(new char[]{'|'});
    >
    >
    > FormsIdentity Id=new FormsIdentity(authTicket);
    >
    > GenericPrincipal principal=new GenericPrincipal(Id,strarrUserGroups);
    >
    > }
    >
    > }
    >
    > }
    >
    > and set cookie in login code with
    >
    > methods of sormsauth class
    >
    > and it will definatley work...
    >
    > mine is working
    >
    >
    >
    >
    > --
    > Thanks and Regards,
    >
    > Amit Agarwal
    > Software Programmer(.NET)
    > "Bob Hansen" <bhansen200@jascorp.com> wrote in message
    > news:uRnAxF26DHA.3704@tk2msftngp13.phx.gbl...
    > > Hello All,
    > >
    > > I am trying to set up forms authentication for an ASP.NET web site. I
    > > programmed quite a bit of stuff with custom IPrincipal and IIdentity
    > objects
    > > and everything only to find out that none of it worked. After fiddling
    > > around with things I decided to try a really basic example. A set some
    > > values in the web.config as follows...
    > >
    > > <authentication mode="Forms">
    > > <forms name=".ASPXAUTH" loginUrl="Login.aspx" />
    > > </authentication>
    > > <authorization>
    > > <deny users="?" />
    > > <allow users="*" />
    > > </authorization>
    > >
    > > I then created a simple login.aspx page and a default.aspx page with no
    > > implementation. The only thing I wanted to do was see if accessing the
    > > default.aspx page would bring up the login.aspx page as expected. Didnt
    > > work. Not only that, but on further inspection of the
    > > Context.User.Identity.IsAuthenticated property revealed that I am always
    > > authenticated. I cannot unauthenticate myself. Further, the
    > > Context.User.Identity.Name comes up as my login name for windows
    complete
    > > with network domain!
    > >
    > > Is there a configuration option I am missing somewhere? Is there
    > something
    > > in IIS that needs to be set? Please help!!!
    > >
    > > Cheers,
    > >
    > > Bob Hansen
    > > JASCorp, L.L.C.
    > > [url]www.jasrx.com[/url]
    > > [url]www.jascorp.com[/url]
    > >
    > >
    > >
    > >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    > Version: 6.0.577 / Virus Database: 366 - Release Date: 2/3/2004
    >
    >

    Madan Nayak Guest

Posting Permissions

  • You may not post new threads
  • You may not 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