Beispiel #1
0
 protected void SaveDerivedRoleAndWarnOnValidationErrors(ExchangeRole role)
 {
     if (role.IsRootRole)
     {
         throw new ArgumentNullException("Only derive roles should be");
     }
     try
     {
         int count = role.RoleEntries.Count;
         ValidationError[] array = role.Validate();
         role.AllowEmptyRole = true;
         this.settings.ConfigurationSession.Save(role);
         this.settings.LogWriteObject(role);
         this.settings.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(role, this.settings.ConfigurationSession, typeof(ExchangeRole)));
         if (array != null && array.Length != 0)
         {
             this.settings.WriteWarning(Strings.WarningInvalidRoleAfterUpgrade(role.Identity.ToString(), MultiValuedPropertyBase.FormatMultiValuedProperty(array)));
         }
     }
     catch (DataSourceOperationException ex)
     {
         this.settings.WriteWarning(Strings.WarningCannotUpgradeRole(role.Identity.ToString(), ex.Message));
     }
     catch (DataValidationException ex2)
     {
         this.settings.WriteWarning(Strings.WarningCannotUpgradeRole(role.Identity.ToString(), ex2.Message));
     }
 }
        private bool TryUpdateRoleAssigneeTypeAndScope(ExchangeRoleAssignment assignment)
        {
            RoleAssigneeType roleAssigneeType = RoleAssigneeType.User;
            ADRawEntry       adrawEntry       = this.recipientSession.ReadADRawEntry(assignment.User, InstallCannedRbacRoleAssignments.principalProperties);

            if (adrawEntry == null)
            {
                adrawEntry = this.configurationSession.ReadADRawEntry(assignment.User, InstallCannedRbacRoleAssignments.principalProperties);
                if (adrawEntry == null)
                {
                    return(false);
                }
            }
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass];

            foreach (string value in multiValuedProperty)
            {
                if ("group".Equals(value, StringComparison.OrdinalIgnoreCase))
                {
                    roleAssigneeType = RoleAssigneeType.SecurityGroup;
                    break;
                }
                if ("msExchRBACPolicy".Equals(value, StringComparison.OrdinalIgnoreCase))
                {
                    roleAssigneeType = RoleAssigneeType.RoleAssignmentPolicy;
                    break;
                }
                if ("user".Equals(value, StringComparison.OrdinalIgnoreCase))
                {
                    if (RecipientTypeDetails.MailboxPlan == (RecipientTypeDetails)adrawEntry[ADRecipientSchema.RecipientTypeDetails])
                    {
                        roleAssigneeType = RoleAssigneeType.MailboxPlan;
                        break;
                    }
                    roleAssigneeType = RoleAssigneeType.User;
                    break;
                }
            }
            ConfigWriteScopeType configWriteScopeType = assignment.ConfigWriteScope;
            ScopeType            scopeType            = assignment.ConfigReadScope;

            if (configWriteScopeType == ConfigWriteScopeType.None)
            {
                ExchangeRole exchangeRole = this.configurationSession.Read <ExchangeRole>(assignment.Role);
                if (exchangeRole != null)
                {
                    base.LogReadObject(exchangeRole);
                    ValidationError[] array = exchangeRole.Validate();
                    if (array.Length > 0)
                    {
                        this.WriteWarning(Strings.WarningCannotUpgradeRole(exchangeRole.Identity.ToString(), array[0].Description));
                        return(false);
                    }
                    scopeType            = exchangeRole.ImplicitConfigReadScope;
                    configWriteScopeType = (ConfigWriteScopeType)exchangeRole.ImplicitConfigWriteScope;
                }
            }
            if (assignment.RoleAssigneeType != roleAssigneeType || assignment.ConfigWriteScope != configWriteScopeType || assignment.ConfigReadScope != scopeType)
            {
                assignment.RoleAssigneeType = roleAssigneeType;
                assignment.ConfigReadScope  = scopeType;
                assignment.ConfigWriteScope = configWriteScopeType;
            }
            return(true);
        }