Пример #1
0
        public void AddUser(string name, string password, UserAuthType type)
        {
            try
            {
                name = name.ToLower(); //only lower case usernames are allowed

                User user = SecurityFramework.AddNewUser(name, password, type);
                if (_Users != null)
                {
                    if (string.IsNullOrEmpty(UsernameFilter))
                    {
                        UserInfo u = new UserInfo(user, SecurityFramework.Groups);
                        if (_Users.Count(ui => ui.User.Account == u.User.Account) > 0)
                        {
                            MessageBox.Show(String.Format("The given username '{0}' already exists.", u.User.Account),
                                            "Execution was aborted", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else
                        {
                            _Users.Add(new UserInfo(user, SecurityFramework.Groups));
                        }
                    }
                    else if (user.Account.Contains(UsernameFilter))
                    {
                        _Users.Add(new UserInfo(user, SecurityFramework.Groups));
                        (MainWindow as MainWindow).ListBoxUsers.GetBindingExpression(System.Windows.Controls.ListBox.ItemsSourceProperty).UpdateTarget();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
 public UserInfo(User user, List <Group> groups)
 {
     this.User = user;
     Groups    = new ObservableCollection <GroupMembershipInfo>();
     foreach (Group group in groups)
     {
         GroupMembershipInfo gmi = new GroupMembershipInfo(group, this.User);
         gmi.PropertyChanged += gmi_PropertyChanged;
         Groups.Add(gmi);
     }
 }
Пример #3
0
 private void RemoveUser(User user)
 {
     try
     {
         SecurityFramework.RemoveUser(user);
         if (_Users.ToList().Exists(ui => ui.User == user))
         {
             _Users.Remove(_Users.ToList().Find(ui => ui.User == user));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #4
0
        public UserAuth(User u)
        {
            InitializeComponent();
            this._User = u;

            if (_User.Type == UserAuthType.FormsAuthentication)
                AuthForm();
            else if (_User.Type == UserAuthType.ListAuthentication)
                AuthList();
            else if (_User.Type == UserAuthType.LocalDirectoryAuthentication)
                AuthActiveDirectory();

            DataContext = this;
            tbString.Focus();
        }
Пример #5
0
 public bool IsUserObjectPermissionInherited(object o, string permissionName, User user)
 {
     bool ival = GetUserObjectPermissionInherited(o, permissionName, user);
     bool val = GetUserObjectPermission(o, permissionName, user);
     //forciere Cleaning
     SetUserObjectTypePermission(o, permissionName, val, user);
     return ival == val;
 }
Пример #6
0
 public List<PermissionInfo> GetUserTypePermissions(string type, User user)
 {
     List<PermissionInfo> pis = new List<PermissionInfo>();
     TypeInfo ti = GetTypeInfoByTypeName(type);
     foreach (PermissionInfo pi in ti.Permissions)
     {
         bool access = GetUserTypePermission(type, pi.PermissionName, user);
         pis.Add(new PermissionInfo(pi.PermissionName, access));
     }
     return pis;
 }
Пример #7
0
 public GroupMembershipInfo(Group group, User user)
 {
     Group = group;
     User = user;
 }
Пример #8
0
        private bool GetUserTypePermission(string type, string permissionName, User user)
        {
            bool? access = null;

            access = _DataAdapter._GetPermissionOfUserTypePermissionList(type, permissionName, user.Id);
            if (access != null) return access.Value;

            return GetUserTypePermissionInherited(type, permissionName, user);
        }
Пример #9
0
 public void UpdateUser(User user)
 {
     _DataAdapter._UpdateUser(user);
 }
Пример #10
0
 public void SetUserObjectTypePermission(object o, string permissionName, bool access, User user)
 {
     string type = o.GetType().FullName;
     string locator = GetLocator(o);
     //Wenn schon durch einen MemberGruppe vererbt, dann braucht es den Eintrag nicht!
     if (GetUserObjectPermissionInherited(o, permissionName, user) == access)
     {
         _DataAdapter._RemoveUserObjectPermission(locator, type, permissionName, user.Id);
     }
     else
     {
         if (GetUserObjectPermission(o, permissionName, user) != access)
             //ansonsten hinzufügen
             _DataAdapter._AddUserObjectPermission(locator, type, permissionName, access, user.Id);
     }
 }
Пример #11
0
 public void ResetUserObjectPermission(object o, User user)
 {
     string locator = GetLocator(o);
     string type = o.GetType().FullName;
     _DataAdapter._ResetUserObjectPermission(locator, type, user.Id);
 }
Пример #12
0
 public GroupMembershipInfo(Group group, User user)
 {
     Group = group;
     User  = user;
 }
 /// <summary>
 /// Removes a user.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <remarks>Documented by Dev03, 2009-02-27</remarks>
 public void _RemoveUser(User user)
 {
     throw new NotSupportedException("Not supported for SQL CE!");
 }
Пример #14
0
 internal SecurityToken(User user, Framework fw)
 {
     _User = user;
     _Framework = fw;
 }
Пример #15
0
 public UserInfo(User user, List<Group> groups)
 {
     this.User = user;
     Groups = new ObservableCollection<GroupMembershipInfo>();
     foreach (Group group in groups)
     {
         GroupMembershipInfo gmi = new GroupMembershipInfo(group, this.User);
         gmi.PropertyChanged += gmi_PropertyChanged;
         Groups.Add(gmi);
     }
 }
Пример #16
0
        public bool IsUserTypePermissionInherited(string type, string permissionName, User user)
        {
            bool ival = GetUserTypePermissionInherited(type, permissionName, user);
            bool val = GetUserTypePermission(type, permissionName, user);

            //forciere Cleaning
            SetUserTypePermission(type, permissionName, val, user);

            return ival == val;
        }
Пример #17
0
 public void RemoveUser(User user)
 {
     _DataAdapter._RemoveUser(user);
 }
        public void _RemoveUser(User user)
        {
            Adapters.UserProfilesAdapter.RemoveUser(int.Parse(user.Id));
            Adapters.UserProfiles_UserGroupsAdapter.RemoveEntriesByUserId(int.Parse(user.Id));

            __Users.Remove(user);
        }
Пример #19
0
 public void ResetUserTypePermission(string type, User user)
 {
     _DataAdapter._ResetUserTypePermission(type, user.Id);
 }
        public void _UpdateUser(User user)
        {
            Adapters.UserProfilesAdapter.UpdateUser(int.Parse(user.Id), user.Account, user.Password, user.Type);
            Adapters.UserProfiles_UserGroupsAdapter.RemoveEntriesByUserId(int.Parse(user.Id));
            foreach (Group group in user.Groups)
            {
                Adapters.UserProfiles_UserGroupsAdapter.AddEntry(int.Parse(user.Id), int.Parse(group.Id));
            }

            Reset();
        }
Пример #21
0
        public void SetUserTypePermission(string type, string permissionName, bool access, User user)
        {
            //Wenn durch Mitgliedgruppen vererbt, dann Wert aus der Liste streichen
            if (GetUserTypePermissionInherited(type, permissionName, user) == access)
            {
                _DataAdapter._RemoveUserTypePermission(type, permissionName, user.Id);
            }

            else
            {
                if (GetUserTypePermission(type, permissionName, user) != access)
                    //ansonsten hinzufügen
                    _DataAdapter._AddUserTypePermission(type, permissionName, access, user.Id);
            }
        }
Пример #22
0
        public bool GetUserObjectPermission(object o, string permissionName, User user)
        {
            string type = o.GetType().FullName;
            object parent = GetParent(o);
            string locator = this.GetLocator(o);
            string parentLocator = null;
            if (locator != null && parent != null)
                parentLocator = this.GetLocator(parent);
            string parentType = null;
            if (parent != null)
                parentType = parent.GetType().FullName;

            //es existiertn ein direkter Eintrag in der Liste, also diesen Wert verwenden
            bool? access = _DataAdapter._GetPermissionOfUserObjectPermissionList(locator, type, permissionName, user.Id);
            if (access != null) return access.Value;

            return GetUserObjectPermissionInherited(o, permissionName, user);
        }
Пример #23
0
        private bool GetUserObjectPermissionInherited(object o, string permissionName, User user)
        {
            string type = o.GetType().FullName;
            object parent = GetParent(o);
            string locator = this.GetLocator(o);
            string parentLocator = null;
            if (locator != null && parent != null)
                parentLocator = this.GetLocator(parent);
            string parentType = null;
            if (parent != null)
                parentType = parent.GetType().FullName;

            bool? access = null;

            //Gibt es Einträge in den Gruppen, zu der der User gehört? Alle Werte der Gruppen werden OR - verknüpft,
            //d.h. ein Eintrag true, dann wird dieser zurückgegeben
            foreach (Group g in user.Groups)
            {
                bool? gp = _DataAdapter._GetPermissionOfGroupObjectPermissionList(locator, type, permissionName, g.Id);
                if (gp == null) continue;
                if (access == null)
                    access = gp;

                access = access | gp;
            }
            if (access != null) return access.Value;

            //Hat man über den ObjektParent einen entsprechende Berechtigung?
            if (parentLocator != null && parentType != null)
            {
                access = _DataAdapter._GetPermissionOfUserObjectPermissionList(parentLocator, parentType, permissionName, user.Id);
                if (access != null) return access.Value;
            }

            //Eventuell hat ein Gruppe über ObjektParent einen Eintrag?
            if (parentLocator != null && parentType != null)
            {
                foreach (Group g in user.Groups)
                {
                    bool? gp = _DataAdapter._GetPermissionOfGroupObjectPermissionList(parentLocator, parentType, permissionName, g.Id);
                    if (gp == null) continue;
                    if (access == null)
                        access = gp;

                    access = access | gp;
                }
                if (access != null) return access.Value;

            }

            //exisitiert ein Typeeintrag?
            access = _DataAdapter._GetPermissionOfUserTypePermissionList(type, permissionName, user.Id);
            if (access != null) return access.Value;

            //existiert ein Typeeintrag über die Gruppenzugehörigkeit?
            foreach (Group g in user.Groups)
            {
                bool? gp = _DataAdapter._GetPermissionOfGroupTypePermissionList(type, permissionName, g.Id);
                if (gp == null) continue;
                if (access == null)
                    access = gp;
                access = access | gp;
            }
            if (access != null) return access.Value;

            //Hat man über HierarchicalParent einen Eintrag?
            TypeInfo ti = GetTypeInfoByTypeName(type);

            string hierachicalParentType = (ti.HierachicalParent == null) ? null : ti.HierachicalParent.Name;

            //Hat man über den ObjektParent einen Eintrag?
            if (hierachicalParentType != null)
            {
                access = _DataAdapter._GetPermissionOfUserTypePermissionList(hierachicalParentType, permissionName, user.Id);
                if (access != null) return access.Value;
            }

            //Hat eventuell eine Gruppe über den ObjektParent einen Eintrag?
            if (hierachicalParentType != null)
            {
                foreach (Group g in user.Groups)
                {
                    bool? gp = _DataAdapter._GetPermissionOfGroupTypePermissionList(hierachicalParentType, permissionName, g.Id);
                    if (gp == null) continue;
                    if (access == null)
                        access = gp;
                    access = access | gp;
                }
                if (access != null) return access.Value;
            }

            //nun die Defaultpermission zurückgeben
            return _DataAdapter._GetDefaultPermissionOfType(type, permissionName);
        }
Пример #24
0
 public List<PermissionInfo> GetUserObjectPermissions(object o, User user)
 {
     List<PermissionInfo> pis = new List<PermissionInfo>();
     string type = o.GetType().FullName;
     TypeInfo ti = GetTypeInfoByTypeName(type);
     foreach (PermissionInfo pi in ti.Permissions)
     {
         bool access = GetUserObjectPermission(o, pi.PermissionName, user);
         pis.Add(new PermissionInfo(pi.PermissionName, access));
     }
     return pis;
 }
Пример #25
0
        private bool GetUserTypePermissionInherited(string type, string permissionName, User user)
        {
            bool? access = null;

            //Gibt es Einträge in den Gruppen, zu der der User gehört?
            foreach (Group g in user.Groups)
            {
                bool? gp = _DataAdapter._GetPermissionOfGroupTypePermissionList(type, permissionName, g.Id);
                if (gp == null) continue;
                if (access == null)
                    access = gp;

                access = access | gp;
            }
            if (access != null) return access.Value;

            //Parent?
            TypeInfo ti = GetTypeInfoByTypeName(type);
            if (ti != null && ti.HierachicalParent != null)
            {
                string hierachicalParentType = ti.HierachicalParent.Name;
                access = _DataAdapter._GetPermissionOfUserTypePermissionList(hierachicalParentType, permissionName, user.Id);
            }
            if (access != null) return access.Value;

            //Parent Group
            if (ti != null && ti.HierachicalParent != null)
            {
                string hierachicalParentType = ti.HierachicalParent.Name;
                foreach (Group g in user.Groups)
                {
                    bool? gp = _DataAdapter._GetPermissionOfGroupTypePermissionList(hierachicalParentType, permissionName, g.Id);
                    if (gp == null) continue;
                    if (access == null)
                        access = gp;

                    access = access | gp;
                }

                if (access != null) return access.Value;
            }

            return GetDefaultPermissionOfType(type, permissionName);
        }
Пример #26
0
 private void RemoveUser(User user)
 {
     try
     {
         SecurityFramework.RemoveUser(user);
         if (_Users.ToList().Exists(ui => ui.User == user))
         {
             _Users.Remove(_Users.ToList().Find(ui => ui.User == user));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }