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); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); if (base.ParameterSetName == "ValidateOnly" || this.needListMatchingUser) { base.WriteObject(this.matchedUsers, true); } else if (this.Archive) { if (!this.Force && this.User == null && !base.ShouldContinue(Strings.ComfirmConnectToMatchingUser(this.userToConnect.Identity.ToString(), this.userToConnect.Alias))) { TaskLogger.LogExit(); return; } ConnectMailbox.ConnectArchiveCore(this.userToConnect, this.DataObject.MailboxGuid, base.ParameterSetName, this.RecipientSession, this.TenantConfigurationSession, (MapiAdministrationSession)base.DataSession, this.alias, this.linkedUserSid, this.databaseLocationInfo, this.OwnerMailboxDatabase, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); } else { Organization orgContainer = this.TenantConfigurationSession.GetOrgContainer(); if (this.DataObject.MailboxType != StoreMailboxType.Private) { if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid == Guid.Empty) { if (this.DataObject.MailboxType == StoreMailboxType.PublicFolderSecondary) { this.WriteWarning(Strings.WarningPromotingSecondaryToPrimary); } } else if (this.DataObject.MailboxType == StoreMailboxType.PublicFolderPrimary) { this.WriteWarning(Strings.WarningConnectingPrimaryAsSecondary); } } if (!this.Force && this.User == null && !base.ShouldContinue(Strings.ComfirmConnectToMatchingUser(this.userToConnect.Identity.ToString(), this.alias))) { TaskLogger.LogExit(); return; } if (this.elcPolicyId != null && !this.Force && !this.ManagedFolderMailboxPolicyAllowed.IsPresent && !base.ShouldContinue(Strings.ConfirmManagedFolderMailboxPolicyAllowed(this.userToConnect.Identity.ToString()))) { TaskLogger.LogExit(); return; } if (!base.IsProvisioningLayerAvailable) { base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), ErrorCategory.InvalidOperation, null); } ADObjectId roleAssignmentPolicyId = null; RoleAssignmentPolicy roleAssignmentPolicy = RecipientTaskHelper.FindDefaultRoleAssignmentPolicy(this.TenantConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), Strings.ErrorDefaultRoleAssignmentPolicyNotUnique, Strings.ErrorDefaultRoleAssignmentPolicyNotFound); if (roleAssignmentPolicy != null) { roleAssignmentPolicyId = (ADObjectId)roleAssignmentPolicy.Identity; } ConnectMailbox.ConnectMailboxCore(this.userToConnect, this.DataObject.MailboxGuid, this.DataObject.MailboxType, this.DataObject.LegacyDN, base.ParameterSetName, true, this.RecipientSession, (MapiAdministrationSession)base.DataSession, this.alias, this.linkedUserSid, this.databaseLocationInfo, this.OwnerMailboxDatabase, this.elcPolicyId, this.retentionPolicyId, this.mobilePolicyId, this.addressBookPolicyId, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning), roleAssignmentPolicyId, this); if (this.DataObject.MailboxType != StoreMailboxType.Private && orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid == Guid.Empty) { orgContainer.DefaultPublicFolderMailbox = orgContainer.DefaultPublicFolderMailbox.Clone(); orgContainer.DefaultPublicFolderMailbox.SetHierarchyMailbox(this.DataObject.MailboxGuid, PublicFolderInformation.HierarchyType.MailboxGuid); this.TenantConfigurationSession.Save(orgContainer); MailboxTaskHelper.PrepopulateCacheForMailbox(this.OwnerMailboxDatabase, this.databaseLocationInfo.ServerFqdn, this.userToConnect.OrganizationId, this.DataObject.LegacyDN, this.DataObject.MailboxGuid, this.TenantConfigurationSession.LastUsedDc, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } } TaskLogger.LogExit(); }
private RoleAssignmentPolicy FindDefaultRoleAssignmentPolicy() { return(RecipientTaskHelper.FindDefaultRoleAssignmentPolicy(this.configurationSession, new Task.ErrorLoggerDelegate(base.WriteError), Strings.ErrorDefaultRoleAssignmentPolicyNotUnique, Strings.ErrorDefaultRoleAssignmentPolicyNotFound)); }