Exemplo n.º 1
0
        public AccountMembershipService(string Login)
        {
            if (!String.IsNullOrEmpty(Login))
            {
                _CurrUsrLogin = Login;
                System.Web.HttpContext.Current.Session["Login"] = Login;
            }

            if (_currUser == null)
            {
                _CurrUsrLogin = (System.Web.HttpContext.Current.Session["Login"] != null
                                ? System.Web.HttpContext.Current.Session["Login"].ToString()
                                : _CurrUsrLogin);

                _currUser = _db.GetUserByLogin(_CurrUsrLogin);
            }
        }
Exemplo n.º 2
0
 public void SaveUser(Users obj)
 {
     Users old = GetUser(obj.ID);
     old.RoleID = obj.RoleID;
     old.SortType = obj.SortType;
     _DB.SaveChanges();
 }
Exemplo n.º 3
0
        public Users GetCurrUser(string username, string filterAttribute)
        {
            Users usr = null;
            if (username == "sysadmin")
            {
                if (filterAttribute == Configuration.SysPassword)
                {
                    usr = new Users();
                    usr.ID = Guid.NewGuid();
                    usr.Login = username;
                    usr.FIO = username;
                    usr.AccessRights = 31;//все права
                }

                //_DB.Users.AddObject(usr);
                //_DB.SaveChanges();
                return usr;
            }

            IList<Users> userlst = _DB.Users.Where(p => p.Login.Equals(username, StringComparison.CurrentCultureIgnoreCase)).ToList();

            if (userlst.Count == 0 || userlst[0].FIO != filterAttribute)
            {
                usr = new Users();
                usr.ID = Guid.NewGuid();
                usr.Login = username;
                usr.FIO = filterAttribute;
                _DB.Users.AddObject(usr);
                _DB.SaveChanges();
            }
            else
                usr = userlst[0];
            return usr;
        }
Exemplo n.º 4
0
        public bool ValidateUser(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
            if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");

            _currUser = IsAuthenticated("LDAP://maytea.com", "maytea", userName, password);
            // if (_currUser == null)  _currUser = new Users(); _currUser.Login = "******";
            return (_currUser != null);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(Users users)
 {
     base.AddObject("Users", users);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Create a new Users object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Users CreateUsers(global::System.Guid id)
 {
     Users users = new Users();
     users.ID = id;
     return users;
 }
Exemplo n.º 7
0
 public ActionResult EditUser(Users obj, String Roles)
 {
     obj.RoleID = _db.GetRoleID(Roles);
     _db.SaveUser(obj);
     return RedirectToAction("UsersList", "Admin");
 }