コード例 #1
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADRecipient adrecipient = (ADRecipient)base.PrepareDataObject();

            if (base.IsProvisioningLayerAvailable)
            {
                Fqdn value = (Fqdn)base.UserSpecifiedParameters["DomainController"];
                try
                {
                    base.UserSpecifiedParameters["DomainController"] = this.globalCatalog;
                    ProvisioningLayer.UpdateAffectedIConfigurable(this, RecipientTaskHelper.ConvertRecipientToPresentationObject(adrecipient), false);
                    goto IL_82;
                }
                finally
                {
                    base.UserSpecifiedParameters["DomainController"] = value;
                }
            }
            base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), (ErrorCategory)1012, null);
IL_82:
            if (RecipientType.UserMailbox == adrecipient.RecipientType)
            {
                ADUser aduser = (ADUser)adrecipient;
                if (string.IsNullOrEmpty(aduser.ServerLegacyDN))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Mailbox).Name, adrecipient.Identity.ToString(), MailEnabledRecipientSchema.LegacyExchangeDN.Name)), (ErrorCategory)1009, this.Identity);
                }
                Server server = this.configurationSession.FindServerByLegacyDN(aduser.ServerLegacyDN);
                if (server != null)
                {
                    if (!server.IsExchange2007OrLater)
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorCannotUpdateLegacyMailbox(this.Identity.ToString())), (ErrorCategory)1010, this.Identity);
                    }
                    else if (RecipientTaskHelper.IsE15OrLater(server.VersionNumber))
                    {
                        if (adrecipient.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
                        {
                            adrecipient.SetExchangeVersion(ExchangeObjectVersion.Exchange2012);
                        }
                    }
                    else if (server.IsE14OrLater)
                    {
                        if (adrecipient.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010))
                        {
                            adrecipient.SetExchangeVersion(ExchangeObjectVersion.Exchange2010);
                        }
                    }
                    else if (adrecipient.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2007))
                    {
                        adrecipient.SetExchangeVersion(ExchangeObjectVersion.Exchange2007);
                    }
                }
                SetMailboxBase <MailboxIdParameter, Mailbox> .StampMailboxTypeDetails(adrecipient, true);

                MailboxTaskHelper.StampMailboxRecipientDisplayType(adrecipient);
                if (server != null && server.IsE14OrLater)
                {
                    NetID netID = aduser.NetID;
                    if (netID != null)
                    {
                        aduser.NetID = netID;
                    }
                }
                if (aduser.RoleAssignmentPolicy == null && RecipientTypeDetails.None == (aduser.RecipientTypeDetails & (RecipientTypeDetails.PublicFolder | RecipientTypeDetails.SystemMailbox | RecipientTypeDetails.ArbitrationMailbox | RecipientTypeDetails.DiscoveryMailbox | RecipientTypeDetails.AuditLogMailbox)))
                {
                    RoleAssignmentPolicy roleAssignmentPolicy = RecipientTaskHelper.FindDefaultRoleAssignmentPolicy(RecipientTaskHelper.GetTenantLocalConfigSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId, base.RootOrgContainerId), new Task.ErrorLoggerDelegate(base.WriteError), Strings.ErrorDefaultRoleAssignmentPolicyNotUnique, Strings.ErrorDefaultRoleAssignmentPolicyNotFound);
                    if (roleAssignmentPolicy != null)
                    {
                        aduser.RoleAssignmentPolicy = (ADObjectId)roleAssignmentPolicy.Identity;
                    }
                }
            }
            TaskLogger.LogExit();
            return(adrecipient);
        }