private void RemoveAllRoleAssignmentsForOneRole(ExchangeRole role, RoleAssignmentDelegationType delegationType)
        {
            QueryFilter queryFilter;

            if (delegationType == RoleAssignmentDelegationType.Regular)
            {
                queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.RoleAssignmentDelegationType, delegationType);
            }
            else
            {
                queryFilter = new OrFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.RoleAssignmentDelegationType, RoleAssignmentDelegationType.Delegating),
                    new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.RoleAssignmentDelegationType, RoleAssignmentDelegationType.DelegatingOrgWide)
                });
            }
            foreach (ExchangeRoleAssignment exchangeRoleAssignment in this.configurationSession.FindPaged <ExchangeRoleAssignment>(base.OrgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer), QueryScope.OneLevel, new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.Role, role.Id),
                queryFilter
            }), null, 0))
            {
                this.configurationSession.Delete(exchangeRoleAssignment);
                base.LogWriteObject(exchangeRoleAssignment);
            }
        }
Exemplo n.º 2
0
 public ManagementRoleAssignment(ExchangeRoleAssignmentPresentation assignment) : base(assignment.ToIdentity(), assignment)
 {
     this.Role             = assignment.Role;
     this.RoleAssignmentId = assignment.ToIdentity();
     this.Name             = assignment.Name;
     this.DelegationType   = assignment.RoleAssignmentDelegationType;
 }
 public RoleAssignmentDefinition(RoleType roleType, RoleAssignmentDelegationType delegationType, string[] neededFeatures, string introducedInBuild, bool useSafeVersionOfRole)
 {
     this.RoleType          = roleType;
     this.DelegationType    = delegationType;
     this.neededFeatures    = neededFeatures;
     this.introducedInBuild = introducedInBuild;
     this.UseSafeRole       = useSafeVersionOfRole;
 }
        private void CreateRoleAssignment(ExchangeRole role, ADRecipient recipient, RoleAssignmentDelegationType delegationType)
        {
            if (this.adSplitPermissionMode && delegationType == RoleAssignmentDelegationType.Regular && InstallCannedRbacRoleAssignments.invalidRoleTypesInADSplitPermissionMode.Contains(role.RoleType))
            {
                base.WriteVerbose(Strings.VerboseSkipCreatingRoleAssignment(recipient.Id.ToString(), role.Id.ToString(), delegationType.ToString()));
                return;
            }
            RoleAssigneeType roleAssigneeType = ExchangeRoleAssignment.RoleAssigneeTypeFromADRecipient(recipient);

            RoleHelper.CreateRoleAssignment(role, recipient.Id, recipient.OrganizationId, roleAssigneeType, recipient.OriginatingServer, delegationType, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, this.configurationSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError));
        }
 private bool FindRoleAssignment(ExchangeRole role, ADRecipient user, RoleAssignmentDelegationType delegationType)
 {
     using (IEnumerator <ExchangeRoleAssignment> enumerator = this.configurationSession.FindPaged <ExchangeRoleAssignment>(base.OrgContainerId, QueryScope.SubTree, new AndFilter(new QueryFilter[]
     {
         new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.Role, role.Id),
         new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.User, user.Id),
         new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.RoleAssignmentDelegationType, delegationType)
     }), null, 1).GetEnumerator())
     {
         if (enumerator.MoveNext())
         {
             ExchangeRoleAssignment exchangeRoleAssignment = enumerator.Current;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        internal static string GenerateUniqueRoleAssignmentName(IConfigurationSession configurationSession, ADObjectId orgContainerId, string roleName, string roleAssigneeName, RoleAssignmentDelegationType roleAssignmentDelegationType, Task.TaskVerboseLoggingDelegate writeVerbose)
        {
            if (configurationSession == null)
            {
                throw new ArgumentNullException("configurationSession");
            }
            if (orgContainerId == null)
            {
                throw new ArgumentNullException("orgContainerId");
            }
            string text = roleName + "-" + roleAssigneeName;

            if (roleAssignmentDelegationType != RoleAssignmentDelegationType.Regular)
            {
                text += "-Delegating";
            }
            text = text.Trim();
            if (text.Length > 64)
            {
                text = text.Substring(0, 64).Trim();
            }
            if (writeVerbose == null)
            {
                throw new ArgumentNullException("writeVerbose");
            }
            ADObjectId descendantId = orgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer);
            string     text2        = text;

            if (text2.Length > 61)
            {
                text2 = text2.Substring(0, 61).Trim();
            }
            int num = 1;

            for (;;)
            {
                QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, text);
                writeVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configurationSession, typeof(ExchangeRoleAssignment), filter, descendantId, false));
                ExchangeRoleAssignment[] array = configurationSession.Find <ExchangeRoleAssignment>(descendantId, QueryScope.OneLevel, filter, null, 1);
                if (array.Length == 0)
                {
                    break;
                }
                text = text2 + "-" + num.ToString();
                num++;
                if (num >= 100)
                {
                    return(text);
                }
            }
            return(text);
        }
 private void RemoveRoleAssignmentsFromGroup(ExchangeRole role, ADGroup group, RoleAssignmentDelegationType delegationType)
 {
     foreach (ExchangeRoleAssignment exchangeRoleAssignment in this.configurationSession.FindPaged <ExchangeRoleAssignment>(base.OrgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer), QueryScope.OneLevel, new AndFilter(new QueryFilter[]
     {
         new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.Role, role.Id),
         new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.User, group.Id),
         new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.RoleAssignmentDelegationType, delegationType)
     }), null, 0))
     {
         this.configurationSession.Delete(exchangeRoleAssignment);
         base.LogWriteObject(exchangeRoleAssignment);
     }
 }