problem with SetAuthCookie

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

  1. #1

    Default problem with SetAuthCookie

    I have a web application that authenticate users and give them access to all
    other web applications of the company.

    They first get access to default.aspx wich ask them for a user name and a
    password. It then authenticate them via a SQL Server, create a authentication
    cookie and then create a list of applications they have access.

    This list is made of simple <a> tags and open new browsers so that visitors
    don't need to relogin all the time.

    All <a> tags leed to another page named LoadApp.aspx witch create a token
    and then redirect the response to the application the user asked for with the
    token in parameters.

    Child applications then read the token, check if it is ok and delete it if
    it is correct and create a authentication cookie for the child application.

    When I access my general application by localhost, all the process is
    working but if I access it from [url]http://machinename/application[/url] I can only get
    one application.
    I can authenticate on the primary application, I get the list and I can
    access the first application that I select from the list. But when I try to
    click on a second one, the page that shows the new browser is default.aspx of
    the primary application with a ReturnURL argument as if I was not
    authenticated.

    Is that clear ? Anyone have a hint about it ?

    Thanks !

    Pascal.Landry Guest

  2. Similar Questions and Discussions

    1. contribute problem - access denied file may not existpermission problem
      Recieving the following error message - "access denied file may not exist , or there could be a permission problem" this happened this morning ,...
    2. SetAuthCookie problem
      I have a login page which with the following code: FormsAuthentication.SetAuthCookie(UserID, False) '''''For testing''' ...
    3. Problem playing Quicktime thru .DCR embedded in HTML - pathreferencing problem?
      Greetings earthlings and Director heads. Here's the problem: created an HTML file containing shockwave (dcr) movie that calls quicktime movies in...
    4. Uploading problem = weird warning (was: access denied problem.....)
      Hi, I had a problem where my upload form was not working on our production server but was working on two other servers, after checking the...
    5. Problem with Apache Web Server config file and PHP (please give advice on what problem may be me)
      HI: Can anyone refer me to someone that can help with the problem below. I installed Apache Web Server on my laptop which has Windows XP. I...
  3. #2

    Default problem with SetAuthCookie

    Is there a problem with SethAuthCookie if I open more than one new window
    from my application ?

    After being authenticated, I clic a web link that open new browser with
    another application in it. If I clic on another link it seems that the
    authentication is not made because the second new browser shows me the login
    page again...

    I really need help with this !
    Pascal.Landry Guest

  4. #3

    Default Problem with setauthcookie

    Hi all,

    I am having a problem with setting the auth cookie.

    I have a username/password box on a page. In my button
    event, I am checking a database with the
    username/password pair and if I get a row returned, then
    I do...

    FormsAuthentication.SetAuthCookie(UserNameBox.Text , true);

    then do a little bit on my page, such as switching off
    panels and switching others on.

    Now, on one of the panels that I switch on, I have
    linkbuttons which post the page back. I am checking...

    if (User.Identity.IsAuthenticated) to do other
    operations. This is in my page_load, but IsAuthenticated
    is returning false.

    I know of no reason. Can anybody help?

    My code...

    private void Page_Load(object sender,
    System.EventArgs e)
    {
    // Put user code to initialize
    the page here
    //CheckLogin();
    if (User.Identity.IsAuthenticated)
    {
    TabListPanel.Visible =
    true;
    Trace.Warn("Auth",
    DateTime.Now.ToString());
    }
    else
    {
    LoginPanel.Visible = true;
    }
    }

    private void LoginButton_Click(object
    sender, System.EventArgs e)
    {
    CheckLogin();
    }

    private void CheckLogin()
    {
    try
    {
    sqlConn.Open();

    SqlDataAdapter cmd;

    if
    (User.Identity.IsAuthenticated)
    {
    cmd = new
    SqlDataAdapter(MyNoneAuthSqlStatement, sqlConn);
    }
    else
    {
    cmd = new
    SqlDataAdapter(MyAuthSqlStatement, sqlConn);
    }

    DataSet Login = new
    DataSet();
    cmd.Fill
    (Login, "UserDetails");

    if (Login.Tables
    ["UserDetails"].Rows.Count > 0)
    {
    // Write the
    authentication cookie.

    FormsAuthentication.SetAuthCookie
    (LoginEmailTextBox.Text, true);
    // Remove login
    panel, show links (TAB) panel.

    LoginPanel.Visible = false;

    TabListPanel.Visible = true;
    }
    }
    finally
    {
    sqlConn.Close();
    }
    }


    This is in my web.config... I have to be careful in here
    as this may have issues elsewhere on the site.

    <authentication mode="Forms">
    <forms loginUrl="MyLogonPage.aspx"
    name="adAuthCookie" timeout="60" path="/NQT">
    </forms>
    </authentication>


    Thanks for any assistance.

    Best regards,
    Dave Colliver.
    [url]http://www.SheffieldFOCUS.com[/url]
    ~~
    [url]http://www.FOCUSPortals.com[/url] - portal franchises available

    David Colliver Guest

  5. #4

    Default Re: Problem with setauthcookie

    > if (User.Identity.IsAuthenticated) to do other operations. This is in
    > my page_load, but IsAuthenticated is returning false.
    That's because for this request the user wasn't authenticated when they came
    in.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]




    Brock Allen Guest

  6. #5

    Default Re: Problem with setauthcookie

    Hi Brock,

    Thanks for answering this Q and the one regarding my
    usercontrols on the other group.

    Granted, the form at initial request won't be
    authenticated. This is where I put in a login form. Once
    the form has been submitted, then I create an authcookie
    in the button submit event.

    When I return to the page, I would expect the cookie to
    be read which I am assuming would make
    User.Identity.IsAuthenticated = true.

    Am I missing something?

    Thanks.
    Dave Colliver.
    [url]http://www.ChesterFOCUS.com[/url]

    >-----Original Message-----
    >> if (User.Identity.IsAuthenticated) to do other
    operations. This is in
    >> my page_load, but IsAuthenticated is returning false.
    >
    >That's because for this request the user wasn't
    authenticated when they came
    >in.
    >
    >-Brock
    >DevelopMentor
    >[url]http://staff.develop.com/ballen[/url]
    >
    >
    >
    >
    >.
    >
    Guest

  7. #6

    Default Re: Problem with setauthcookie

    Hello John,

    i have a sample app on my blog which shows you how to correctly do this:
    [url]http://www.leastprivilege.com/PermaLink.aspx?guid=b0e51388-71d1-4a6f-98d0-bc8cfbec4c3a[/url]

    HTH

    ---------------------------------------
    Dominick Baier - DevelopMentor
    [url]http://www.leastprivilege.com[/url]
    > Hi Brock,
    >
    > Thanks for answering this Q and the one regarding my usercontrols on
    > the other group.
    >
    > Granted, the form at initial request won't be authenticated. This is
    > where I put in a login form. Once the form has been submitted, then I
    > create an authcookie in the button submit event.
    >
    > When I return to the page, I would expect the cookie to be read which
    > I am assuming would make User.Identity.IsAuthenticated = true.
    >
    > Am I missing something?
    >
    > Thanks.
    > Dave Colliver.
    > [url]http://www.ChesterFOCUS.com[/url]
    >> -----Original Message-----
    >>
    >>> if (User.Identity.IsAuthenticated) to do other
    >>>
    > operations. This is in
    >
    >>> my page_load, but IsAuthenticated is returning false.
    >>>
    >> That's because for this request the user wasn't
    >>
    > authenticated when they came
    >
    >> in.
    >>
    >> -Brock
    >> DevelopMentor
    >> [url]http://staff.develop.com/ballen[/url]
    >> .
    >>


    Dominick Baier [DevelopMentor] 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