public override bool ValidateUser(string username, string password) { try { using (documentmanagerEntities entities = new documentmanagerEntities()) { var result = from r in entities.user where (r.user_name == username && r.user_password == password) select r; LocalServerService lLocalService = new LocalServerService(); if (lLocalService.GetExpireDay() < 0) { return(true); } if (result.Count() > 0) { return(true); } else { return(false); } } } catch (System.Exception ex) { return(false); } }
// To enable Forms/Windows Authentication for the Web Application, edit the appropriate section of web.config file. protected override User GetAuthenticatedUser(IPrincipal principal) { using (documentmanagerEntities documentmanagerEntities = new documentmanagerEntities()) { User user = new User(); LocalServerService lLocalService = new LocalServerService(); user.ExpireDay = lLocalService.GetExpireDay(); try { var result = from r in documentmanagerEntities.user where r.user_name == principal.Identity.Name select r; if (result.Count() > 0) { DocumentManager.Web.Model.user lUser = result.First(); user.UserID = lUser.user_id; user.Name = lUser.user_name; user.Password = lUser.user_password; user.UserName = lUser.user_cname; user.RightDictionary = new Dictionary <int, bool>(); if (user.UserID != 1) { var resultaction = from r in documentmanagerEntities.useraction where r.user_id == lUser.user_id select r; if (resultaction.Count() > 0) { foreach (DocumentManager.Web.Model.useraction useraction in resultaction) { user.RightDictionary.Add(useraction.action_id.Value, useraction.hasRight.Value); } } } else { var resultaction = from r in documentmanagerEntities.action select r; if (resultaction.Count() > 0) { foreach (DocumentManager.Web.Model.action action in resultaction) { user.RightDictionary.Add(action.action_id, true); } } } } } catch (System.Exception ex) { } return(user); } }
public override bool ValidateUser(string username, string password) { try { using (documentmanagerEntities entities = new documentmanagerEntities()) { var result = from r in entities.user where (r.user_name == username && r.user_password == password) select r; LocalServerService lLocalService = new LocalServerService(); if (lLocalService.GetExpireDay() < 0) { return true; } if (result.Count() > 0) { return true; } else { return false; } } } catch (System.Exception ex) { return false; } }