public string ValidateLogin(string username, string password) { try { //http://172.22.226.148:31564/MicrosoftDynamicsAXAif60/AxTest/xppservice.svc //http://dc01:3340/MicrosoftDynamicsAXAif60/AxMobServices/xppservice.svc //BasicHttpBinding binding = new BasicHttpBinding(); //EndpointAddress epAddr = new EndpointAddress("http://172.22.226.148:31564/MicrosoftDynamicsAXAif60/AxTest/xppservice.svc"); //ESSWebService.SDSPersonalInfoServices servref = ChannelFactory<ESSWebService.SDSPersonalInfoServices>.CreateChannel(binding, epAddr); //ESSWebService.SDSPersonalInfoServicesClient sd = new ESSWebService.SDSPersonalInfoServicesClient(binding, epAddr); ESSWebService.SDSLoginServicesClient sd = new ESSWebService.SDSLoginServicesClient(); sd.ClientCredentials.Windows.ClientCredential.Domain = "Soletechs"; sd.ClientCredentials.Windows.ClientCredential = new NetworkCredential("webapp", "pass" + '"' + "word123"); //sd.ClientCredentials.Windows.ClientCredential.UserName = "******"; //sd.ClientCredentials.Windows.ClientCredential.Password = "******" + '"' + "word123"; ESSWebService.CallContext callcont = new ESSWebService.CallContext(); ESSWebService.Permission _permissionlInfo = sd.ValidateUserEncrypted(callcont, username, password); callcont.LogonAsUser = ""; var userCookie = new HttpCookie("user", _permissionlInfo.WorkerRecId.ToString()); var compCookie = new HttpCookie("compid", _permissionlInfo.CompanyId); var useridCookie = new HttpCookie("userlogid", username); var language = new HttpCookie("Language", "En"); //add Language Cookie //language cookie by default English //language = new HttpCookie("Language", "En"); userCookie.Expires.AddDays(365); compCookie.Expires.AddDays(365); useridCookie.Expires.AddDays(365); language.Expires.AddDays(365); HttpContext.Response.Cookies.Add(userCookie); HttpContext.Response.Cookies.Add(compCookie); HttpContext.Response.Cookies.Add(useridCookie); //if (Request.Cookies["Language"] == null) //{ HttpContext.Response.Cookies.Add(language); //} // ESSWebService.SDSPersonPhotoData photo = sd.getPersonPhoto(callcont, Convert.ToInt64("52565425785")); return(""); } catch (Exception ex) { //throw new Exception("Username or password is Incorrect"); return(ex.Message); } }
public string UpdatePassword(string currpassword, string newpassword) { if (Request.Cookies["user"] != null && Request.Cookies["compid"] != null) { var username = Convert.ToInt64(Request.Cookies["user"].Value); var compid = Request.Cookies["compid"].Value; var userlogid = Request.Cookies["userlogid"].Value; ESSWebService.SDSLoginServicesClient sd = new ESSWebService.SDSLoginServicesClient(); sd.ClientCredentials.Windows.ClientCredential.Domain = "Soletechs"; sd.ClientCredentials.Windows.ClientCredential = new NetworkCredential("webapp", "pass" + '"' + "word123"); ESSWebService.CallContext callcont = new ESSWebService.CallContext(); ESSWebService.Permission _permissionlInfo = sd.ValidateUserEncrypted(callcont, userlogid, currpassword); if (_permissionlInfo != null) { sd.changePassword(callcont, username, currpassword, newpassword, newpassword); HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); // make it expire yesterday Response.Cookies.Add(aCookie); // overwrite it } return("Password has changed"); } else { return("Current Password is Incorrect"); } } else { return(""); } }