G
Guest
I will be using a companyname, user name, and password to authenicate users
in my system. I am trying to save the company name in the session for later
use. I cannot access the Session["CompanyName"] object in the
Application_AuthenticateRequest function. I need the companyname to lookup
the users group to build the GenericPrincipal for the user. My code is below.
Login Page:
int c = SiteSecurity.DBAuthenticate(txtCompanyName.Text, txtUsername.Text,
txtPassword.Text);
if (c > 0) {
//save the company name into the session
Session.Add("CompanyName", txtCompanyName.Text);
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);
}
else {
//error handling
}
GLobal.asax
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if ( Context.Request.IsAuthenticated ) {
string strUserName;
String strRoles;
String userName = String.Empty;
strUserName = Context.User.Identity.Name;
strRoles = EMS.PepSecurity.GetClientUsersGroups(strUserName);
string[] arrRoles = strRoles.Split('|');
Context.User = new GenericPrincipal( Context.User.Identity, arrRoles );
}
}
In the EMS.PepSecurity.GetClientUsersGroups function I am getting the error
on the following lines
string companyName = string.Empty;
try { companyName = HttpContext.Current.Session["CompanyName"].ToString(); }
The object cannot be found.
How can I save the company name if the session will not work?
in my system. I am trying to save the company name in the session for later
use. I cannot access the Session["CompanyName"] object in the
Application_AuthenticateRequest function. I need the companyname to lookup
the users group to build the GenericPrincipal for the user. My code is below.
Login Page:
int c = SiteSecurity.DBAuthenticate(txtCompanyName.Text, txtUsername.Text,
txtPassword.Text);
if (c > 0) {
//save the company name into the session
Session.Add("CompanyName", txtCompanyName.Text);
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);
}
else {
//error handling
}
GLobal.asax
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if ( Context.Request.IsAuthenticated ) {
string strUserName;
String strRoles;
String userName = String.Empty;
strUserName = Context.User.Identity.Name;
strRoles = EMS.PepSecurity.GetClientUsersGroups(strUserName);
string[] arrRoles = strRoles.Split('|');
Context.User = new GenericPrincipal( Context.User.Identity, arrRoles );
}
}
In the EMS.PepSecurity.GetClientUsersGroups function I am getting the error
on the following lines
string companyName = string.Empty;
try { companyName = HttpContext.Current.Session["CompanyName"].ToString(); }
The object cannot be found.
How can I save the company name if the session will not work?