J
James Coleman
I have a asp:Login control with an OnLoggedIn="Login1_LoggedIn" method.
The first time through the method the Context.User.IsAuthenticated = false.
The 2nd time I log in, it is then true. Anyone know why this is, am I doing
something wrong, is there a way around it?
protected void Login1_LoggedIn(object sender, EventArgs e)
{
Login myLogin = sender as Login;
// if we get a Ticket from AuthenticateAsUser the credentials are
valid
//Ticket =
CmsFormsAuthentication.AuthenticateAsUser(Login1.UserName, Login1.Password);
if (Context.User.IsInRole("Admin"))
{
//Ticket =
CmsFormsAuthentication.AuthenticateAsUser("WinNT://webacom/jcoleman",
"`1q`1q");
Ticket = CmsFormsAuthentication.AuthenticateAsUser("WinNT://" +
WebConfigurationManager.AppSettings["ADMIN_USERNAME"],
WebConfigurationManager.AppSettings["ADMIN_PASSWORD"]);
}
else if (Context.User.IsInRole("Dealer"))
{
Ticket = CmsFormsAuthentication.AuthenticateAsUser("WinNT://" +
WebConfigurationManager.AppSettings["DEALER_USERNAME"],
WebConfigurationManager.AppSettings["DEALER_PASSWORD"]);
}
else
{
CmsFormsAuthentication.AuthenticateAsGuest();
}
if (Ticket != null)
{
CmsFormsAuthentication.SetAuthCookie(Ticket, false,
Login1.RememberMeSet);
}
}
Thanks
~James
The first time through the method the Context.User.IsAuthenticated = false.
The 2nd time I log in, it is then true. Anyone know why this is, am I doing
something wrong, is there a way around it?
protected void Login1_LoggedIn(object sender, EventArgs e)
{
Login myLogin = sender as Login;
// if we get a Ticket from AuthenticateAsUser the credentials are
valid
//Ticket =
CmsFormsAuthentication.AuthenticateAsUser(Login1.UserName, Login1.Password);
if (Context.User.IsInRole("Admin"))
{
//Ticket =
CmsFormsAuthentication.AuthenticateAsUser("WinNT://webacom/jcoleman",
"`1q`1q");
Ticket = CmsFormsAuthentication.AuthenticateAsUser("WinNT://" +
WebConfigurationManager.AppSettings["ADMIN_USERNAME"],
WebConfigurationManager.AppSettings["ADMIN_PASSWORD"]);
}
else if (Context.User.IsInRole("Dealer"))
{
Ticket = CmsFormsAuthentication.AuthenticateAsUser("WinNT://" +
WebConfigurationManager.AppSettings["DEALER_USERNAME"],
WebConfigurationManager.AppSettings["DEALER_PASSWORD"]);
}
else
{
CmsFormsAuthentication.AuthenticateAsGuest();
}
if (Ticket != null)
{
CmsFormsAuthentication.SetAuthCookie(Ticket, false,
Login1.RememberMeSet);
}
}
Thanks
~James