Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > SECURITY (TECHNET) > Problem with setauthcookie
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 29th July 23:52
dave colliver
External User
 
Posts: 1
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.
http://www.SheffieldFOCUS.com
~~
http://www.FOCUSPortals.com - portal franchises available
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666