private bool IsValid(string usernam, string password) { var crypto = new SimpleCrypto.PBKDF2(); bool IsValid = false; using (var db = new paresetEntities()) { var user = db.Userinfoes.FirstOrDefault(u => u.username == usernam); if (user != null) { if (user.password == crypto.Compute(password, user.passwordsalt)) { return(true); } } int count = int.Parse(user.failurecount.ToString()); user.failurecount = count + 1; db.Entry(user).CurrentValues.SetValues(user); db.SaveChanges(); } return(IsValid); }
public ActionResult pwdpolicy(Pwdpolicycon pwd) { try { paresetEntities db = new paresetEntities(); var obj = db.Pwdpolicies.ToList(); obj[0].Isenabel = pwd.pwdminlen; obj[1].Isenabel = pwd.capfirst; obj[2].Isenabel = pwd.spclchar; obj[3].Isenabel = pwd.lastpwd; //obj.Emailotp = confauthoptionsobj.emailotp; //obj.Charesq = confauthoptionsobj.challengequestions; //obj.Smsotp = confauthoptionsobj.smsotp; foreach (var m in obj) { db.Entry(m).CurrentValues.SetValues(m); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = "Success"; return(View(pwd)); } catch (Exception ex) { ViewBag.Message = "Error"; return(View()); } }
public ActionResult configauthoptions(checkboxforauthoptions confauthoptionsobj) { try { paresetEntities db = new paresetEntities(); var obj = db.Userauthoptions.ToList(); obj[0].Isenabel = confauthoptionsobj.Email; obj[1].Isenabel = confauthoptionsobj.smsotp; obj[2].Isenabel = confauthoptionsobj.challengeqs; //obj.Emailotp = confauthoptionsobj.emailotp; //obj.Charesq = confauthoptionsobj.challengequestions; //obj.Smsotp = confauthoptionsobj.smsotp; foreach (var m in obj) { db.Entry(m).CurrentValues.SetValues(m); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = "Success"; return(View(confauthoptionsobj)); } catch { ViewBag.Message = "Error"; return(View()); } }
public ActionResult Myprofile(UserReg user) { paresetEntities db = new paresetEntities(); var obj = db.Userinfoes.Where(c => c.username == user.Username).First(); try { obj.username = user.Username; obj.email = user.email; //obj.adminq = user.Adinq; obj.ansforaq = user.Ansforaq; obj.userq = user.Userq; obj.ansforuq = user.Ansforuq; obj.phone = user.phone; //user.password = obj.password; // user.Userq = (int)obj.userq; db.Entry(obj).CurrentValues.SetValues(obj); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Success"; } catch (Exception cex) { ViewBag.Message = "Error"; } return(View(GetusqlistA())); }
public ActionResult adminview(Admindetails Admind, String Command) { if (Command == "Update") { if (Admind.serveradminname != null && Admind.serveradminpass != null && Admind.DomainName != null && Admind.DomainIP != null) { IPAddress ip; bool ValidateIP = IPAddress.TryParse(Admind.DomainIP, out ip); if (ValidateIP) { paresetEntities db = new paresetEntities(); var obj = db.Admininfoes.Where(c => c.adminname == User.Identity.Name).First(); obj.serveradminname = Admind.serveradminname; obj.serveradminpass = Admind.serveradminpass; // obj.adminsq = Admind.AdminSq; obj.dmainname = Admind.DomainName; obj.domainip = Admind.DomainIP; db.Entry(obj).CurrentValues.SetValues(obj); db.SaveChanges(); //ModelState.Clear(); ViewBag.Message = "Success1"; } } } else { try { DirectoryEntry entry = new DirectoryEntry("LDAP://" + Admind.DomainIP, Admind.serveradminname, Admind.serveradminpass); object nativeObject = entry.NativeObject; ViewBag.Message = "Success2"; } catch (DirectoryServicesCOMException cex) { //not authenticated; reason why is in cex ViewBag.Message = "Error"; } catch (Exception ex) { //not authenticated due to some other exception [this is optional] ViewBag.Message = "Error"; } } //Admindetails objcountrymodel1 = new Admindetails(); //objcountrymodel1.Adminsqlist = GetAsqlist(); //return View(objcountrymodel1); return(View()); }
public ActionResult EnableUser(Enableusr enable) { try { paresetEntities db = new paresetEntities(); var obj = db.Userinfoes.Where(c => c.username == enable.username).First(); obj.failurecount = 0; obj.AdminApproved = true; db.Entry(obj).CurrentValues.SetValues(obj); db.SaveChanges(); ViewBag.Message = "Success1"; } catch (Exception cex) { ViewBag.Message = "Error"; } return(View()); }
public ActionResult SelectAdmiqforuser(Admindetails admind) { paresetEntities db = new paresetEntities(); var obj = db.Admininfoes.Where(c => c.adminname == User.Identity.Name).First(); obj.adminsq = admind.AdminSq; db.Entry(obj).CurrentValues.SetValues(obj); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Success"; Admindetails objcountrymodel1 = new Admindetails(); objcountrymodel1.Adminsqlist = GetAsqlist(); var Aq1 = db.Chresqlists.FirstOrDefault(u => u.id == admind.AdminSq); objcountrymodel1.AdminSqaslbl = Aq1.Adminsqlist.ToString(); return(View(objcountrymodel1)); }
public ActionResult changeuserpass(Passwordchange A) { // var crypto = new SimpleCrypto.PBKDF2(); using (var db = new paresetEntities()) { if (A.ChangePassword == A.ConfirmPassword) { var user = db.Userinfoes.FirstOrDefault(u => u.username == A.Username); if (user != null) { var crypto = new SimpleCrypto.PBKDF2(); var encrypPass = crypto.Compute(A.ChangePassword); user.password = encrypPass; user.passwordsalt = crypto.Salt; db.Entry(user).CurrentValues.SetValues(A); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Success"; } else { ViewBag.Message = "Error1"; } } else { ViewBag.Message = "Error2"; } } return(View()); }