protected override IConfigurable PrepareDataObject() { SmtpSendConnectorConfig smtpSendConnectorConfig = (SmtpSendConnectorConfig)base.PrepareDataObject(); try { this.localServer = ((ITopologyConfigurationSession)base.DataSession).ReadLocalServer(); } catch (TransientException exception) { base.WriteError(exception, ErrorCategory.ResourceUnavailable, this.DataObject); } if (base.Fields.IsModified("SourceTransportServers")) { if (this.SourceTransportServers != null) { smtpSendConnectorConfig.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, null); if (smtpSendConnectorConfig.SourceTransportServers.Count > 0) { ManageSendConnectors.SetConnectorHomeMta(smtpSendConnectorConfig, (IConfigurationSession)base.DataSession); } } else { smtpSendConnectorConfig.SourceTransportServers = null; } } return(smtpSendConnectorConfig); }
protected override IConfigurable PrepareDataObject() { DeliveryAgentConnector deliveryAgentConnector = (DeliveryAgentConnector)base.PrepareDataObject(); if (!MultiValuedPropertyBase.IsNullOrEmpty(this.SourceTransportServers)) { deliveryAgentConnector.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, null); } else { Server server = null; try { server = ((ITopologyConfigurationSession)base.DataSession).ReadLocalServer(); } catch (TransientException exception) { base.WriteError(exception, ErrorCategory.ResourceUnavailable, this.DataObject); } if (server != null && server.IsHubTransportServer && server.IsExchange2007OrLater) { deliveryAgentConnector.SourceTransportServers = new MultiValuedProperty <ADObjectId>(false, SendConnectorSchema.SourceTransportServers, new ADObjectId[] { server.Id }); } } if (!MultiValuedPropertyBase.IsNullOrEmpty(deliveryAgentConnector.SourceTransportServers)) { ManageSendConnectors.SetConnectorHomeMta(deliveryAgentConnector, (IConfigurationSession)base.DataSession); } ManageSendConnectors.SetConnectorId(deliveryAgentConnector, ((ITopologyConfigurationSession)base.DataSession).GetRoutingGroupId()); return(deliveryAgentConnector); }
public static void RemoveServersFromGroup(IList<ADObjectId> serverIds, Guid groupGuid, ITopologyConfigurationSession configSession, ManageSendConnectors.ThrowTerminatingErrorDelegate throwDelegate) { TaskLogger.LogEnter(); IRecipientSession recipSession; ITopologyConfigurationSession gcSession; ADGroup wellKnownGroup = ManageSendConnectors.GetWellKnownGroup(groupGuid, configSession, throwDelegate, out recipSession, out gcSession); ManageSendConnectors.RemoveServersFromGroup(serverIds, wellKnownGroup, recipSession, gcSession, throwDelegate); TaskLogger.LogExit(); }
protected override IConfigurable PrepareDataObject() { SmtpSendConnectorConfig smtpSendConnectorConfig = (SmtpSendConnectorConfig)base.PrepareDataObject(); try { this.localServer = ((ITopologyConfigurationSession)base.DataSession).ReadLocalServer(); } catch (TransientException exception) { base.WriteError(exception, ErrorCategory.ResourceUnavailable, this.DataObject); } this.isHubTransportServer = (this.localServer != null && this.localServer.IsHubTransportServer); bool isEdgeConnector = this.localServer != null && this.localServer.IsEdgeServer; if (this.SourceTransportServers != null) { smtpSendConnectorConfig.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, delegate(IConfigurable configObject) { Server server = (Server)configObject; isEdgeConnector |= server.IsEdgeServer; return(server); }); } MultiValuedProperty <ADObjectId> multiValuedProperty = this.DataObject.SourceTransportServers; if (this.localServer != null && this.localServer.IsHubTransportServer && (multiValuedProperty == null || multiValuedProperty.Count == 0)) { multiValuedProperty = new MultiValuedProperty <ADObjectId>(false, SendConnectorSchema.SourceTransportServers, new ADObjectId[] { this.localServer.Id }); this.DataObject.SourceTransportServers = multiValuedProperty; } if (multiValuedProperty != null && multiValuedProperty.Count > 0) { ManageSendConnectors.SetConnectorHomeMta(this.DataObject, (IConfigurationSession)base.DataSession); } if (!this.DataObject.IsModified(SendConnectorSchema.MaxMessageSize)) { if (this.IsUsageSet && this.usage == NewSendConnector.UsageType.Internal) { this.MaxMessageSize = Unlimited <ByteQuantifiedSize> .UnlimitedValue; } else { this.MaxMessageSize = ByteQuantifiedSize.FromMB(35UL); } } if (!this.DataObject.IsModified(SmtpSendConnectorConfigSchema.UseExternalDNSServersEnabled) && isEdgeConnector) { this.UseExternalDNSServersEnabled = true; } ManageSendConnectors.SetConnectorId(smtpSendConnectorConfig, ((ITopologyConfigurationSession)base.DataSession).GetRoutingGroupId()); return(smtpSendConnectorConfig); }
protected override void InternalProcessRecord() { ForeignConnector dataObject = this.DataObject; if (dataObject.IsScopedConnector) { ManageSendConnectors.AdjustAddressSpaces(dataObject); } base.InternalProcessRecord(); ManageSendConnectors.UpdateGwartLastModified((ITopologyConfigurationSession)base.DataSession, this.DataObject.SourceRoutingGroup, new ManageSendConnectors.ThrowTerminatingErrorDelegate(base.WriteError)); }
protected override void InternalProcessRecord() { DeliveryAgentConnector dataObject = this.DataObject; if (this.currentlyEnabled && !dataObject.Enabled && !this.force && !base.ShouldContinue(Strings.ConfirmationMessageDisableSendConnector)) { return; } ManageSendConnectors.AdjustAddressSpaces(dataObject); base.InternalProcessRecord(); ManageSendConnectors.UpdateGwartLastModified((ITopologyConfigurationSession)base.DataSession, this.DataObject.SourceRoutingGroup, new ManageSendConnectors.ThrowTerminatingErrorDelegate(base.WriteError)); }
public static void UpdateGwartLastModified(ITopologyConfigurationSession configSession, ADObjectId sourceRoutingGroup, ManageSendConnectors.ThrowTerminatingErrorDelegate throwDelegate) { TaskLogger.LogEnter(); if (ManageSendConnectors.IsE12RoutingGroup(sourceRoutingGroup)) { configSession.UpdateGwartLastModified(); TaskLogger.Trace("Updated E12 Legacy GWART {0}", new object[] { LegacyGwart.DefaultName }); } TaskLogger.LogExit(); }
protected override IConfigurable PrepareDataObject() { ForeignConnector foreignConnector = (ForeignConnector)base.PrepareDataObject(); if (!MultiValuedPropertyBase.IsNullOrEmpty(this.SourceTransportServers)) { foreignConnector.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, null); if (this.SourceTransportServers.Count > 0) { ManageSendConnectors.SetConnectorHomeMta(foreignConnector, (IConfigurationSession)base.DataSession); } } return(foreignConnector); }
public static void ValidateSourceServers(ForeignConnector connector, IConfigurationSession session, Task task) { ADObjectId sourceRoutingGroup = connector.SourceRoutingGroup; bool flag; bool flag2; LocalizedException ex = ManageSendConnectors.ValidateTransportServers(session, connector, ref sourceRoutingGroup, false, true, task, out flag, out flag2); if (ex != null) { throw ex; } if (flag2) { throw new MultiSiteSourceServersException(); } }
private static LocalizedException ValidateSourceServers(SmtpSendConnectorConfig connector, IConfigurationSession session, Server localServer, Task task, out bool edgeConnector, out bool multiSiteConnector) { edgeConnector = false; multiSiteConnector = false; MultiValuedProperty <ADObjectId> sourceTransportServers = connector.SourceTransportServers; if (localServer == null || !localServer.IsEdgeServer) { ADObjectId sourceRoutingGroup = connector.SourceRoutingGroup; return(ManageSendConnectors.ValidateTransportServers(session, connector, ref sourceRoutingGroup, true, true, task, out edgeConnector, out multiSiteConnector)); } if (sourceTransportServers != null && sourceTransportServers.Count > 0) { return(new SendConnectorSourceServersSetForEdgeException()); } edgeConnector = true; return(null); }
protected override void InternalValidate() { base.InternalValidate(); ADObjectId sourceRoutingGroup = this.DataObject.SourceRoutingGroup; bool flag; bool flag2; LocalizedException ex = ManageSendConnectors.ValidateTransportServers((IConfigurationSession)base.DataSession, this.DataObject, ref sourceRoutingGroup, true, true, this, out flag, out flag2); if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject); return; } if (flag2) { this.WriteWarning(Strings.WarningMultiSiteSourceServers); } }
protected override void InternalProcessRecord() { base.InternalProcessRecord(); Server server = null; try { server = ((ITopologyConfigurationSession)base.DataSession).FindLocalServer(); } catch (ComputerNameNotCurrentlyAvailableException) { } catch (LocalServerNotFoundException) { } if (server == null || !server.IsEdgeServer) { ManageSendConnectors.UpdateGwartLastModified((ITopologyConfigurationSession)base.DataSession, base.DataObject.SourceRoutingGroup, new ManageSendConnectors.ThrowTerminatingErrorDelegate(base.ThrowTerminatingError)); } }
protected override IConfigurable PrepareDataObject() { DeliveryAgentConnector deliveryAgentConnector = (DeliveryAgentConnector)base.PrepareDataObject(); if (base.Fields.IsModified("SourceTransportServers")) { if (this.SourceTransportServers != null) { deliveryAgentConnector.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, null); if (deliveryAgentConnector.SourceTransportServers.Count > 0) { ManageSendConnectors.SetConnectorHomeMta(deliveryAgentConnector, (IConfigurationSession)base.DataSession); } } else { deliveryAgentConnector.SourceTransportServers = null; } } return(deliveryAgentConnector); }
protected override void InternalValidate() { base.InternalValidate(); if (TopologyProvider.IsAdamTopology()) { base.WriteError(new LocalizedException(Strings.CannotRunDeliveryAgentConnectorTaskOnEdge), ErrorCategory.InvalidOperation, null); } ADObjectId sourceRoutingGroup = this.DataObject.SourceRoutingGroup; bool flag; bool flag2; LocalizedException ex = ManageSendConnectors.ValidateTransportServers((IConfigurationSession)base.DataSession, this.DataObject, ref sourceRoutingGroup, false, true, this, out flag, out flag2); if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject); return; } if (flag2) { this.WriteWarning(Strings.WarningMultiSiteSourceServers); } }
protected override void InternalProcessRecord() { if (this.dashDashConnector && (this.DataObject.IsChanged(MailGatewaySchema.AddressSpaces) || this.DataObject.IsChanged(SmtpSendConnectorConfigSchema.SmartHostsString)) && !this.force && !base.ShouldContinue(Strings.ConfirmationMessageSetEdgeSyncSendConnectorAddressSpaceOrSmartHosts)) { return; } Exception ex = null; if (this.DataObject.DNSRoutingEnabled) { ex = NewSendConnector.CheckDNSAndSmartHostParameters(this.DataObject); if (ex == null) { ex = NewSendConnector.CheckDNSAndSmartHostAuthMechanismParameters(this.DataObject); } } if (ex == null) { ex = NewSendConnector.CheckTLSParameters(this.DataObject); } if (this.DataObject.TlsCertificateName != null) { ex = this.ValidateCertificateForSmtp(this.DataObject); } if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity); return; } NewSendConnector.ClearSmartHostsListIfNecessary(this.DataObject); NewSendConnector.SetSmartHostAuthMechanismIfNecessary(this.DataObject); ManageSendConnectors.AdjustAddressSpaces(this.DataObject); base.InternalProcessRecord(); if (!TopologyProvider.IsAdamTopology()) { ManageSendConnectors.UpdateGwartLastModified((ITopologyConfigurationSession)base.DataSession, this.DataObject.SourceRoutingGroup, new ManageSendConnectors.ThrowTerminatingErrorDelegate(base.ThrowTerminatingError)); } }
public static void RemoveServersFromGroup(IList<ADObjectId> serverIds, ADGroup group, IRecipientSession recipSession, ITopologyConfigurationSession gcSession, ManageSendConnectors.ThrowTerminatingErrorDelegate throwDelegate) { TaskLogger.LogEnter(); if (serverIds.Count == 0) { TaskLogger.LogExit(); return; } foreach (ADObjectId adobjectId in serverIds) { ADComputer computerObject = ManageSendConnectors.GetComputerObject(adobjectId.Name, gcSession, throwDelegate); if (group.Members.Contains(computerObject.Id)) { TaskLogger.Trace("Removing server '{0}' from group '{1}'", new object[] { adobjectId.Name, group.Name }); group.Members.Remove(computerObject.Id); } } recipSession.Save(group); TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { SmtpSendConnectorConfig dataObject = this.DataObject; if (!TopologyProvider.IsAdamTopology() && !dataObject.Enabled && !this.force && !base.ShouldContinue(Strings.ConfirmationMessageDisableSendConnector)) { return; } Exception ex = null; if (dataObject.DNSRoutingEnabled) { ex = NewSendConnector.CheckDNSAndSmartHostParameters(this.DataObject); if (ex == null) { ex = NewSendConnector.CheckDNSAndSmartHostAuthMechanismParameters(this.DataObject); } } if (ex == null) { ex = NewSendConnector.CheckTLSParameters(this.DataObject); } if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity); return; } NewSendConnector.ClearSmartHostsListIfNecessary(this.DataObject); NewSendConnector.SetSmartHostAuthMechanismIfNecessary(this.DataObject); if (dataObject.IsScopedConnector) { ManageSendConnectors.AdjustAddressSpaces(dataObject); } base.InternalProcessRecord(); ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession; SmtpSendConnectorConfig smtpSendConnectorConfig = null; try { smtpSendConnectorConfig = topologyConfigurationSession.Read <SmtpSendConnectorConfig>(this.DataObject.OriginalId); } catch (LocalizedException exception) { base.WriteError(exception, ErrorCategory.ReadError, this.DataObject); return; } RawSecurityDescriptor originalSecurityDescriptor = smtpSendConnectorConfig.ReadSecurityDescriptor(); RawSecurityDescriptor rawSecurityDescriptor = null; try { rawSecurityDescriptor = this.ConfigureDefaultSecurityDescriptor(originalSecurityDescriptor); } catch (LocalizedException exception2) { base.WriteError(exception2, ErrorCategory.InvalidOperation, this.DataObject); return; } if (rawSecurityDescriptor != null) { topologyConfigurationSession.SaveSecurityDescriptor(this.DataObject.OriginalId, rawSecurityDescriptor); } if (!TopologyProvider.IsAdamTopology()) { ManageSendConnectors.UpdateGwartLastModified(topologyConfigurationSession, this.DataObject.SourceRoutingGroup, new ManageSendConnectors.ThrowTerminatingErrorDelegate(base.ThrowTerminatingError)); } }
public static LocalizedException ValidateTransportServers(IConfigurationSession session, SendConnector sendConnector, ref ADObjectId routingGroupId, Task task, bool sourceValidation, out bool multiSiteConnector) { bool flag; return ManageSendConnectors.ValidateTransportServers(session, sendConnector, ref routingGroupId, false, sourceValidation, task, out flag, out multiSiteConnector); }
protected override void InternalProcessRecord() { base.InternalProcessRecord(); ManageSendConnectors.UpdateGwartLastModified((ITopologyConfigurationSession)base.DataSession, base.DataObject.SourceRoutingGroup, new ManageSendConnectors.ThrowTerminatingErrorDelegate(base.WriteError)); }
public static LocalizedException ValidateTransportServers(IConfigurationSession session, SendConnector connector, ref ADObjectId routingGroupId, bool allowEdgeServers, bool sourceValidation, Task task, out bool edgeConnector, out bool multiSiteConnector) { edgeConnector = false; multiSiteConnector = false; MultiValuedProperty<ADObjectId> sourceTransportServers = connector.SourceTransportServers; if (sourceTransportServers != null && sourceTransportServers.Count != 0) { bool flag = false; ADObjectId adobjectId = null; MultiValuedProperty<ADObjectId> multiValuedProperty = new MultiValuedProperty<ADObjectId>(); List<string> list = new List<string>(); foreach (ADObjectId adobjectId2 in sourceTransportServers) { if (adobjectId2 != null) { Server server = session.Read<Server>(adobjectId2); if (server == null) { list.Add(adobjectId2.Name); } else { if (adobjectId == null) { if (routingGroupId == null) { routingGroupId = ManageSendConnectors.GetServerRoutingGroup(server); if (routingGroupId == null) { return new SendConnectorUndefinedServerRgException(adobjectId2.Name); } } flag = ManageSendConnectors.IsE12RoutingGroup(routingGroupId); if (allowEdgeServers) { edgeConnector = server.IsEdgeServer; } adobjectId = server.ServerSite; } else if (!multiSiteConnector) { multiSiteConnector = !adobjectId.Equals(server.ServerSite); } if (!routingGroupId.Equals(server.HomeRoutingGroup)) { bool flag2 = false; if (!flag) { flag2 = true; } else if (server.HomeRoutingGroup != null) { flag2 = true; } else if (!server.IsExchange2007OrLater) { flag2 = true; } if (flag2) { return sourceValidation ? new SendConnectorWrongSourceServerRgException(adobjectId2.Name) : new SendConnectorWrongTargetServerRgException(adobjectId2.Name); } } if (flag) { if ((!server.IsEdgeServer || !allowEdgeServers) && !server.IsHubTransportServer) { return sourceValidation ? new SendConnectorWrongSourceServerRoleException(adobjectId2.Name) : new SendConnectorWrongTargetServerRoleException(adobjectId2.Name); } if (edgeConnector != server.IsEdgeServer) { return new SendConnectorMixedSourceServerRolesException(); } } multiValuedProperty.Add(adobjectId2); } } } if (multiValuedProperty.Count != 0) { if (multiValuedProperty.Count != connector.SourceTransportServers.Count) { connector.SourceTransportServers = multiValuedProperty; if (task != null) { task.WriteWarning(Strings.WarningSourceServersSkipped(string.Join(", ", list))); } } return null; } if (!sourceValidation) { return new SendConnectorValidTargetServerNotFoundException(); } return new SendConnectorValidSourceServerNotFoundException(); } if (!sourceValidation) { return new SendConnectorTargetServersNotSetException(); } return new SendConnectorSourceServersNotSetException(); }