Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void getAuthenticated()
- {
- try
- {
- string URL = "http://XXX.XXX.XXX.XXX:0000/LDAPAuthentication/doAuthentication";
- string user = txtUser.Text.ToLower().ToString();
- string password = txtPassword.Text.ToString();
- string DATA = "?username=" + user + "&password=" + password;
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL+DATA);
- request.Method = "POST";
- request.ContentType = "application/json";
- request.ContentLength = DATA.Length;
- StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
- requestWriter.Write(DATA);
- requestWriter.Close();
- WebResponse webResponse = request.GetResponse();
- Stream webStream = webResponse.GetResponseStream();
- //webStream.Close();
- //webStream.Dispose();
- StreamReader responseReader = new StreamReader(webStream);
- string response = responseReader.ReadToEnd();
- responseReader.Close();
- // responseReader.Dispose();
- string r = response.Substring(12, 7);
- if (r == "failure")
- {
- lblLoginFailed.ForeColor = System.Drawing.Color.Red;
- lblLoginFailed.Visible = true;
- lblLoginFailed.Text = "User is not Authenticated by AD. Kindly add this user";
- }
- else
- {
- loginNow();
- }
- //lblLoginFailed.Visible = true;
- //lblLoginFailed.Text = response.ToString();
- }
- catch (Exception ex)
- {
- lblLoginFailed.Visible =true;
- lblLoginFailed.Text = ex.Message;
- throw ex;
- }
- }
- private void loginNow()
- {
- try
- {
- //Session.Clear();
- Session.Add("currentDataConnectionPooled", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
- Session.Add("currentDataConnectionNormal", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
- Session.Add("currentAccConnectionPooled", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
- Session.Add("currentAccConnectionNormal", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
- Session.Add("currentDEBTConnectionPooled", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);////Added new connection for DEBT market. 02/05/2013/Amar
- Session.Add("currentDEBTConnectionNormal", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
- BSECAS.BusinessLogic.LoginManager LGM = new BSECAS.BusinessLogic.LoginManager();
- BSECAS.BOs.BSECASAppLoginList LoginInfo = LGM.DoAppLogin(txtUser.Text, txtPassword.Text);
- LoginInfo[0].USERCODE = txtUser.Text.ToUpper();
- LoginInfo[0].REMOTEIP = Request.ServerVariables["REMOTE_ADDR"];
- Session.Add("GLOBALCSS", ResolveUrl(LoginInfo[0].CSSPATH));
- BSECAS.BOs.BSECASUserPemissionList RightsInfoList = LGM.AppGetUserPermission(LoginInfo[0].CATEGORYCODE, txtUser.Text.ToUpper(), "");
- BSECAS.BOs.BSECASAppThemeList AppThemeList = LGM.ApplicationThemes();
- LoginInfo[0].STATUSNAME = LoginInfo[0].USERCODE;
- Session["LoginName"] = LoginInfo[0].USERCODE;
- Session.Add("loginINFO", LoginInfo);
- Session.Add("ApplicationThemes", AppThemeList);
- Session.Add("userRIGHTS", RightsInfoList);
- Session.Add("FullRights", true);
- Session.Add("NoRights", false);
- Session.Add("AddRights", false);
- Session.Add("ModRights", false);
- Session.Add("DelRights", false);
- Session.Add("ViewRights", false);
- Session.Add("AuditRights", false);
- Session.Add("BaseKey", sBaseKey.Value);
- Session.Add("SuppKey", sSuppKey.Value);
- if (LoginInfo[0].PWDEXPIRY < 0 || LoginInfo[0].FIRSTLOGIN.ToUpper() == "Y")
- {
- Response.Redirect("ChangePassword.aspx", true);
- }
- loginSuccess.Value = "1";
- }
- catch (Exception ex)
- {
- loginSuccess.Value = "2";
- loginMSG.Value = ex.Message;
- }
- finally
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement