Advertisement
Guest User

Untitled

a guest
Apr 1st, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. public void getAuthenticated()
  2. {
  3. try
  4. {
  5. string URL = "http://XXX.XXX.XXX.XXX:0000/LDAPAuthentication/doAuthentication";
  6. string user = txtUser.Text.ToLower().ToString();
  7. string password = txtPassword.Text.ToString();
  8. string DATA = "?username=" + user + "&password=" + password;
  9. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL+DATA);
  10. request.Method = "POST";
  11. request.ContentType = "application/json";
  12. request.ContentLength = DATA.Length;
  13. StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
  14. requestWriter.Write(DATA);
  15. requestWriter.Close();
  16.  
  17. WebResponse webResponse = request.GetResponse();
  18. Stream webStream = webResponse.GetResponseStream();
  19. //webStream.Close();
  20. //webStream.Dispose();
  21. StreamReader responseReader = new StreamReader(webStream);
  22. string response = responseReader.ReadToEnd();
  23. responseReader.Close();
  24. // responseReader.Dispose();
  25. string r = response.Substring(12, 7);
  26. if (r == "failure")
  27. {
  28. lblLoginFailed.ForeColor = System.Drawing.Color.Red;
  29. lblLoginFailed.Visible = true;
  30. lblLoginFailed.Text = "User is not Authenticated by AD. Kindly add this user";
  31. }
  32. else
  33. {
  34. loginNow();
  35. }
  36. //lblLoginFailed.Visible = true;
  37. //lblLoginFailed.Text = response.ToString();
  38.  
  39.  
  40. }
  41. catch (Exception ex)
  42. {
  43. lblLoginFailed.Visible =true;
  44. lblLoginFailed.Text = ex.Message;
  45. throw ex;
  46. }
  47. }
  48.  
  49. private void loginNow()
  50. {
  51. try
  52. {
  53. //Session.Clear();
  54. Session.Add("currentDataConnectionPooled", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
  55. Session.Add("currentDataConnectionNormal", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
  56. Session.Add("currentAccConnectionPooled", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
  57. Session.Add("currentAccConnectionNormal", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
  58. Session.Add("currentDEBTConnectionPooled", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);////Added new connection for DEBT market. 02/05/2013/Amar
  59. Session.Add("currentDEBTConnectionNormal", ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
  60.  
  61. BSECAS.BusinessLogic.LoginManager LGM = new BSECAS.BusinessLogic.LoginManager();
  62. BSECAS.BOs.BSECASAppLoginList LoginInfo = LGM.DoAppLogin(txtUser.Text, txtPassword.Text);
  63. LoginInfo[0].USERCODE = txtUser.Text.ToUpper();
  64. LoginInfo[0].REMOTEIP = Request.ServerVariables["REMOTE_ADDR"];
  65. Session.Add("GLOBALCSS", ResolveUrl(LoginInfo[0].CSSPATH));
  66. BSECAS.BOs.BSECASUserPemissionList RightsInfoList = LGM.AppGetUserPermission(LoginInfo[0].CATEGORYCODE, txtUser.Text.ToUpper(), "");
  67. BSECAS.BOs.BSECASAppThemeList AppThemeList = LGM.ApplicationThemes();
  68.  
  69. LoginInfo[0].STATUSNAME = LoginInfo[0].USERCODE;
  70.  
  71. Session["LoginName"] = LoginInfo[0].USERCODE;
  72. Session.Add("loginINFO", LoginInfo);
  73. Session.Add("ApplicationThemes", AppThemeList);
  74. Session.Add("userRIGHTS", RightsInfoList);
  75. Session.Add("FullRights", true);
  76. Session.Add("NoRights", false);
  77. Session.Add("AddRights", false);
  78. Session.Add("ModRights", false);
  79. Session.Add("DelRights", false);
  80. Session.Add("ViewRights", false);
  81. Session.Add("AuditRights", false);
  82. Session.Add("BaseKey", sBaseKey.Value);
  83. Session.Add("SuppKey", sSuppKey.Value);
  84.  
  85.  
  86. if (LoginInfo[0].PWDEXPIRY < 0 || LoginInfo[0].FIRSTLOGIN.ToUpper() == "Y")
  87. {
  88. Response.Redirect("ChangePassword.aspx", true);
  89. }
  90.  
  91. loginSuccess.Value = "1";
  92.  
  93. }
  94. catch (Exception ex)
  95. {
  96. loginSuccess.Value = "2";
  97. loginMSG.Value = ex.Message;
  98. }
  99. finally
  100. {
  101. }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement