internal static AURole FindMatchRole(IEnumerable <AURole> auRoles, AUSchemaRole schemaRole) { AURole result = null; foreach (var item in auRoles) { if (item.SchemaRoleID == schemaRole.ID) { result = item; break; } } return(result); }
private void ImportRoleMembers(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, Operations.IFacade exec, ImportContextWrapper wrapper, int totalSteps, AdminUnit unit, int currentStep, AURole[] roles) { if (this.IncludeRoleMembers) { wrapper.SetStatusAndLog(currentStep, totalSteps, "正在替换管理单元角色成员" + unit.GetQualifiedName()); foreach (AURole role in roles) { var userIDS = (from c in objectSet.Membership where c.ContainerID == role.ID && c.MemberSchemaType == "Users" && c.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal select c.ID).ToArray(); var users = MCS.Library.OGUPermission.OguMechanismFactory.GetMechanism().GetObjects<IUser>(SearchOUIDType.Guid, userIDS); var scUsers = (from u in users select new SCUser() { }).ToArray(); var schemaRole = AUCommon.DoDbProcess<AUSchemaRole>(() => (AUSchemaRole)PC.Adapters.SchemaObjectAdapter.Instance.Load(role.SchemaRoleID)); exec.ReplaceUsersInRole(scUsers, unit, schemaRole); } } }
public void AddAdminUnitWithMembers(ClientAdminUnit unit, ClientAdminUnit parent, ClientAURole[] roles, ClientAUAdminScope[] scopes) { roles.NullCheck("roles"); scopes.NullCheck("scopes"); CheckIDProvided(unit); AURole[] auRoles = new AURole[roles.Length]; for (int i = roles.Length - 1; i >= 0; i--) auRoles[i] = (AURole)roles[i].ToSchemaObject(); AUAdminScope[] auScopes = new AUAdminScope[scopes.Length]; for (int i = scopes.Length - 1; i >= 0; i--) auScopes[i] = (AUAdminScope)scopes[i].ToSchemaObject(); EnsureID(unit); AdminUnit auParent = parent != null ? (AdminUnit)parent.ToSchemaObject(true) : null; this.Facade.AddAdminUnitWithMembers((AdminUnit)unit.ToSchemaObject(false), auParent, auRoles, auScopes); }