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); } }
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); } }
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); } }
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(); }
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; }
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; }
public GroupMembershipInfo(Group group, User user) { Group = group; User = user; }
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); }
public void UpdateUser(User user) { _DataAdapter._UpdateUser(user); }
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); } }
public void ResetUserObjectPermission(object o, User user) { string locator = GetLocator(o); string type = o.GetType().FullName; _DataAdapter._ResetUserObjectPermission(locator, type, user.Id); }
/// <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!"); }
internal SecurityToken(User user, Framework fw) { _User = user; _Framework = fw; }
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); } }
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; }
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); }
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(); }
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); } }
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); }
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); }
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; }
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); }