Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: IIS6 ASP.NET
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 :
                Session["UserName"] = GWALogin.UserName;
                Session["Password"] = GWALogin.Password;
                TryLogin(GWALogin.UserName, GWALogin.Password);

            catch (Exception _objEx)
                GWALogin.FailureText = _objEx.Message;
                //lblError.Text = _objEx.Message;
                //lblError.Visible = true;
                errMessage.InnerText = _objEx.Message;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ToggleScript", "window.setTimeout('open_errormessage_box()',500);", true);

protected void TryLogin(string userid, string password)
                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);
                //userRoleList = Roles.GetRolesForUser();
                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;
                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;
                    string strRedirect;
                    strRedirect = "Home.aspx"; //Request["ReturnUrl"];

                    Response.Redirect(strRedirect, false);
                    errMessage.InnerText = "Invalid UserName or Password!";
                    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..
Posted 1-Mar-12 14:23pm
Edited 2-Mar-12 13:58pm
digimanus at 2-Mar-12 8:29am
what's the code for TryLogin(GWALogin.UserName, GWALogin.Password);?
virang_21 at 2-Mar-12 18:58pm
I have updated the question.
ryanb31 at 7-Mar-12 11:31am
The error says it cannot connect to SQL server. That should be pretty easy to track down.
virang_21 at 7-Mar-12 14:58pm
Hi Ryan, The big question mark is I don't have any database related connection on that page... Apart from that it works perfectly fine in development environment... I am validating users against AD nothing to do with database....

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

missed to add this bit to web.config file. Finally solved the issue.
 <membership defaultprovider="MyADMembershipProvider">
        <clear />
        <add name="MyADMembershipProvider">
        type="System.Web.Security.ActiveDirectoryMembershipProvider,System.Web, Version=, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Peter Leow 308
1 Kornfeld Eliyahu Peter 220
2 Sergey Alexandrovich Kryukov 162
3 Maciej Los 160
4 OriginalGriff 153
0 OriginalGriff 383
1 Peter Leow 318
2 Kornfeld Eliyahu Peter 260
3 Maciej Los 230
4 Sergey Alexandrovich Kryukov 212

Advertise | Privacy | Mobile
Web01 | 2.8.150301.1 | Last Updated 7 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100