protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            ExchangeOrganizationalUnit exchangeOrganizationalUnit = null;

            if (base.Fields.IsModified("DefaultDistributionListOU"))
            {
                this.DataObject.DefaultDistributionListOU = ((this.defaultOU == null) ? null : this.defaultOU.Id);
                exchangeOrganizationalUnit = this.defaultOU;
            }
            else if (this.DataObject.IsChanged(RecipientTemplateProvisioningPolicySchema.DefaultDistributionListOU) && this.DataObject.DefaultDistributionListOU != null)
            {
                exchangeOrganizationalUnit = RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(this.DataObject.DefaultDistributionListOU), this.ConfigurationSession, null, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.Client, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
            }
            if (exchangeOrganizationalUnit != null)
            {
                OrganizationId organizationId = OrganizationId.ForestWideOrgId;
                if (this.ConfigurationSession is ITenantConfigurationSession)
                {
                    organizationId = TaskHelper.ResolveOrganizationId(this.DataObject.Id, ADProvisioningPolicy.RdnContainer, (ITenantConfigurationSession)this.ConfigurationSession);
                }
                RecipientTaskHelper.IsOrgnizationalUnitInOrganization(this.ConfigurationSession, organizationId, exchangeOrganizationalUnit, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
            }
            TaskLogger.LogExit();
        }
Esempio n. 2
0
 protected override void PrepareRecipientObject(ADDynamicGroup group)
 {
     TaskLogger.LogEnter();
     base.PrepareRecipientObject(group);
     if (base.OrganizationalUnit == null && group[ADRecipientSchema.DefaultDistributionListOU] != null)
     {
         ADObjectId adobjectId = (ADObjectId)group[ADRecipientSchema.DefaultDistributionListOU];
         RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(adobjectId), this.ConfigurationSession, base.CurrentOrganizationId, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.ServerOperation, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
         group.SetId(adobjectId.GetChildId(base.Name));
     }
     if (this.RecipientContainer == null)
     {
         if (!base.Fields.IsModified(ADDynamicGroupSchema.RecipientContainer))
         {
             group.RecipientContainer = group.Id.Parent;
         }
     }
     else
     {
         bool useConfigNC      = this.ConfigurationSession.UseConfigNC;
         bool useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog;
         this.ConfigurationSession.UseConfigNC = false;
         if (string.IsNullOrEmpty(this.ConfigurationSession.DomainController))
         {
             this.ConfigurationSession.UseGlobalCatalog = true;
         }
         ExchangeOrganizationalUnit exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(this.RecipientContainer, this.ConfigurationSession, (base.CurrentOrganizationId != null) ? base.CurrentOrganizationId.OrganizationalUnit : null, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.RecipientContainer.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.RecipientContainer.ToString())), ExchangeErrorCategory.Client);
         RecipientTaskHelper.IsOrgnizationalUnitInOrganization(this.ConfigurationSession, group.OrganizationId, exchangeOrganizationalUnit, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
         this.ConfigurationSession.UseConfigNC      = useConfigNC;
         this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
         group.RecipientContainer = (ADObjectId)exchangeOrganizationalUnit.Identity;
     }
     group.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.DynamicDistributionGroup);
     TaskLogger.LogExit();
 }
Esempio n. 3
0
        private ADObjectId GetHierarchicalAddressBookRootFromOU(ADObjectId ouId)
        {
            if (ouId == null)
            {
                return(null);
            }
            ExchangeOrganizationalUnit exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(new OrganizationalUnitIdParameter(ouId), this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(ouId.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(ouId.ToString())));

            return(exchangeOrganizationalUnit.HierarchicalAddressBookRoot);
        }
Esempio n. 4
0
        protected override void InternalBeginProcessing()
        {
            TaskLogger.LogEnter();
            base.InternalBeginProcessing();
            if (this.Identity != null && this.OrganizationalUnit != null && this.IgnoreDefaultScope)
            {
                base.ThrowTerminatingError(new ArgumentException(Strings.ErrorIdAndOUSetTogetherUnderIgnoreDefaultScope), ErrorCategory.InvalidArgument, null);
            }
            ExchangeOrganizationalUnit exchangeOrganizationalUnit = null;

            if (this.OrganizationalUnit != null)
            {
                bool useConfigNC      = this.ConfigurationSession.UseConfigNC;
                bool useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog;
                this.ConfigurationSession.UseConfigNC = false;
                if (string.IsNullOrEmpty(this.ConfigurationSession.DomainController))
                {
                    this.ConfigurationSession.UseGlobalCatalog = true;
                }
                try
                {
                    exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(this.OrganizationalUnit, this.ConfigurationSession, (base.CurrentOrganizationId != null) ? base.CurrentOrganizationId.OrganizationalUnit : null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.OrganizationalUnit.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.OrganizationalUnit.ToString())));
                    RecipientTaskHelper.IsOrgnizationalUnitInOrganization(this.ConfigurationSession, base.CurrentOrganizationId, exchangeOrganizationalUnit, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                }
                finally
                {
                    this.ConfigurationSession.UseConfigNC      = useConfigNC;
                    this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
                }
            }
            if (exchangeOrganizationalUnit != null)
            {
                this.rootId = exchangeOrganizationalUnit.Id;
            }
            else
            {
                this.rootId = ((base.CurrentOrganizationId != null) ? base.CurrentOrganizationId.OrganizationalUnit : null);
            }
            if (this.UsnForReconciliationSearch >= 0L)
            {
                if (base.DomainController == null)
                {
                    base.ThrowTerminatingError(new ArgumentException(Strings.ErrorDomainControllerNotSpecifiedWithUsnForReconciliationSearch), ErrorCategory.InvalidArgument, null);
                }
                base.InternalResultSize = Unlimited <uint> .UnlimitedValue;
                base.OptionalIdentityData.AdditionalFilter = new ComparisonFilter(ComparisonOperator.GreaterThan, ADRecipientSchema.UsnCreated, this.UsnForReconciliationSearch);
            }
            TaskLogger.LogExit();
        }
Esempio n. 5
0
        public static ADContainer GetAdminSDHolder(ADObjectId domainId, IConfigurationSession session)
        {
            ExchangeOrganizationalUnit exchangeOrganizationalUnit = session.ResolveWellKnownGuid <ExchangeOrganizationalUnit>(WellKnownGuid.SystemWkGuid, domainId);

            if (exchangeOrganizationalUnit == null)
            {
                throw new SystemContainerNotFoundException(DNConvertor.FqdnFromDomainDistinguishedName(domainId.DistinguishedName), WellKnownGuid.SystemWkGuid);
            }
            ADContainer adcontainer = session.Read <ADContainer>(exchangeOrganizationalUnit.Id.GetChildId("AdminSDHolder"));

            if (adcontainer == null)
            {
                throw new AdminSDHolderNotFoundException(exchangeOrganizationalUnit.DistinguishedName);
            }
            return(adcontainer);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (this.microsoftExchangeRecipient != null && this.microsoftExchangeRecipient.ObjectState != ObjectState.Unchanged)
     {
         this.recipientSession.Save(this.microsoftExchangeRecipient);
     }
     if (this.DataObject.IsModified(OrganizationSchema.CustomerFeedbackEnabled))
     {
         IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession;
         IEnumerable <Server>  enumerable           = configurationSession.FindAllPaged <Server>();
         if (enumerable != null)
         {
             foreach (Server server in enumerable)
             {
                 if (server.IsE14OrLater)
                 {
                     server.CustomerFeedbackEnabled = this.DataObject.CustomerFeedbackEnabled;
                     configurationSession.Save(server);
                 }
             }
         }
     }
     if (this.DataObject.IsModified(OrganizationSchema.HABRootDepartmentLink) && VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
     {
         ADOrganizationConfig dataObject = this.DataObject;
         ADObjectId           hierarchicalAddressBookRoot = dataObject.HierarchicalAddressBookRoot;
         dataObject.HierarchicalAddressBookRoot = null;
         IConfigurationSession      tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, this.ConfigurationSession.SessionSettings, 756, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\SetOrganization.cs");
         ADObjectId                 organizationalUnit         = dataObject.OrganizationId.OrganizationalUnit;
         ExchangeOrganizationalUnit exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(new OrganizationalUnitIdParameter(organizationalUnit), tenantOrTopologyConfigurationSession, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(organizationalUnit.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(organizationalUnit.ToString())));
         exchangeOrganizationalUnit.HierarchicalAddressBookRoot = hierarchicalAddressBookRoot;
         tenantOrTopologyConfigurationSession.Save(exchangeOrganizationalUnit);
     }
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
Esempio n. 7
0
        // Token: 0x0600049E RID: 1182 RVA: 0x000108B0 File Offset: 0x0000EAB0
        protected override void InternalBeginProcessing()
        {
            base.InternalBeginProcessing();
            if (!string.IsNullOrEmpty(this.ExternalDirectoryObjectId))
            {
                ITenantRecipientSession tenantRecipientSession = base.TenantGlobalCatalogSession as ITenantRecipientSession;
                if (tenantRecipientSession != null)
                {
                    bool useGlobalCatalog = tenantRecipientSession.UseGlobalCatalog;
                    tenantRecipientSession.UseGlobalCatalog = false;
                    Result <ADRawEntry>[] array = null;
                    try
                    {
                        array = tenantRecipientSession.FindByExternalDirectoryObjectIds(new string[]
                        {
                            this.ExternalDirectoryObjectId
                        }, true, new ADPropertyDefinition[]
                        {
                            DeletedObjectSchema.LastKnownParent
                        });
                    }
                    finally
                    {
                        tenantRecipientSession.UseGlobalCatalog = useGlobalCatalog;
                    }
                    if (array != null)
                    {
                        for (int i = 0; i < array.Length; i++)
                        {
                            if (array[i].Error != ProviderError.NotFound || array[i].Data != null)
                            {
                                ADObjectId adobjectId = null;
                                if (array[i].Error == null)
                                {
                                    adobjectId = (ADObjectId)array[i].Data[DeletedObjectSchema.LastKnownParent];
                                }
                                if (array[i].Error != null || adobjectId == null || (adobjectId.DomainId != null && !adobjectId.IsDescendantOf(ADSession.GetDeletedObjectsContainer(adobjectId.DomainId))))
                                {
                                    base.ThrowTerminatingError(new DuplicateExternalDirectoryObjectIdException(this.Name, this.ExternalDirectoryObjectId), ExchangeErrorCategory.Client, null);
                                }
                            }
                        }
                    }
                }
            }
            bool useConfigNC       = this.ConfigurationSession.UseConfigNC;
            bool useGlobalCatalog2 = this.ConfigurationSession.UseGlobalCatalog;

            this.ConfigurationSession.UseConfigNC      = false;
            this.ConfigurationSession.UseGlobalCatalog = true;
            IConfigurationSession cfgSession = this.ConfigurationSession;

            if (!cfgSession.IsReadConnectionAvailable())
            {
                cfgSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, this.ConfigurationSession.SessionSettings, 623, "InternalBeginProcessing", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs");
                cfgSession.UseGlobalCatalog = true;
                cfgSession.UseConfigNC      = false;
            }
            try
            {
                ExchangeOrganizationalUnit exchangeOrganizationalUnit = null;
                if (this.OrganizationalUnit != null)
                {
                    exchangeOrganizationalUnit = base.ProvisioningCache.TryAddAndGetGlobalDictionaryValue <ExchangeOrganizationalUnit, string>(CannedProvisioningCacheKeys.OrganizationalUnitDictionary, this.OrganizationalUnit.RawIdentity, () => (ExchangeOrganizationalUnit)this.GetDataObject <ExchangeOrganizationalUnit>(this.OrganizationalUnit, cfgSession, (this.CurrentOrganizationId != null) ? this.CurrentOrganizationId.OrganizationalUnit : null, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.OrganizationalUnit.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.OrganizationalUnit.ToString()))));
                }
                if (exchangeOrganizationalUnit != null)
                {
                    this.containerId = exchangeOrganizationalUnit.Id;
                }
                else if (base.CurrentOrganizationId != null && base.CurrentOrganizationId.OrganizationalUnit != null)
                {
                    this.containerId = base.CurrentOrganizationId.OrganizationalUnit;
                }
                else
                {
                    string defaultOUForRecipient = RecipientTaskHelper.GetDefaultOUForRecipient(base.ServerSettings.RecipientViewRoot);
                    if (string.IsNullOrEmpty(defaultOUForRecipient))
                    {
                        base.ThrowTerminatingError(new TaskArgumentException(Strings.ErrorCannotDiscoverDefaultOrganizationUnitForRecipient), ExchangeErrorCategory.Client, null);
                    }
                    exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(new OrganizationalUnitIdParameter(defaultOUForRecipient), cfgSession, null, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(defaultOUForRecipient)), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(defaultOUForRecipient)), ExchangeErrorCategory.Client);
                    this.containerId           = exchangeOrganizationalUnit.Id;
                }
                if (exchangeOrganizationalUnit != null)
                {
                    RecipientTaskHelper.IsOrgnizationalUnitInOrganization(cfgSession, base.CurrentOrganizationId, exchangeOrganizationalUnit, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                }
            }
            finally
            {
                this.ConfigurationSession.UseConfigNC      = useConfigNC;
                this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog2;
            }
        }
Esempio n. 8
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ExchangeOrganizationalUnit exchangeOrganizationalUnit = null;

            ((IConfigurationSession)base.DataSession).SessionSettings.IsSharedConfigChecked = true;
            this.ConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
            this.DataObject = (ExchangeRoleAssignment)base.PrepareDataObject();
            if (base.HasErrors)
            {
                return(null);
            }
            if (!this.IgnoreDehydratedFlag)
            {
                SharedConfigurationTaskHelper.VerifyIsNotTinyTenant(base.CurrentOrgState, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            this.role = (ExchangeRole)base.GetDataObject <ExchangeRole>(this.Role, base.DataSession, null, new LocalizedString?(Strings.ErrorRoleNotFound(this.Role.ToString())), new LocalizedString?(Strings.ErrorRoleNotUnique(this.Role.ToString())));
            RoleHelper.VerifyNoScopeForUnScopedRole(base.Fields, this.role, new Task.TaskErrorLoggingDelegate(base.WriteError));
            if (this.role != null && this.role.IsDeprecated)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorCannotCreateRoleAssignmentToADeprecatedRole(this.role.ToString())), ErrorCategory.InvalidOperation, null);
            }
            RoleAssigneeType roleAssigneeType;
            ADObject         adobject;

            if (this.Policy != null)
            {
                RoleAssignmentPolicy roleAssignmentPolicy = (RoleAssignmentPolicy)base.GetDataObject <RoleAssignmentPolicy>(this.Policy, RecipientTaskHelper.GetTenantLocalConfigSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId, base.RootOrgContainerId), null, new LocalizedString?(Strings.ErrorRBACPolicyNotFound(this.Policy.ToString())), new LocalizedString?(Strings.ErrorRBACPolicyNotUnique(this.Policy.ToString())));
                if (!this.role.IsEndUserRole)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorNonEndUserRoleCannoBeAssignedToPolicy(this.role.Name)), ErrorCategory.InvalidOperation, roleAssignmentPolicy.Id);
                }
                OrganizationId organizationId = OrganizationId.ForestWideOrgId;
                if (this.ConfigurationSession is ITenantConfigurationSession)
                {
                    organizationId = TaskHelper.ResolveOrganizationId(this.role.Id, ExchangeRole.RdnContainer, (ITenantConfigurationSession)this.ConfigurationSession);
                }
                ADObjectId adobjectId;
                if (OrganizationId.ForestWideOrgId.Equals(organizationId))
                {
                    adobjectId = this.ConfigurationSession.GetOrgContainerId();
                }
                else
                {
                    adobjectId = organizationId.ConfigurationUnit;
                }
                if (!roleAssignmentPolicy.Id.IsDescendantOf(adobjectId))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorPolicyOutOfRoleScope(roleAssignmentPolicy.Id.ToString(), adobjectId.Name)), ErrorCategory.InvalidOperation, null);
                }
                roleAssigneeType = RoleAssigneeType.RoleAssignmentPolicy;
                adobject         = roleAssignmentPolicy;
            }
            else
            {
                ADRecipient adrecipient = null;
                if (this.User != null)
                {
                    adrecipient = (ADUser)base.GetDataObject <ADUser>(this.User, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorAssigneeUserNotFound(this.User.ToString())), new LocalizedString?(Strings.ErrorAssigneeUserNotUnique(this.User.ToString())));
                }
                else if (this.SecurityGroup != null)
                {
                    adrecipient = (ADGroup)base.GetDataObject <ADGroup>(this.SecurityGroup, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorAssigneeSecurityGroupNotFound(this.SecurityGroup.ToString())), new LocalizedString?(Strings.ErrorAssigneeSecurityGroupNotUnique(this.SecurityGroup.ToString())));
                }
                else if (this.Computer != null)
                {
                    adrecipient = (ADComputerRecipient)base.GetDataObject <ADComputerRecipient>(this.Computer, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorAssigneeComputerNotFound(this.Computer.ToString())), new LocalizedString?(Strings.ErrorAssigneeComputerNotUnique(this.Computer.ToString())));
                }
                RoleHelper.ValidateRoleAssignmentUser(adrecipient, new Task.TaskErrorLoggingDelegate(base.WriteError), false);
                roleAssigneeType = ExchangeRoleAssignment.RoleAssigneeTypeFromADRecipient(adrecipient);
                adobject         = adrecipient;
            }
            ((IDirectorySession)base.DataSession).LinkResolutionServer = adobject.OriginatingServer;
            RoleHelper.PrepareNewRoleAssignmentWithUniqueNameAndDefaultScopes(this.Name, this.DataObject, this.role, adobject.Id, adobject.OrganizationId, roleAssigneeType, this.Delegating.IsPresent ? RoleAssignmentDelegationType.Delegating : RoleAssignmentDelegationType.Regular, this.ConfigurationSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError));
            if (this.role.IsUnscopedTopLevel && this.UnScopedTopLevel)
            {
                this.skipHRoleCheck = true;
                if (this.Delegating)
                {
                    this.DataObject.RoleAssignmentDelegationType = RoleAssignmentDelegationType.DelegatingOrgWide;
                }
            }
            else
            {
                RoleHelper.AnalyzeAndStampCustomizedWriteScopes(this, this.DataObject, this.role, this.ConfigurationSession, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ManagementScope>), ref this.skipHRoleCheck, ref exchangeOrganizationalUnit, ref this.customRecipientScope, ref this.customConfigScope);
            }
            TaskLogger.LogExit();
            return(this.DataObject);
        }
Esempio n. 9
0
        private void VerifyAndSetRecipientViewRoot(string root)
        {
            if (object.Equals(root, this.modifiedServerSettings.RecipientViewRoot))
            {
                return;
            }
            OrganizationalUnitIdParameter organizationalUnitIdParameter = null;

            try
            {
                organizationalUnitIdParameter = OrganizationalUnitIdParameter.Parse(root);
            }
            catch (ArgumentException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidArgument, this);
            }
            if (this.configSession == null)
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromCustomScopeSet(base.ScopeSet, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);
                this.configSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 588, "VerifyAndSetRecipientViewRoot", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\ADServerSettings\\SetADServerSettings.cs");
                this.configSession.UseGlobalCatalog = true;
                this.configSession.UseConfigNC      = false;
            }
            ADObjectId adobjectId = null;

            if (base.ScopeSet.RecipientReadScope != null && base.ScopeSet.RecipientReadScope.Root != null)
            {
                adobjectId = base.ScopeSet.RecipientReadScope.Root;
            }
            ExchangeOrganizationalUnit exchangeOrganizationalUnit = null;

            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.VerboseVerifyingRecipientViewRoot(root));
            }
            IEnumerable <ExchangeOrganizationalUnit> objects = organizationalUnitIdParameter.GetObjects <ExchangeOrganizationalUnit>(adobjectId, this.configSession);

            using (IEnumerator <ExchangeOrganizationalUnit> enumerator = objects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    exchangeOrganizationalUnit = enumerator.Current;
                    if (enumerator.MoveNext())
                    {
                        if (adobjectId != null)
                        {
                            base.WriteError(new ManagementObjectAmbiguousException(Strings.ErrorRecipientViewRootDuplicatedUnderScope(root, adobjectId.ToString())), ErrorCategory.InvalidArgument, this);
                        }
                        else
                        {
                            base.WriteError(new ManagementObjectAmbiguousException(Strings.ErrorRecipientViewRootDuplicated(root)), ErrorCategory.InvalidArgument, this);
                        }
                    }
                }
                else if (adobjectId != null)
                {
                    base.WriteError(new ArgumentException(Strings.ErrorRecipientViewRootNotFoundUnderScope(root, adobjectId.ToString())), ErrorCategory.InvalidArgument, this);
                }
                else
                {
                    base.WriteError(new ArgumentException(Strings.ErrorRecipientViewRootNotFound(root)), ErrorCategory.InvalidArgument, this);
                }
            }
            this.modifiedServerSettings.RecipientViewRoot = exchangeOrganizationalUnit.Id;
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.VerboseVerifyRecipientViewRootSucceed);
            }
        }
Esempio n. 10
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (!this.Force && SharedConfiguration.IsSharedConfiguration(this.DataObject.OrganizationId) && !base.ShouldContinue(Strings.ConfirmSharedConfiguration(this.DataObject.OrganizationId.OrganizationalUnit.Name)))
            {
                TaskLogger.LogExit();
                return;
            }
            if (base.Fields.IsModified(RbacCommonParameters.ParameterEnabled))
            {
                this.DataObject.Enabled = this.Enabled;
            }
            ExchangeRole exchangeRole = (ExchangeRole)base.GetDataObject <ExchangeRole>(new RoleIdParameter(this.DataObject.Role), this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorRoleNotFound(this.DataObject.Role.ToString())), new LocalizedString?(Strings.ErrorRoleNotUnique(this.DataObject.Role.ToString())));

            if (base.Fields.IsModified(RbacCommonParameters.ParameterRecipientRelativeWriteScope))
            {
                this.DataObject.RecipientWriteScope       = this.RecipientRelativeWriteScope;
                this.DataObject.CustomRecipientWriteScope = null;
            }
            else
            {
                if (base.Fields.IsModified(RbacCommonParameters.ParameterRecipientOrganizationalUnitScope))
                {
                    this.DataObject.RecipientWriteScope = RecipientWriteScopeType.OU;
                    bool useConfigNC      = this.ConfigurationSession.UseConfigNC;
                    bool useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog;
                    try
                    {
                        this.ConfigurationSession.UseConfigNC      = false;
                        this.ConfigurationSession.UseGlobalCatalog = true;
                        ExchangeOrganizationalUnit exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(this.RecipientOrganizationalUnitScope, this.ConfigurationSession, this.DataObject.OrganizationalUnitRoot, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.RecipientOrganizationalUnitScope.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.RecipientOrganizationalUnitScope.ToString())));
                        this.DataObject.CustomRecipientWriteScope = exchangeOrganizationalUnit.Id;
                        goto IL_321;
                    }
                    finally
                    {
                        this.ConfigurationSession.UseConfigNC      = useConfigNC;
                        this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
                    }
                }
                if (base.Fields.IsModified(RbacCommonParameters.ParameterCustomRecipientWriteScope))
                {
                    if (this.CustomRecipientWriteScope == null)
                    {
                        this.DataObject.CustomRecipientWriteScope = null;
                        this.DataObject.RecipientWriteScope       = (RecipientWriteScopeType)exchangeRole.ImplicitRecipientWriteScope;
                    }
                    else
                    {
                        ManagementScope andValidateDomainScope = RoleHelper.GetAndValidateDomainScope(this.CustomRecipientWriteScope, this.ConfigurationSession, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ManagementScope>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
                        if (andValidateDomainScope.Exclusive)
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorScopeExclusive(andValidateDomainScope.Id.ToString(), RbacCommonParameters.ParameterCustomRecipientWriteScope)), ErrorCategory.InvalidArgument, null);
                        }
                        this.DataObject.CustomRecipientWriteScope = andValidateDomainScope.Id;
                        this.DataObject.RecipientWriteScope       = RecipientWriteScopeType.CustomRecipientScope;
                    }
                }
                else if (base.Fields.IsModified("ExclusiveRecipientWriteScope"))
                {
                    ManagementScope andValidateDomainScope2 = RoleHelper.GetAndValidateDomainScope(this.ExclusiveRecipientWriteScope, this.ConfigurationSession, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ManagementScope>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    if (!andValidateDomainScope2.Exclusive)
                    {
                        base.WriteError(new ArgumentException(Strings.ErrorScopeNotExclusive(andValidateDomainScope2.Id.ToString(), "ExclusiveRecipientWriteScope")), ErrorCategory.InvalidArgument, null);
                    }
                    this.DataObject.CustomRecipientWriteScope = andValidateDomainScope2.Id;
                    this.DataObject.RecipientWriteScope       = RecipientWriteScopeType.ExclusiveRecipientScope;
                }
            }
IL_321:
            RoleHelper.VerifyNoScopeForUnScopedRole(base.Fields, exchangeRole, new Task.TaskErrorLoggingDelegate(base.WriteError));
            if (exchangeRole.ImplicitRecipientWriteScope != (ScopeType)this.DataObject.RecipientWriteScope && !RbacScope.IsScopeTypeSmaller((ScopeType)this.DataObject.RecipientWriteScope, exchangeRole.ImplicitRecipientWriteScope))
            {
                this.WriteWarning(Strings.WriteScopeGreaterThanRoleScope(this.DataObject.RecipientWriteScope.ToString(), exchangeRole.Name, exchangeRole.ImplicitRecipientWriteScope.ToString()));
                this.DataObject.CustomRecipientWriteScope = null;
                this.DataObject.RecipientWriteScope       = (RecipientWriteScopeType)exchangeRole.ImplicitRecipientWriteScope;
            }
            if (base.Fields.IsModified(RbacCommonParameters.ParameterCustomConfigWriteScope))
            {
                if (this.CustomConfigWriteScope == null)
                {
                    this.DataObject.ConfigWriteScope       = (ConfigWriteScopeType)exchangeRole.ImplicitConfigWriteScope;
                    this.DataObject.CustomConfigWriteScope = null;
                }
                else
                {
                    this.DataObject.ConfigWriteScope = ConfigWriteScopeType.CustomConfigScope;
                    ManagementScope andValidateConfigScope = RoleHelper.GetAndValidateConfigScope(this.CustomConfigWriteScope, this.ConfigurationSession, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ManagementScope>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    if (andValidateConfigScope.Exclusive)
                    {
                        base.WriteError(new ArgumentException(Strings.ErrorScopeExclusive(andValidateConfigScope.Id.ToString(), RbacCommonParameters.ParameterCustomConfigWriteScope)), ErrorCategory.InvalidArgument, null);
                    }
                    this.DataObject.CustomConfigWriteScope = andValidateConfigScope.Id;
                    this.DataObject.ConfigWriteScope       = ((andValidateConfigScope.ScopeRestrictionType == ScopeRestrictionType.PartnerDelegatedTenantScope) ? ConfigWriteScopeType.PartnerDelegatedTenantScope : ConfigWriteScopeType.CustomConfigScope);
                }
            }
            else if (base.Fields.IsModified("ExclusiveConfigWriteScope"))
            {
                ManagementScope andValidateConfigScope2 = RoleHelper.GetAndValidateConfigScope(this.ExclusiveConfigWriteScope, this.ConfigurationSession, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ManagementScope>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
                if (!andValidateConfigScope2.Exclusive)
                {
                    base.WriteError(new ArgumentException(Strings.ErrorScopeNotExclusive(andValidateConfigScope2.Id.ToString(), "ExclusiveConfigWriteScope")), ErrorCategory.InvalidArgument, null);
                }
                this.DataObject.CustomConfigWriteScope = andValidateConfigScope2.Id;
                this.DataObject.ConfigWriteScope       = ConfigWriteScopeType.ExclusiveConfigScope;
            }
            if (exchangeRole.ImplicitConfigWriteScope != (ScopeType)this.DataObject.ConfigWriteScope && !RbacScope.IsScopeTypeSmaller((ScopeType)this.DataObject.ConfigWriteScope, exchangeRole.ImplicitConfigWriteScope))
            {
                this.WriteWarning(Strings.WriteScopeGreaterThanRoleScope(this.DataObject.CustomConfigWriteScope.ToString(), exchangeRole.Name, exchangeRole.ImplicitConfigWriteScope.ToString()));
                this.DataObject.CustomConfigWriteScope = null;
                this.DataObject.ConfigWriteScope       = (ConfigWriteScopeType)exchangeRole.ImplicitConfigWriteScope;
            }
            RoleHelper.HierarchyRoleAssignmentChecking(this.DataObject, base.ExchangeRunspaceConfig, this.ConfigurationSession, base.ExecutingUserOrganizationId, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), !this.Enabled);
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }