Group: StrataFrame Users
Posts: 223,
Visits: 893
|
First of all I read the help and it instructed me to add the following line to Global.asax file:
SecurityBasics.IsWebEnvironment = true;
Then using the code copied from the help files (see below) I try to authicate the user. However, the login fails. I know this code and username and password works, because I used the exact same code from a Windows form. When looking at the user name returned by SecurityBasics.CurrentUser after the authentication fails, it is 'Administrator' even though I am trying to authenticate another user. What is wrong or what do I have to do to get this same code to work from a Web form?
//-- Establish locals
StringBuilder sb = new StringBuilder();
String userName = "";
MicroFour.StrataFrame.Security.Login.LoginResult loResult;
//-- Attempt to authenticate the user
loResult = MicroFour.StrataFrame.Security.Login.SetLoggedInUser(this.txtUsername.Text, this.txtPassword.Text, "");
//-- If the result if Success, AdminLoggedOn, or SecMaintUserLoggedOn, the
// SecurityBasics.CurrentUser object will be changed to the correct user
//-- Do something based upon the result
switch (loResult)
{
case MicroFour.StrataFrame.Security.Login.LoginResult.Success:
sb.AppendLine("Login successful.");
userName = MicroFour.StrataFrame.Security.SecurityBasics.CurrentUser.UserName;
sb.AppendLine(userName);
this.lblMessage.Text = sb.ToString();
return true;
case MicroFour.StrataFrame.Security.Login.LoginResult.Failure:
this.lblMessage.Text = "Login failed.";
return false;
case MicroFour.StrataFrame.Security.Login.LoginResult.UserDeactivated:
this.lblMessage.Text = "User Deactivated.";
return true;
default:
this.lblMessage.Text = "Unexpected Error: No login result returned.";
return false;
}
}
|