protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.Identity }); ADSystemAttendantMailbox dataObject = this.DataObject; if (string.IsNullOrEmpty(dataObject.DisplayName)) { dataObject.DisplayName = dataObject.Name; } ((IRecipientSession)base.DataSession).UseConfigNC = true; if (string.IsNullOrEmpty(this.DataObject.LegacyExchangeDN)) { string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "/o={0}/ou={1}/cn=Recipients", new object[] { this.ConfigurationSession.GetOrgContainerId().Name, ((ITopologyConfigurationSession)this.ConfigurationSession).GetAdministrativeGroupId().Name }); this.DataObject.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, null); } if (base.IsProvisioningLayerAvailable) { ProvisioningLayer.UpdateAffectedIConfigurable(this, this.ConvertDataObjectToPresentationObject(dataObject), false); } else { base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), ErrorCategory.InvalidOperation, null); } base.InternalProcessRecord(); TaskLogger.LogExit(); }
protected override void PrepareRecipientObject(ADMicrosoftExchangeRecipient dataObject) { this.DataObject = dataObject; dataObject.HiddenFromAddressListsEnabled = true; dataObject.EmailAddressPolicyEnabled = true; dataObject.Name = ADMicrosoftExchangeRecipient.DefaultName; dataObject.Alias = ADMicrosoftExchangeRecipient.DefaultName; dataObject.SetId(ADMicrosoftExchangeRecipient.GetDefaultId(this.ConfigurationSession)); dataObject.ObjectCategory = base.PartitionConfigSession.SchemaNamingContext.GetChildId("ms-Exch-Exchange-Server-Recipient"); if (string.IsNullOrEmpty(dataObject.LegacyExchangeDN)) { string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "/o={0}/ou={1}/cn=Recipients", new object[] { base.RootOrgGlobalConfigSession.GetOrgContainerId().Name, base.RootOrgGlobalConfigSession.GetAdministrativeGroupId().Name }); dataObject.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, dataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique)); } AcceptedDomain defaultAcceptedDomain = this.ConfigurationSession.GetDefaultAcceptedDomain(); if (defaultAcceptedDomain == null) { base.WriteError(new InvalidOperationException(Strings.ErrorNoDefaultAcceptedDomainFound(base.CurrentOrganizationId.ToString())), ErrorCategory.InvalidOperation, null); } dataObject.EmailAddresses.Add(new SmtpProxyAddress(dataObject.Alias + "@" + defaultAcceptedDomain.DomainName.Domain.ToString(), true)); dataObject.DeliverToMailboxAndForward = false; dataObject.OrganizationId = base.CurrentOrganizationId; }
private void ProcessMailboxTransportServerRole(bool isMailboxTransportServer, ITopologyConfigurationSession scSession, ADObjectId configContainerId) { ADObjectId childId = configContainerId.GetChildId("Mailbox"); IConfigurable[] array = base.DataSession.Find <MailboxTransportServer>(null, childId, true, null); if (isMailboxTransportServer) { if (array.Length == 0) { MailboxTransportServer mailboxTransportServer = new MailboxTransportServer(); mailboxTransportServer.NetworkAddress = this.DataObject.NetworkAddress; mailboxTransportServer.Name = "Mailbox"; mailboxTransportServer.Edition = ServerEditionType.StandardEvaluation; mailboxTransportServer.AdminDisplayVersion = ConfigurationContext.Setup.InstalledVersion; mailboxTransportServer.VersionNumber = SystemConfigurationTasksHelper.GenerateVersionNumber(ConfigurationContext.Setup.InstalledVersion); mailboxTransportServer.ExchangeLegacyDN = LegacyDN.GenerateLegacyDN(Server.GetParentLegacyDN(scSession), mailboxTransportServer); mailboxTransportServer.CurrentServerRole = ServerRole.Mailbox; mailboxTransportServer.SetId(childId); base.DataSession.Save(mailboxTransportServer); return; } } else if (array.Length > 0) { base.DataSession.Delete(array[0]); } }
protected override IConfigurable PrepareDataObject() { base.PrepareDataObject(); ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession; this.DataObject.Edition = ServerEditionType.StandardEvaluation; this.DataObject.AdminDisplayVersion = ConfigurationContext.Setup.InstalledVersion; this.DataObject.VersionNumber = SystemConfigurationTasksHelper.GenerateVersionNumber(ConfigurationContext.Setup.InstalledVersion); this.DataObject.MailboxRelease = MailboxRelease.E15; if (string.IsNullOrEmpty(this.Name)) { string localComputerFqdn = NativeHelpers.GetLocalComputerFqdn(true); int num = localComputerFqdn.IndexOf('.'); this.DataObject.Name = ((num == -1) ? localComputerFqdn : localComputerFqdn.Substring(0, num)); NewExchangeServer.TcpNetworkAddress value = new NewExchangeServer.TcpNetworkAddress(NetworkProtocol.TcpIP, localComputerFqdn); this.DataObject.NetworkAddress = new NetworkAddressCollection(value); } this.DataObject.FaultZone = "FaultZone1"; ADObjectId childId = topologyConfigurationSession.GetAdministrativeGroupId().GetChildId("Servers"); ADObjectId childId2 = childId.GetChildId(this.DataObject.Name); this.DataObject.SetId(childId2); this.DataObject.ExchangeLegacyDN = LegacyDN.GenerateLegacyDN(Server.GetParentLegacyDN(topologyConfigurationSession), this.DataObject); using (RegistryKey registryKey = RegistryUtil.OpenRemoteBaseKey(RegistryHive.LocalMachine, NativeHelpers.GetLocalComputerFqdn(true))) { using (RegistryKey registryKey2 = registryKey.OpenSubKey(NewExchangeServer.EdgeKeyName)) { if (registryKey2 == null && this.IsDomainJoined()) { this.SetServerSiteInformation(topologyConfigurationSession); } } } return(this.DataObject); }
private ExchangeConfigurationUnit CreateOrgConfigurationContainer(ADObjectId enclosureContainerId, OrganizationId targetSharedOrgId, string externalDirectoryOrganizationId, string programId, string offerId, bool isDehydrated, bool isStaticConfigurationShared, string sourceForestFqdn, Guid sourceObjectGuid, Guid sourceObjectExchangeObjectId, ITenantConfigurationSession targetForestTenantSession) { ExchangeConfigurationUnit exchangeConfigurationUnit = new ExchangeConfigurationUnit(); exchangeConfigurationUnit.SetId(enclosureContainerId.GetChildId("Configuration")); exchangeConfigurationUnit.ExternalDirectoryOrganizationId = externalDirectoryOrganizationId; exchangeConfigurationUnit.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationStarted; exchangeConfigurationUnit.OrganizationStatus = OrganizationStatus.PendingArrival; exchangeConfigurationUnit.RelocationSourceForestRaw = sourceForestFqdn; exchangeConfigurationUnit.ProgramId = programId; exchangeConfigurationUnit.OfferId = offerId; exchangeConfigurationUnit.IsDehydrated = isDehydrated; exchangeConfigurationUnit.IsStaticConfigurationShared = isStaticConfigurationShared; exchangeConfigurationUnit.CorrelationId = sourceObjectGuid; exchangeConfigurationUnit.ExchangeObjectId = sourceObjectExchangeObjectId; if (targetSharedOrgId != null) { exchangeConfigurationUnit.SupportedSharedConfigurations = new MultiValuedProperty <ADObjectId>(); exchangeConfigurationUnit.SupportedSharedConfigurations.Add(targetSharedOrgId.ConfigurationUnit); } exchangeConfigurationUnit.Name = "Configuration"; ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(targetForestTenantSession.SessionSettings.PartitionId), 546, "CreateOrgConfigurationContainer", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs"); string parentLegacyDN = string.Format("{0}{1}", topologyConfigurationSession.GetAdministrativeGroup().LegacyExchangeDN, this.GetRelativeDNTillConfigurationUnits(exchangeConfigurationUnit.Id)); exchangeConfigurationUnit.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, exchangeConfigurationUnit); targetForestTenantSession.Save(exchangeConfigurationUnit); return(exchangeConfigurationUnit); }
protected override IConfigurable PrepareDataObject() { IConfigurationSession configurationSession = base.DataSession as IConfigurationSession; bool useConfigNC = configurationSession.UseConfigNC; configurationSession.UseConfigNC = false; try { this.ou = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.OrganizationalUnit, configurationSession, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.OrganizationalUnit.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.OrganizationalUnit.ToString()))); this.ouOriginatingServer = this.ou.OriginatingServer; } finally { configurationSession.UseConfigNC = useConfigNC; } ExchangeConfigurationUnit exchangeConfigurationUnit = (ExchangeConfigurationUnit)base.PrepareDataObject(); ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 290, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\DirectorySetup\\InstallTenantConfigurationContainerTask.cs"); string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}{1}", new object[] { topologyConfigurationSession.GetAdministrativeGroup().LegacyExchangeDN, this.GetRelativeDNTillConfigurationUnits(exchangeConfigurationUnit.Id) }); exchangeConfigurationUnit.Name = exchangeConfigurationUnit.Id.Rdn.UnescapedName; exchangeConfigurationUnit.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, exchangeConfigurationUnit); exchangeConfigurationUnit.OrganizationStatus = OrganizationStatus.PendingCompletion; if (!string.IsNullOrEmpty(this.ServicePlan)) { exchangeConfigurationUnit.ServicePlan = this.ServicePlan; } if (!string.IsNullOrEmpty(this.ProgramId) && !string.IsNullOrEmpty(this.OfferId)) { exchangeConfigurationUnit.ResellerId = string.Format("{0}.{1}", this.ProgramId, this.OfferId); if (this.CreateSharedConfiguration) { this.DataObject.SharedConfigurationInfo = SharedConfigurationInfo.FromInstalledVersion(this.ProgramId, this.OfferId); } } if (string.IsNullOrEmpty(exchangeConfigurationUnit.ExternalDirectoryOrganizationId)) { exchangeConfigurationUnit.ExternalDirectoryOrganizationId = Guid.NewGuid().ToString(); } return(exchangeConfigurationUnit); }
protected override IConfigurable PrepareDataObject() { this.DataObject = (OfflineAddressBook)base.PrepareDataObject(); MultiValuedProperty <OfflineAddressBookVersion> multiValuedProperty = new MultiValuedProperty <OfflineAddressBookVersion>(); multiValuedProperty.Add(OfflineAddressBookVersion.Version4); this.DataObject.Versions = multiValuedProperty; this.DataObject.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList; this.DataObject.UpdateRawMapiAttributes(false); if (base.Fields.IsModified("GeneratingMailbox")) { this.DataObject.GeneratingMailbox = OfflineAddressBookTaskUtility.ValidateGeneratingMailbox(base.TenantGlobalCatalogSession, this.GeneratingMailbox, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADUser>), this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError)); } this.DataObject.AddressLists = OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError)); this.DataObject.PublicFolderDistributionEnabled = false; this.DataObject.PublicFolderDatabase = null; if (this.VirtualDirectories != null && this.VirtualDirectories.Length != 0) { this.DataObject.VirtualDirectories = OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, this.VirtualDirectories, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError)); } if (base.Fields.IsModified("GlobalWebDistributionEnabled")) { this.DataObject.GlobalWebDistributionEnabled = this.GlobalWebDistributionEnabled; } if (base.Fields.IsModified("ShadowMailboxDistributionEnabled")) { this.DataObject.ShadowMailboxDistributionEnabled = this.ShadowMailboxDistributionEnabled; } this.DataObject.Server = ((IConfigurationSession)base.DataSession).GetOrgContainerId().GetDescendantId(this.DataObject.ParentPath); if (!this.DataObject.IsModified(OfflineAddressBookSchema.IsDefault) && ((IConfigurationSession)base.DataSession).Find <OfflineAddressBook>(null, QueryScope.SubTree, null, null, 1).Length == 0) { this.DataObject.IsDefault = true; } this.DataObject.SetId((IConfigurationSession)base.DataSession, base.Name); string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/cn=addrlists/cn=oabs", new object[] { ((IConfigurationSession)base.DataSession).GetOrgContainer().LegacyExchangeDN }); this.DataObject[OfflineAddressBookSchema.ExchangeLegacyDN] = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique)); OfflineAddressBookTaskUtility.WarnForNoDistribution(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning)); return(this.DataObject); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (string.IsNullOrEmpty(this.DataObject.LegacyExchangeDN)) { AdministrativeGroup administrativeGroup = base.GlobalConfigSession.GetAdministrativeGroup(); string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/cn=Recipients", new object[] { administrativeGroup.LegacyExchangeDN }); this.DataObject.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique)); } if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.EmailAddressPolicy.Enabled) { this.DataObject.EmailAddressPolicyEnabled = false; } DistributionGroupTaskHelper.CheckModerationInMixedEnvironment(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), Strings.WarningLegacyExchangeServer); TaskLogger.LogExit(); }
internal static ADSystemMailbox SaveSystemMailbox(MailboxDatabase mdb, Server owningServer, ADObjectId rootOrgContainerId, ITopologyConfigurationSession configSession, IRecipientSession recipientSession, ADObjectId[] forcedReplicationSites, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskVerboseLoggingDelegate writeVerbose) { TaskLogger.LogEnter(); bool useConfigNC = configSession.UseConfigNC; bool useGlobalCatalog = configSession.UseGlobalCatalog; string text = "SystemMailbox" + mdb.Guid.ToString("B"); SecurityIdentifier securityIdentifier = new SecurityIdentifier("SY"); ADSystemMailbox adsystemMailbox = new ADSystemMailbox(); adsystemMailbox.StampPersistableDefaultValues(); adsystemMailbox.Name = text; adsystemMailbox.DisplayName = text; adsystemMailbox.Alias = text; adsystemMailbox.HiddenFromAddressListsEnabled = true; adsystemMailbox.Database = mdb.Id; if (owningServer == null) { throw new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString())); } adsystemMailbox.ServerLegacyDN = owningServer.ExchangeLegacyDN; adsystemMailbox.ExchangeGuid = Guid.NewGuid(); AcceptedDomain defaultAcceptedDomain = configSession.GetDefaultAcceptedDomain(); if (defaultAcceptedDomain == null || defaultAcceptedDomain.DomainName == null || defaultAcceptedDomain.DomainName.Domain == null) { throw new ManagementObjectNotFoundException(Strings.ErrorNoDefaultAcceptedDomainFound(mdb.Identity.ToString())); } adsystemMailbox.EmailAddresses.Add(ProxyAddress.Parse("SMTP:" + adsystemMailbox.Alias + "@" + defaultAcceptedDomain.DomainName.Domain.ToString())); adsystemMailbox.WindowsEmailAddress = adsystemMailbox.PrimarySmtpAddress; adsystemMailbox.SendModerationNotifications = TransportModerationNotificationFlags.Never; Organization organization = configSession.Read <Organization>(rootOrgContainerId); if (organization == null) { throw new ManagementObjectNotFoundException(Strings.ErrorOrganizationNotFound(rootOrgContainerId.Name)); } string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/ou={1}/cn=Recipients", new object[] { organization.LegacyExchangeDN, configSession.GetAdministrativeGroupId().Name }); adsystemMailbox.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, adsystemMailbox); ADComputer adcomputer; try { configSession.UseConfigNC = false; configSession.UseGlobalCatalog = true; adcomputer = configSession.FindComputerByHostName(owningServer.Name); } finally { configSession.UseConfigNC = useConfigNC; configSession.UseGlobalCatalog = useGlobalCatalog; } if (adcomputer == null) { throw new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString())); } ADObjectId adobjectId = adcomputer.Id.DomainId; adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects"); adsystemMailbox.SetId(adobjectId.GetChildId(text)); GenericAce[] aces = new GenericAce[] { new CommonAce(AceFlags.None, AceQualifier.AccessAllowed, 131075, securityIdentifier, false, null) }; DirectoryCommon.SetAclOnAlternateProperty(adsystemMailbox, aces, ADSystemAttendantMailboxSchema.ExchangeSecurityDescriptor, securityIdentifier, securityIdentifier); recipientSession.LinkResolutionServer = mdb.OriginatingServer; bool enforceDefaultScope = recipientSession.EnforceDefaultScope; try { writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox))); recipientSession.EnforceDefaultScope = false; recipientSession.Save(adsystemMailbox); } catch (ADConstraintViolationException ex) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ex.Server, false, ConsistencyMode.PartiallyConsistent, configSession.SessionSettings, 705, "SaveSystemMailbox", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\NewMailboxDatabase.cs"); if (!tenantOrTopologyConfigurationSession.ReplicateSingleObjectToTargetDC(mdb, ex.Server)) { throw; } writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox))); recipientSession.Save(adsystemMailbox); } finally { writeVerbose(TaskVerboseStringHelper.GetSourceVerboseString(recipientSession)); recipientSession.EnforceDefaultScope = enforceDefaultScope; } if (forcedReplicationSites != null) { DagTaskHelper.ForceReplication(recipientSession, adsystemMailbox, forcedReplicationSites, mdb.Name, writeWarning, writeVerbose); } TaskLogger.LogExit(); return(adsystemMailbox); }