Forms Authentication

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

  1. #1

    Default Forms Authentication

    Hi,

    I am working with forms authentication, so when the user leaves the
    application pushing the exit option the program execute the following
    instrucctions:

    FormsAuthentication.SignOut()
    Response.Redirect("login.aspx")

    but, when the user leaves the application pushing the close button of the
    navigator (placed at the right top of the screen) the instrucctions won't be
    executed.

    Is there any way to catch this event in order to make the execution of the
    above instructions ??

    I would really appreciate your helping me...!

    Thanks in advance....!

    Boris


    Boris Condarco Guest

  2. Similar Questions and Discussions

    1. Accessing htm files without authentication (forms authentication)
      I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But...
    2. ASP.Net Forms authentication with basic authentication popup
      Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user...
    3. Forms authentication then redirection to a secure web with NT authentication?
      Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've...
    4. Authentication ticket, cookieless, forms authentication?
      Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the...
    5. Forms authentication with Windows authentication
      Hi, I have an ASP.NET web site that uses IIS Basic Authentication and accesses an OLAP Server at various stages. The OLAP Server authentication...
  3. #2

    Default RE: Forms Authentication

    Boris,

    That's a client-side event (onunload of the <body>) that you would capture,
    and since HTTP is connectionless, you won't be able to run your code. You
    can do it by having a client-side event take you to an ASPX page that runs
    code to sign the user out, but you wouldn't want to do that because it
    would run when the user navigates away from the page as well.

    You're not going to be able to do this. You cannot rely on the Session_End
    firing when the user closes the browser. In fact, it won't. It will only
    fire when the session expires or if you call Session.Abandon.

    Jim Cheshire
    Developer Support
    ASP.NET
    [email]jamesche@online.microsoft.com[/email]

    This post is provided as-is with no warranties and confers no rights.

    --------------------
    >Reply-To: "Boris Condarco" <bcondarco@sbef.gov.bo>
    >From: "Boris Condarco" <bcondarco@sbef.gov.bo>
    >Subject: Forms Authentication
    >Date: Tue, 29 Jul 2003 15:00:05 -0400
    >Lines: 23
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
    >Message-ID: <uSHgqcgVDHA.532@TK2MSFTNGP09.phx.gbl>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 166.114.44.250
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:163109
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >Hi,
    >
    >I am working with forms authentication, so when the user leaves the
    >application pushing the exit option the program execute the following
    >instrucctions:
    >
    >FormsAuthentication.SignOut()
    >Response.Redirect("login.aspx")
    >
    >but, when the user leaves the application pushing the close button of the
    >navigator (placed at the right top of the screen) the instrucctions won't
    be
    >executed.
    >
    >Is there any way to catch this event in order to make the execution of the
    >above instructions ??
    >
    >I would really appreciate your helping me...!
    >
    >Thanks in advance....!
    >
    >Boris
    >
    >
    >
    Jim Cheshire Guest

  4. #3

    Default Re: Forms Authentication

    Thanks a lot guys for helping me to clear the concepts above

    "Jim Cheshire (MS)" <jamesche@online.microsoft.com> wrote in message
    news:YtIAMGhVDHA.1800@cpmsftngxa06.phx.gbl...
    > Boris,
    >
    > That's a client-side event (onunload of the <body>) that you would
    capture,
    > and since HTTP is connectionless, you won't be able to run your code. You
    > can do it by having a client-side event take you to an ASPX page that runs
    > code to sign the user out, but you wouldn't want to do that because it
    > would run when the user navigates away from the page as well.
    >
    > You're not going to be able to do this. You cannot rely on the
    Session_End
    > firing when the user closes the browser. In fact, it won't. It will only
    > fire when the session expires or if you call Session.Abandon.
    >
    > Jim Cheshire
    > Developer Support
    > ASP.NET
    > [email]jamesche@online.microsoft.com[/email]
    >
    > This post is provided as-is with no warranties and confers no rights.
    >
    > --------------------
    > >Reply-To: "Boris Condarco" <bcondarco@sbef.gov.bo>
    > >From: "Boris Condarco" <bcondarco@sbef.gov.bo>
    > >Subject: Forms Authentication
    > >Date: Tue, 29 Jul 2003 15:00:05 -0400
    > >Lines: 23
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
    > >Message-ID: <uSHgqcgVDHA.532@TK2MSFTNGP09.phx.gbl>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: 166.114.44.250
    > >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
    > >Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet:163109
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > >
    > >Hi,
    > >
    > >I am working with forms authentication, so when the user leaves the
    > >application pushing the exit option the program execute the following
    > >instrucctions:
    > >
    > >FormsAuthentication.SignOut()
    > >Response.Redirect("login.aspx")
    > >
    > >but, when the user leaves the application pushing the close button of the
    > >navigator (placed at the right top of the screen) the instrucctions won't
    > be
    > >executed.
    > >
    > >Is there any way to catch this event in order to make the execution of
    the
    > >above instructions ??
    > >
    > >I would really appreciate your helping me...!
    > >
    > >Thanks in advance....!
    > >
    > >Boris
    > >
    > >
    > >
    >

    Boris Condarco Guest

  5. #4

    Default Forms Authentication

    I'm beggining to migrate one of my asp apps to asp.net but i'm stuck at
    some security issues.
    My asp application has a custom made auth method (roles, permissions, ip
    deny, etc) and I'm thinking to mantain the same base on .net, but I
    don't know why, i'm not feeling safe with the FORMS Authentication.

    My question is:

    Is it fully secure for me to build my entire application based on this
    Authentication?

    PS. Windows and passport do not combine with the hosting server.

    Gustavo Mateus Guest

  6. #5

    Default forms authentication

    hi,

    two people can login to yahoo on the same computer on seperate browser
    windows. first one logins using a browser window and then the other
    one opens another explorer window and logins. two windows can be open
    simultaniously. maybe this is not secure but the two can be very good
    friends or a couple :))

    my problem is, can we do this with forms authentication in asp.net.
    whenever i do this, all user identities turns to the one that lastly
    logged in.
    how can i solve this.

    i know that yahoo uses some kind of forms authentication.

    KaaN
    [email]kaan.oezturk@spdata.de[/email]
    [url]www.spdata.de[/url]
    KaaN Guest

  7. #6

    Default Forms Authentication

    I have set up forms authentication for my web application.
    I have several subdirectories inside a main directory and
    I have forms authentication for each of my sub directories.

    In the logon page when the user is authenticated, I have

    FormsAuthentication.RedirectFromLoginPage(txtLogon id.Text,
    False)

    And in the web.config files of my subdirectory, I have
    <authentication mode="Forms">
    <forms name=".ASPXAUTH"
    loginUrl="../Default.aspx" timeout="20"/>
    </authentication>
    <authorization>
    <deny users="?" />
    </authorization>

    -------------------------

    This works absolutely fine without any problems. When I
    deployed my entire app to a new server, I started getting
    problems. When I click a link to the subdirectory, it
    redirects me to a logon page, which means I'm not
    authorized.

    Does this mean that my Authentication ticket has not been
    created or what? I do not understand. The same copy of the
    application still works fine in my old server. Do I have
    to change any settings in my new server?

    Any help is appreciated.

    Thanks,
    Sudhir.


    Dotnet beginner Guest

  8. #7

    Default Forms Authentication

    Hi DotNet Beginner
    I don't have a solution on your problem but I still want
    to answer because it's a problem that no one want to
    answer. I have had almost the same problem since this
    summer and I've written 3 messages about the problem here
    and no answer. I have a good working website with
    framework 1.0. When I update to version 1.1 I get the
    same problem as you. If i degrade to 1.0 it works again.
    The big problem came when I started to use Visual Studio
    2003. No I'm unable to work on my projects because I must
    have framework ver 1.1.I don't know if you have ver 1.1
    on your new server but that can be the problem!

    I hope someone read our messages and come to our help.
    /Arne
    >-----Original Message-----
    >I have set up forms authentication for my web
    application.
    >I have several subdirectories inside a main directory
    and
    >I have forms authentication for each of my sub
    directories.
    >
    >In the logon page when the user is authenticated, I have
    >
    >FormsAuthentication.RedirectFromLoginPage
    (txtLogonid.Text,
    >False)
    >
    >And in the web.config files of my subdirectory, I have
    > <authentication mode="Forms">
    > <forms name=".ASPXAUTH"
    >loginUrl="../Default.aspx" timeout="20"/>
    > </authentication>
    > <authorization>
    > <deny users="?" />
    > </authorization>
    >
    >-------------------------
    >
    >This works absolutely fine without any problems. When I
    >deployed my entire app to a new server, I started
    getting
    >problems. When I click a link to the subdirectory, it
    >redirects me to a logon page, which means I'm not
    >authorized.
    >
    >Does this mean that my Authentication ticket has not
    been
    >created or what? I do not understand. The same copy of
    the
    >application still works fine in my old server. Do I have
    >to change any settings in my new server?
    >
    >Any help is appreciated.
    >
    >Thanks,
    >Sudhir.
    >
    >
    >.
    >
    Guest

  9. #8

    Default Forms Authentication

    Hello everyone,

    I have found a problem with form authentication method that I can't
    solve. The problem is:

    I want to use a form authentication in my application, so i set :
    <authentication mode="Forms">
    ,and
    <forms name="LoginForm" loginUrl="SM_LoginPage.aspx" protection="All">

    but the structure of my application folders is following:

    root
    |
    +CommonPages
    | + loginPage.aspx
    |
    +SysPages
    | + Sys1Pages
    | | +Page1.aspx
    | + Sys2Pages
    | +Page2.aspx
    + OtherPages
    + Page3.asp

    Because of this structure the relative path of LoginPage.aspx is
    diffrent for Page1.aspx(../../CommonPages/loginPage.aspx) and Page for
    page3.aspx(../CommonPages/loginPage.aspx). I have to set this path in
    web.config and I want to use relative path (not [url]http://.[/url]....). Is there
    any way to do this?? (sth like {root}//CommonPages/loginPage.aspx)??
    Thanks for any help

    Best Regards
    Slawek






    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    slawek xxxxx Guest

  10. #9

    Default Forms Authentication

    I wonder if anyone can help.

    We have web application using Forms Authentication that works
    perfectly ok in all environments, but in the production environment
    the forms authentication isn't timing out and returning the user to a
    login screen. Instead it tries to load the requested page and falls
    over on a multiple control id. Remember these errors don't happen in
    the Development and Testing environments.

    Another interesting point is, if I set the persistence of the cookie
    to true it doesn't write the cookie. The application continues to
    work, but obviously doesn't remember the user on a return (as the
    cookie isn't there). This happens in all environments.

    Event logs show no indication of the worker process being recycled and
    everthing seems to be ok.

    Any ideas or suggestions?
    Tony Guest

  11. #10

    Default Re: Forms Authentication

    Regarding your second issue, the one with the persist that doesn't work. I
    stumbled into the same issue working my way through this example:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT04.asp[/url]

    The example itself does not offer persisance of the logon cookie, so I tried
    to extend it. The only way to set any kind of persistance is by setting it
    inside the Global.asax.cs "Application_AuthnenticateRequest" event handler.

    In the Logon-button click-event handler, I create a xml document which I
    store inside the FormsAuthenticationTicket. The xml document contains a
    value indicating wether to persist the cookie or not. If true, I set the
    "Expiration" of the cookie to 365 days from now, and then replace updated
    values into the cookie:

    //Reset the expiration of the cookie
    if(persist) {
    authCookie.Expires = DateTime.Now.AddDays(365); }
    //Replace updated cookie into Response
    Context.Response.Cookies.Set(authCookie);

    You may download the complete code from here:
    [url]http://www.geocities.com/gaupen/NETStuff.htm[/url]
    The example is called "GenericPrincipalApp".

    Your first problem is trickier, and I'm sorry to say I can't offer you much
    help from the description you have given. What do you mean by "a multiple
    control id"? Do you have the exact error message? Could you perhaps show
    some code samples?

    Perhaps you could check for a valid authentication cookie in
    Application_AuthnenticateRequest, and do a "FormsAuthentication.Logout()" if
    there isn't one.

    Sincerely
    Svein Terje Gaup

    "Tony" <questions@resolutionsnet.co.uk> wrote in message
    news:bbbbb773.0405290212.71bb6f74@posting.google.c om...
    > I wonder if anyone can help.
    >
    > We have web application using Forms Authentication that works
    > perfectly ok in all environments, but in the production environment
    > the forms authentication isn't timing out and returning the user to a
    > login screen. Instead it tries to load the requested page and falls
    > over on a multiple control id. Remember these errors don't happen in
    > the Development and Testing environments.
    >
    > Another interesting point is, if I set the persistence of the cookie
    > to true it doesn't write the cookie. The application continues to
    > work, but obviously doesn't remember the user on a return (as the
    > cookie isn't there). This happens in all environments.
    >
    > Event logs show no indication of the worker process being recycled and
    > everthing seems to be ok.
    >
    > Any ideas or suggestions?

    Svein Terje Gaup Guest

  12. #11

    Default forms authentication

    How to exclude an aspx page from the Forms authentication of a asp.net web application. It means when ever user requests for that page it should not redirect the request to a logon page to collect credentials.
    I have forgot password page which needs to be accessed by the user without authentication. pls let me know how to do this

    TI
    -Gopi
    Gopi Guest

  13. #12

    Default RE: forms authentication

    Dear Gopi

    In the web.config of the root folder (where you have specified the authentication mode), just specify the followin

    <location path="ForgotPassword Page"><system.web><authorization><allow users="*" /></authorization></system.web></location

    hope it helps

    ----- Gopi wrote: ----

    How to exclude an aspx page from the Forms authentication of a asp.net web application. It means when ever user requests for that page it should not redirect the request to a logon page to collect credentials.
    I have forgot password page which needs to be accessed by the user without authentication. pls let me know how to do this

    TI
    -Gopi
    ranganh Guest

  14. #13

    Default Forms Authentication

    Is it possible to authenticate only a certain page or set of pages within an
    ASP.NET application that are all in the same folder? In other words, I have a
    web directory that contains multiple ASPX pages, but I only want to
    authenticate on one of the pages.

    Is it possible to set up the wbe.config file in such a way? I do not want to
    have to resort to putting the one page I want to authenticate on into a
    different subfolder with its own web.config file.
    Norm Guest

  15. #14

    Default Re: Forms Authentication

    On Tue, 5 Oct 2004 06:59:07 -0700, "Norm" <Norm@discussions.microsoft.com> wrote:

    ¤ Is it possible to authenticate only a certain page or set of pages within an
    ¤ ASP.NET application that are all in the same folder? In other words, I have a
    ¤ web directory that contains multiple ASPX pages, but I only want to
    ¤ authenticate on one of the pages.
    ¤
    ¤ Is it possible to set up the wbe.config file in such a way? I do not want to
    ¤ have to resort to putting the one page I want to authenticate on into a
    ¤ different subfolder with its own web.config file.

    I would take a look at the below article. It demonstrates how to use Forms based authentication for
    selected pages:

    [url]http://msdn.microsoft.com/msdnmag/issues/02/05/ASPSec2/default.aspx[/url]


    Paul ~~~ [email]pclement@ameritech.net[/email]
    Microsoft MVP (Visual Basic)
    Paul Clement Guest

  16. #15

    Default Re: Forms Authentication

    Thanks, Paul.

    "Paul Clement" wrote:
    > On Tue, 5 Oct 2004 06:59:07 -0700, "Norm" <Norm@discussions.microsoft.com> wrote:
    >
    > ¤ Is it possible to authenticate only a certain page or set of pages within an
    > ¤ ASP.NET application that are all in the same folder? In other words, I have a
    > ¤ web directory that contains multiple ASPX pages, but I only want to
    > ¤ authenticate on one of the pages.
    > ¤
    > ¤ Is it possible to set up the wbe.config file in such a way? I do not want to
    > ¤ have to resort to putting the one page I want to authenticate on into a
    > ¤ different subfolder with its own web.config file.
    >
    > I would take a look at the below article. It demonstrates how to use Forms based authentication for
    > selected pages:
    >
    > [url]http://msdn.microsoft.com/msdnmag/issues/02/05/ASPSec2/default.aspx[/url]
    >
    >
    > Paul ~~~ [email]pclement@ameritech.net[/email]
    > Microsoft MVP (Visual Basic)
    >
    Norm Guest

  17. #16

    Default forms authentication

    I have two separate functionalities within the same site. I would like to
    use forms authentication and redirect to two separate pages if the user does
    not pass the authentication (authentication for one functionality is by
    password and the other is by passed in site id). I see that forms
    authentication can not be set up in sub directories, it can only be done in
    the applicaion web.config. Is there any way around this limitation or do I
    have to set up two different sites?

    Any help appreciated.

    Thanks,
    Lloyd
    lohara Guest

  18. #17

    Default Forms Authentication

    Hello all,
    I am trying to use Forms authentication. I have got it to work
    successfully, when the login page, and the redirect page are in the same
    virtual directory, however, I want to put the login page into a separate
    directory. When the user logs in, they will be directed to an application,
    that may be different for each user, and these applications will be in
    separate virtual directories. When I try to login, the login page returns.
    This seems to indicate that the authorization is not being passed on to the
    application.

    Here is my code:
    Dim AppLogin As New AppLogin
    If AppLogin.LoginIsAuthorized(txtClientNo.Text, _
    txtUsername.Text, txtPassword.Text) Then
    'FormsAuthentication.RedirectFromLoginPage("lrutko wski", False)
    'FormsAuthentication.SetAuthCookie("lrutkowski", False)
    Dim authTicket As New FormsAuthenticationTicket(1,
    txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
    'Dim authTicket As New FormsAuthenticationTicket(1,
    "lrutkowski", DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
    Dim encryptedTicket As String =
    FormsAuthentication.Encrypt(authTicket)
    Dim authCookie As New
    HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
    Response.Cookies.Add(authCookie)
    Response.Redirect("/CustomerService/default.aspx")
    Else
    lblErrorMsg.Text = "Login is invalid"
    End If

    and here is my web.config:

    <authentication mode="Forms">
    <forms name=".gfdASPXAUTH"
    path="/" loginUrl="/PortalLogin/PortalLogin.aspx"
    protection="All" timeout="30"
    requireSSL="false">
    </forms>
    </authentication>

    <!-- AUTHORIZATION
    This section sets the authorization policies of the application.
    You can allow or deny access
    to application resources by user or role. Wildcards: "*" mean
    everyone, "?" means anonymous
    (unauthenticated) users.
    -->
    <authorization>
    <deny users="?" />
    <!-- <allow users="*" /> --> <!-- Allow all users -->
    <!-- <allow users="[comma separated list of users]"
    roles="[comma separated list of roles]"/>
    <deny users="[comma separated list of users]"
    roles="[comma separated list of roles]"/>
    -->
    </authorization>


    Thanks, Leonard

    Leonard Rutkowski Guest

  19. #18

    Default Re: Forms Authentication

    If you want to redirect your users to different virtual directories though
    different applications, you have a SSO (Single Sign On) scenario with Forms
    Authentication therefore I suggest you this post:

    [url]http://weblogs.asp.net/hernandl/archive/2004/06/09/ssoformsauth.aspx[/url]

    Regards.

    Hernan de Lahitte
    [url]http://weblogs.asp.net/hernandl[/url]
    [url]http://www.lagash.com/english/index.html[/url]

    "Leonard Rutkowski" <LeonardRutkowski@discussions.microsoft.com> wrote in
    message news:57B8B42F-3B2C-4F8C-9343-890A2895F005@microsoft.com...
    > Hello all,
    > I am trying to use Forms authentication. I have got it to work
    > successfully, when the login page, and the redirect page are in the same
    > virtual directory, however, I want to put the login page into a separate
    > directory. When the user logs in, they will be directed to an
    > application,
    > that may be different for each user, and these applications will be in
    > separate virtual directories. When I try to login, the login page
    > returns.
    > This seems to indicate that the authorization is not being passed on to
    > the
    > application.
    >
    > Here is my code:
    > Dim AppLogin As New AppLogin
    > If AppLogin.LoginIsAuthorized(txtClientNo.Text, _
    > txtUsername.Text, txtPassword.Text) Then
    > 'FormsAuthentication.RedirectFromLoginPage("lrutko wski", False)
    > 'FormsAuthentication.SetAuthCookie("lrutkowski", False)
    > Dim authTicket As New FormsAuthenticationTicket(1,
    > txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False,
    > "test")
    > 'Dim authTicket As New FormsAuthenticationTicket(1,
    > "lrutkowski", DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
    > Dim encryptedTicket As String =
    > FormsAuthentication.Encrypt(authTicket)
    > Dim authCookie As New
    > HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
    > Response.Cookies.Add(authCookie)
    > Response.Redirect("/CustomerService/default.aspx")
    > Else
    > lblErrorMsg.Text = "Login is invalid"
    > End If
    >
    > and here is my web.config:
    >
    > <authentication mode="Forms">
    > <forms name=".gfdASPXAUTH"
    > path="/" loginUrl="/PortalLogin/PortalLogin.aspx"
    > protection="All" timeout="30"
    > requireSSL="false">
    > </forms>
    > </authentication>
    >
    > <!-- AUTHORIZATION
    > This section sets the authorization policies of the application.
    > You can allow or deny access
    > to application resources by user or role. Wildcards: "*" mean
    > everyone, "?" means anonymous
    > (unauthenticated) users.
    > -->
    > <authorization>
    > <deny users="?" />
    > <!-- <allow users="*" /> --> <!-- Allow all users -->
    > <!-- <allow users="[comma separated list of users]"
    > roles="[comma separated list of roles]"/>
    > <deny users="[comma separated list of users]"
    > roles="[comma separated list of roles]"/>
    > -->
    > </authorization>
    >
    >
    > Thanks, Leonard
    >

    Hernan de Lahitte Guest

  20. #19

    Default Re: Forms Authentication

    Hi Hernan,
    I read this article, and didn't really understand it. I will take another
    look at it.

    Thanks,
    Leonard

    "Hernan de Lahitte" wrote:
    > If you want to redirect your users to different virtual directories though
    > different applications, you have a SSO (Single Sign On) scenario with Forms
    > Authentication therefore I suggest you this post:
    >
    > [url]http://weblogs.asp.net/hernandl/archive/2004/06/09/ssoformsauth.aspx[/url]
    >
    > Regards.
    >
    > Hernan de Lahitte
    > [url]http://weblogs.asp.net/hernandl[/url]
    > [url]http://www.lagash.com/english/index.html[/url]
    >
    > "Leonard Rutkowski" <LeonardRutkowski@discussions.microsoft.com> wrote in
    > message news:57B8B42F-3B2C-4F8C-9343-890A2895F005@microsoft.com...
    > > Hello all,
    > > I am trying to use Forms authentication. I have got it to work
    > > successfully, when the login page, and the redirect page are in the same
    > > virtual directory, however, I want to put the login page into a separate
    > > directory. When the user logs in, they will be directed to an
    > > application,
    > > that may be different for each user, and these applications will be in
    > > separate virtual directories. When I try to login, the login page
    > > returns.
    > > This seems to indicate that the authorization is not being passed on to
    > > the
    > > application.
    > >
    > > Here is my code:
    > > Dim AppLogin As New AppLogin
    > > If AppLogin.LoginIsAuthorized(txtClientNo.Text, _
    > > txtUsername.Text, txtPassword.Text) Then
    > > 'FormsAuthentication.RedirectFromLoginPage("lrutko wski", False)
    > > 'FormsAuthentication.SetAuthCookie("lrutkowski", False)
    > > Dim authTicket As New FormsAuthenticationTicket(1,
    > > txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False,
    > > "test")
    > > 'Dim authTicket As New FormsAuthenticationTicket(1,
    > > "lrutkowski", DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
    > > Dim encryptedTicket As String =
    > > FormsAuthentication.Encrypt(authTicket)
    > > Dim authCookie As New
    > > HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
    > > Response.Cookies.Add(authCookie)
    > > Response.Redirect("/CustomerService/default.aspx")
    > > Else
    > > lblErrorMsg.Text = "Login is invalid"
    > > End If
    > >
    > > and here is my web.config:
    > >
    > > <authentication mode="Forms">
    > > <forms name=".gfdASPXAUTH"
    > > path="/" loginUrl="/PortalLogin/PortalLogin.aspx"
    > > protection="All" timeout="30"
    > > requireSSL="false">
    > > </forms>
    > > </authentication>
    > >
    > > <!-- AUTHORIZATION
    > > This section sets the authorization policies of the application.
    > > You can allow or deny access
    > > to application resources by user or role. Wildcards: "*" mean
    > > everyone, "?" means anonymous
    > > (unauthenticated) users.
    > > -->
    > > <authorization>
    > > <deny users="?" />
    > > <!-- <allow users="*" /> --> <!-- Allow all users -->
    > > <!-- <allow users="[comma separated list of users]"
    > > roles="[comma separated list of roles]"/>
    > > <deny users="[comma separated list of users]"
    > > roles="[comma separated list of roles]"/>
    > > -->
    > > </authorization>
    > >
    > >
    > > Thanks, Leonard
    > >
    >
    >
    >
    Leonard Rutkowski Guest

  21. #20

    Default Re: Forms Authentication

    Feel free to ask me whatever thing you don't understand in that article or
    if you wish to give me your feedback about what you find confusing, I'll
    appreciate a great.


    --
    Hernan de Lahitte
    [url]http://weblogs.asp.net/hernandl[/url]
    [url]http://www.lagash.com/english/index.html[/url]

    "Leonard Rutkowski" <LeonardRutkowski@discussions.microsoft.com> wrote in
    message news:4C74D2CF-01DA-4539-B139-D761BE221CDC@microsoft.com...
    > Hi Hernan,
    > I read this article, and didn't really understand it. I will take another
    > look at it.
    >
    > Thanks,
    > Leonard
    >
    > "Hernan de Lahitte" wrote:
    >
    >> If you want to redirect your users to different virtual directories
    >> though
    >> different applications, you have a SSO (Single Sign On) scenario with
    >> Forms
    >> Authentication therefore I suggest you this post:
    >>
    >> [url]http://weblogs.asp.net/hernandl/archive/2004/06/09/ssoformsauth.aspx[/url]
    >>
    >> Regards.
    >>
    >> Hernan de Lahitte
    >> [url]http://weblogs.asp.net/hernandl[/url]
    >> [url]http://www.lagash.com/english/index.html[/url]
    >>
    >> "Leonard Rutkowski" <LeonardRutkowski@discussions.microsoft.com> wrote in
    >> message news:57B8B42F-3B2C-4F8C-9343-890A2895F005@microsoft.com...
    >> > Hello all,
    >> > I am trying to use Forms authentication. I have got it to work
    >> > successfully, when the login page, and the redirect page are in the
    >> > same
    >> > virtual directory, however, I want to put the login page into a
    >> > separate
    >> > directory. When the user logs in, they will be directed to an
    >> > application,
    >> > that may be different for each user, and these applications will be in
    >> > separate virtual directories. When I try to login, the login page
    >> > returns.
    >> > This seems to indicate that the authorization is not being passed on to
    >> > the
    >> > application.
    >> >
    >> > Here is my code:
    >> > Dim AppLogin As New AppLogin
    >> > If AppLogin.LoginIsAuthorized(txtClientNo.Text, _
    >> > txtUsername.Text, txtPassword.Text) Then
    >> > 'FormsAuthentication.RedirectFromLoginPage("lrutko wski",
    >> > False)
    >> > 'FormsAuthentication.SetAuthCookie("lrutkowski", False)
    >> > Dim authTicket As New FormsAuthenticationTicket(1,
    >> > txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False,
    >> > "test")
    >> > 'Dim authTicket As New FormsAuthenticationTicket(1,
    >> > "lrutkowski", DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
    >> > Dim encryptedTicket As String =
    >> > FormsAuthentication.Encrypt(authTicket)
    >> > Dim authCookie As New
    >> > HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
    >> > Response.Cookies.Add(authCookie)
    >> > Response.Redirect("/CustomerService/default.aspx")
    >> > Else
    >> > lblErrorMsg.Text = "Login is invalid"
    >> > End If
    >> >
    >> > and here is my web.config:
    >> >
    >> > <authentication mode="Forms">
    >> > <forms name=".gfdASPXAUTH"
    >> > path="/" loginUrl="/PortalLogin/PortalLogin.aspx"
    >> > protection="All" timeout="30"
    >> > requireSSL="false">
    >> > </forms>
    >> > </authentication>
    >> >
    >> > <!-- AUTHORIZATION
    >> > This section sets the authorization policies of the
    >> > application.
    >> > You can allow or deny access
    >> > to application resources by user or role. Wildcards: "*" mean
    >> > everyone, "?" means anonymous
    >> > (unauthenticated) users.
    >> > -->
    >> > <authorization>
    >> > <deny users="?" />
    >> > <!-- <allow users="*" /> --> <!-- Allow all users -->
    >> > <!-- <allow users="[comma separated list of users]"
    >> > roles="[comma separated list of roles]"/>
    >> > <deny users="[comma separated list of users]"
    >> > roles="[comma separated list of roles]"/>
    >> > -->
    >> > </authorization>
    >> >
    >> >
    >> > Thanks, Leonard
    >> >
    >>
    >>
    >>

    Hernan de Lahitte 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