I have an application that authenticate users against AD. I have an issue with user login on IIS. This is rather odd problem as everything works perfectly fine on development environment. If user credentials are wrong it will show popup indicating it is wrong in dev environment but when I host the application on IIS if user credentials are wrong that popup did not appear.
Here is my log in logic :
try
{
Session["UserName"] = GWALogin.UserName;
Session["Password"] = GWALogin.Password;
TryLogin(GWALogin.UserName, GWALogin.Password);
}
catch (Exception _objEx)
{
GWALogin.FailureText = _objEx.Message;
GWALoginUpdatePanel.Update();
errMessage.InnerText = _objEx.Message;
updErrorMessage.Update();
ScriptManager.RegisterStartupScript(this, this.GetType(), "ToggleScript", "window.setTimeout('open_errormessage_box()',500);", true);
}
protected void TryLogin(string userid, string password)
{
try
{
Jardine.DTO.User objUser = new Jardine.DTO.User();
string[] ValidADGroups;
string allowedGorup;
string strUserName = userid;
string strPassword = password;
bool blValidUser = false;
string strDomainName =ConfigurationManager.AppSettings["Domain"].ToString();
string strAdPath = ConfigurationManager.AppSettings["ADPath"].ToString();
LdapAuthentication adAuth = new LdapAuthentication(strAdPath);
if (adAuth.IsAuthenticated(strDomainName, strUserName, strPassword))
{
ValidADGroups = adAuth.GetGroups(strDomainName , strUserName, strPassword);
allowedGorup = ConfigurationManager.AppSettings["ADGroup"].ToString();
for (int intCount = 0; intCount < ValidADGroups.Length; intCount++)
{
if (ValidADGroups[intCount].ToString() == allowedGorup)
{
blValidUser = true;
break;
}
}
}
if (blValidUser == true)
{
objUser.UserName = userid;
objUser.Password = password;
Session["User"] = objUser;
Session["Division"] = ConfigurationManager.AppSettings["Division"].ToString();
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, objUser.UserName, DateTime.Now,
DateTime.Now.AddMinutes(30), true, "Jardine");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
string strRedirect;
strRedirect = "Home.aspx";
Response.Redirect(strRedirect, false);
}
else
{
errMessage.InnerText = "Invalid UserName or Password!";
updErrorMessage.Update();
ScriptManager.RegisterStartupScript(this, this.GetType(), "ToggleScript", "window.setTimeout('open_errormessage_box()',500);", true);
}
}
catch (Exception Ex)
{
throw Ex;
}
}
Interesting enough after sometime on IE it shows something is wrong with the page script and shows yellow exclamation at bottom left corner. If I double click it it shows below message : Point to note : I am authenticating user against AD and this page has no connection to database whatsoever. So I am not sure why it is saying "Unable to connect to SQL Server database." ?
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Timestamp: Fri, 2 Mar 2012 00:18:29 UTC
Message: Sys.WebForms.PageRequestManagerServerErrorException: Unable to connect to SQL Server database.
Line: 4723
Char: 21
Code: 0
URI: http://revvg110:4455/ScriptResource.axd?d=tmzsU2Huftrx_UnzDAXJbcdfxQqfuhTMUgrqZnVrsIbQNjqD-OYfiiCHlWSAN-gWorCT2FdH5OI29Zltg1hXDQFhNc8JI2yvdrfiRLG4bMo1&t=ffffffff90822266
Any ideas ? I am really stumped here..