private void OnPrivilegeGranted(ESysPrivilege privilege) { if (PrivilegeGranted != null) { PrivilegeGranted(this.userRole as RoleManager.Role, privilege); } }
private void privManager_PrivilegeGranted(RoleManager.Role sender, ESysPrivilege privilege) { // create a queue var queue = CreateDistributionQueue( new { Source = default(RoleManager.Role), Destination = default(UserRole), Privilege = default(ESysPrivilege) }); // fill a queue foreach (UserRole userRole in sender.RoleManager.Dependants) { queue.Enqueue(new { Source = sender, Destination = userRole, Privilege = privilege }); } // start BFS while (queue.Count > 0) { // get a distribution vector var vector = queue.Dequeue(); // get a user or role, which is going to download the privilege info UserRole destination = vector.Destination; if (destination.PrivManager.DownloadPrivilegeChange(privilege, vector.Source)) { // enqueue dependants foreach (UserRole dependant in destination.RoleManager.Dependants) { queue.Enqueue(new { Source = destination as RoleManager.Role, Destination = dependant, Privilege = privilege }); } } } }
public GrantedSysPrivilege(string grantee, ESysPrivilege privilege, bool directGrant, bool adminOption) : base(grantee) { this.grantee = grantee; this.privilege = privilege; this.adminOption = adminOption; this.directGrant = directGrant; }
public bool GetPrivilegeGrantInfo(ESysPrivilege privilege, out GrantedSysPrivilege grant) { IEnumerable <GrantedSysPrivilege> search = from privGrant in privileges where privGrant.Privilege == privilege select privGrant; if (search.Count() > 0) { grant = search.First(); return(true); } else { grant = null; return(false); } }
public bool DownloadPrivilegeChange(ESysPrivilege privilege, RoleManager.Role from) { GrantedSysPrivilege downloaded; RolePrivManagerLocal rolePrivManager = from.PrivManager as RolePrivManagerLocal; if (rolePrivManager.GetPrivilegeGrantInfo(privilege, out downloaded)) { if (mergePrivilege(createInheritedGrant(downloaded))) { return(true); } else { return(false); } } return(false); }