public static void CheckTopology() { if (TopologyProvider.IsAdamTopology()) { throw new CannotRunForeignConnectorTaskOnEdgeException(); } }
public static ADDomain FindExternalDomain(string fqdn, NetworkCredential credential) { if (string.IsNullOrEmpty(fqdn)) { throw new ArgumentNullException("fqdn"); } if (credential == null) { throw new ArgumentNullException("credential"); } if (string.IsNullOrEmpty(credential.UserName)) { throw new ArgumentException("User name must be provided in the credential argument to perform this operation."); } ADServerInfo remoteServerFromDomainFqdn = TopologyProvider.GetInstance().GetRemoteServerFromDomainFqdn(fqdn, credential); IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(remoteServerFromDomainFqdn.Fqdn, true, ConsistencyMode.FullyConsistent, credential, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(Datacenter.IsMicrosoftHostedOnly(true) ? new PartitionId(remoteServerFromDomainFqdn.Fqdn) : PartitionId.LocalForest), 316, "FindExternalDomain", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADForest.cs"); tenantOrTopologyConfigurationSession.UseConfigNC = false; tenantOrTopologyConfigurationSession.EnforceDefaultScope = false; ADDomain[] array = tenantOrTopologyConfigurationSession.Find <ADDomain>(new ADObjectId(NativeHelpers.DistinguishedNameFromCanonicalName(fqdn)), QueryScope.Base, null, null, 1); if (array == null || array.Length <= 0) { throw new ADExternalException(DirectoryStrings.ExceptionADTopologyNoSuchDomain(fqdn)); } return(array[0]); }
public static ADForest GetForest(string forestFqdn, NetworkCredential credentials) { if (string.IsNullOrEmpty(forestFqdn)) { throw new ArgumentNullException("forestFqdn"); } if (ADForest.IsLocalForestFqdn(forestFqdn)) { if (credentials != null) { throw new ArgumentException("The use of credentials is not supported for the local forest '" + forestFqdn + "'"); } return(ADForest.GetLocalForest()); } else { PartitionId partitionId = new PartitionId(forestFqdn); if (ADAccountPartitionLocator.IsKnownPartition(partitionId)) { return(ADForest.GetForest(partitionId)); } ADServerInfo remoteServerFromDomainFqdn = TopologyProvider.GetInstance().GetRemoteServerFromDomainFqdn(forestFqdn, credentials); return(new ADForest(forestFqdn, remoteServerFromDomainFqdn.Fqdn, null, credentials, false)); } }
internal override Guid SelectDomainController(PartitionId partitionId) { ExTraceGlobals.ActiveDirectoryTracer.TraceDebug <Guid>((long)base.TenantExternalDirectoryId.GetHashCode(), "Selecting a DC for Merge operation of {0}. Will examine all DCs in the local site AND domain", base.TenantExternalDirectoryId); if (base.InvocationId != Guid.Empty) { ExTraceGlobals.ActiveDirectoryTracer.TraceError <Guid>((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.SelectDomainController this.InvocationId {0} is not Guid.Empty", base.InvocationId); throw new InvalidOperationException("InvocationId"); } ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 390, "SelectDomainController", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\MergePageToken.cs"); IList <ADServerInfo> serversForRole = TopologyProvider.GetInstance().GetServersForRole(partitionId.ForestFQDN, new List <string>(0), ADServerRole.DomainController, int.MaxValue, false); ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.SelectDomainController searching dcs in preferred site"); foreach (ADServerInfo adserverInfo in serversForRole) { Guid result; if (this.TrySelectDomainController(session, adserverInfo.Fqdn, partitionId, false, out result)) { return(result); } } ReadOnlyCollection <ADServer> readOnlyCollection = ADForest.GetForest(partitionId).FindRootDomain().FindAllDomainControllers(); ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.SelectDomainController searching dcs in other sites"); foreach (ADServer adserver in readOnlyCollection) { Guid result2; if (!ConnectionPoolManager.IsServerInPreferredSite(partitionId.ForestFQDN, adserver) && this.TrySelectDomainController(session, adserver.DnsHostName, partitionId, true, out result2)) { return(result2); } } ExTraceGlobals.ActiveDirectoryTracer.TraceError <Guid, string>((long)base.TenantExternalDirectoryId.GetHashCode(), "Could not find any DC that has all changes reported by the Tenant Full Sync Watermarks for {0}. \r\nFull sync watermarks: \r\n{1}", base.TenantExternalDirectoryId, base.Watermarks.SerializeToString()); throw new BackSyncDataSourceUnavailableException(); }
public static ADMetrics GetMetricsForForest(ADMetrics previousMetrics, string forestFqdn) { ADMetrics admetrics = new ADMetrics(forestFqdn); TopologyProvider instance = TopologyProvider.GetInstance(); if (previousMetrics != null && previousMetrics.serversList != null && ExDateTime.UtcNow - previousMetrics.lastTopologyUpdateTime < ADMetrics.topologyRediscoveryInterval && (instance == null || instance.GetTopologyVersion(forestFqdn) == previousMetrics.topologyVersion)) { ExTraceGlobals.ResourceHealthManagerTracer.TraceDebug(0L, "[ADMetrics::GetMetrics] Using existing topology for forest " + forestFqdn); admetrics.lastTopologyUpdateTime = previousMetrics.lastTopologyUpdateTime; admetrics.serversList = previousMetrics.serversList; admetrics.rediscoverTopology = false; admetrics.topologyVersion = previousMetrics.topologyVersion; } else { ExTraceGlobals.ResourceHealthManagerTracer.TraceDebug(0L, "[ADMetrics::GetMetrics] Rediscovering topology."); admetrics.rediscoverTopology = true; } if (admetrics.Populate(previousMetrics)) { return(admetrics); } Globals.LogEvent(DirectoryEventLogConstants.Tuple_ADHealthFailed, null, new object[0]); return(null); }
private void PopulateTopologyVersion() { TopologyProvider instance = TopologyProvider.GetInstance(); if (instance != null) { this.topologyVersion = instance.GetTopologyVersion(this.forestFqdn); } }
protected override void InternalValidate() { if (TopologyProvider.IsAdamTopology()) { base.WriteError(new CannotRunOnEdgeException(), ErrorCategory.InvalidOperation, null); } base.InternalValidate(); NewX400AuthoritativeDomain.ValidateNoDuplicates(this.DataObject, this.ConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError)); }
protected override void InternalValidate() { TaskLogger.LogEnter(); if (TopologyProvider.IsAdamTopology()) { base.WriteError(new CannotRunOnEdgeException(), ErrorCategory.InvalidOperation, null); } base.InternalValidate(); TaskLogger.LogExit(); }
private object GetNonAdamProperty(ADPropertyDefinition propertyDefinition) { object result; if (TopologyProvider.IsAdamTopology()) { result = propertyDefinition.DefaultValue; } else { result = this[propertyDefinition]; } return(result); }
public CalculationEngineService() { proxyFactory = new ProxyFactory(); topologyBuilder = new GraphBuilder(); voltageFlow = new LoadFlow(); webTopologyBuilder = new TopologyConverter(); sCADAResultProvider = new SCADAResultHandler(); cacheProvider = new MeasurementProvider(); modelManager = new ModelManager(); modelProvider = new ModelProvider(modelManager); topologyProvider = new TopologyProvider(topologyBuilder, voltageFlow); webTopologyModelProvider = new TopologyConverterProvider(webTopologyBuilder); topologyPublisher = new TopologyPublisher(); InitializeHosts(); }
public static ITopologyConfigurationSession CreateRemoteForestSession(string fqdn, NetworkCredential credential) { if (string.IsNullOrEmpty(fqdn)) { throw new ArgumentNullException("fqdn"); } if (credential != null && (string.IsNullOrEmpty(credential.UserName) || string.IsNullOrEmpty(credential.Password))) { throw new ArgumentException("credential"); } ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, credential, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(new PartitionId(fqdn)), 69, "CreateRemoteForestSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADSystemConfigurationSession.cs"); ADServerInfo remoteServerFromDomainFqdn = TopologyProvider.GetInstance().GetRemoteServerFromDomainFqdn(fqdn, credential); topologyConfigurationSession.DomainController = remoteServerFromDomainFqdn.Fqdn; topologyConfigurationSession.EnforceDefaultScope = false; return(topologyConfigurationSession); }
protected override void InternalProcessRecord() { if (TopologyProvider.IsAdamTopology()) { base.InternalProcessRecord(); return; } if (this.RemoveLink.IsPresent) { this.Unlink(); } else { this.Link(); } base.InternalProcessRecord(); }
public static ADForest GetForest(PartitionId partitionId) { if (null == partitionId) { throw new ArgumentNullException("partitionId"); } if (ADForest.IsLocalForestFqdn(partitionId.ForestFQDN)) { return(ADForest.GetLocalForest()); } IList <ADServerInfo> serversForRole = TopologyProvider.GetInstance().GetServersForRole(partitionId.ForestFQDN, new List <string>(0), ADServerRole.DomainController, 1, false); IList <ADServerInfo> serversForRole2 = TopologyProvider.GetInstance().GetServersForRole(partitionId.ForestFQDN, new List <string>(0), ADServerRole.GlobalCatalog, 1, false); if (serversForRole == null || serversForRole2 == null || serversForRole.Count == 0 || serversForRole2.Count == 0) { throw new ADOperationException(DirectoryStrings.CannotGetForestInfo(partitionId.ForestFQDN)); } return(new ADForest(partitionId.ForestFQDN, serversForRole[0].Fqdn, serversForRole2[0].Fqdn, null, true)); }
public TopologyProviderService(StatefulServiceContext context) : base(context) { this.logger = CloudLoggerFactory.GetLogger(ServiceEventSource.Current, context); this.baseLogString = $"{this.GetType()} [{this.GetHashCode()}] =>{Environment.NewLine}"; Logger.LogDebug($"{baseLogString} Ctor => Logger initialized"); try { this.topologyProvider = new TopologyProvider(this.StateManager); this.topologyConverter = new TopologyConverter(); string infoMessage = $"{baseLogString} Ctor => Contract providers initialized."; Logger.LogInformation(infoMessage); } catch (Exception e) { string errorMessage = $"{baseLogString} Ctor => Exception caught: {e.Message}."; Logger.LogError(errorMessage, e); } }
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)); } }
private void DoCalendarValidation(ADUser user) { List <MeetingValidationResult> list = null; base.WriteProgress(Strings.CalendarValidationTask, Strings.ValidatingCalendar(this.Identity.ToString()), 0); try { TopologyProvider.SetProcessTopologyMode(false, false); string mailboxUserAddress = string.Format("SMTP:{0}", user.PrimarySmtpAddress); CalendarValidator calendarValidator; if (!string.IsNullOrEmpty(this.MeetingID)) { VersionedId meetingId = new VersionedId(this.MeetingID); calendarValidator = CalendarValidator.CreateMeetingSpecificValidatingInstance(mailboxUserAddress, user.OrganizationId, base.RootOrgContainerId, meetingId); } else { calendarValidator = CalendarValidator.CreateRangeValidatingInstance(mailboxUserAddress, user.OrganizationId, base.RootOrgContainerId, this.IntervalStartDate, this.IntervalEndDate, this.Location, this.Subject); } list = calendarValidator.Run(); } catch (WrongServerException exception) { base.WriteError(exception, ErrorCategory.InvalidArgument, this); } catch (MailboxUserNotFoundException exception2) { base.WriteError(exception2, ErrorCategory.InvalidData, this); } catch (CorruptDataException exception3) { base.WriteError(exception3, ErrorCategory.InvalidData, this); } finally { TopologyProvider.SetProcessTopologyMode(true, false); } this.validatorObjectCount = 0; int num = (list.Count > 0) ? list.Count : 1; foreach (MeetingValidationResult meetingValidationResult in list) { if (!this.OnlyReportErrors || !meetingValidationResult.IsConsistent || !meetingValidationResult.WasValidationSuccessful || meetingValidationResult.DuplicatesDetected) { MeetingValidationResult meetingValidationResult2 = MeetingValidationResult.CreateOutputObject(meetingValidationResult); MeetingValidationResult.FilterResultsLists(meetingValidationResult2, meetingValidationResult, this.FailureCategoryType, this.OnlyReportErrors); this.validatorObjectCount++; bool flag = true; if (meetingValidationResult2.ResultsPerAttendee.Length < 1) { flag = false; } if ((this.FailureCategoryType & FailureCategory.CorruptMeetings) == FailureCategory.CorruptMeetings && !meetingValidationResult2.WasValidationSuccessful) { flag = true; } else if ((this.FailureCategoryType & FailureCategory.DuplicateMeetings) == FailureCategory.DuplicateMeetings && meetingValidationResult2.DuplicatesDetected) { flag = true; } if (flag) { meetingValidationResult2.SetIsReadOnly(true); base.WriteResult(meetingValidationResult2); } base.WriteProgress(Strings.CalendarValidationTask, Strings.ValidatingCalendar(this.Identity.ToString()), this.validatorObjectCount / num * 100); } } base.WriteProgress(Strings.CalendarValidationTask, Strings.ValidatingCalendar(this.Identity.ToString()), 100); }
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)); } }
/// <summary> /// Creates a default <see cref="IBusClient{TMessageContext}"/> according to config. /// </summary> /// <remarks> /// This component replaces RawRabbit.vNext.BusClientFactory in order to avoid heavy dependency "pollution", but at /// the cost of inflexible, hard-wired setup. /// </remarks> /// <typeparam name="TMessageContext">The type of the context.</typeparam> /// <param name="config">The raw rabbit configuration.</param> /// <returns>The bus client.</returns> public static IBusClient <TMessageContext> CreateDefault <TMessageContext>(RawRabbitConfiguration config) where TMessageContext : MessageContext { var namingConventions = new NamingConventions(); var configurationEvaluator = new ConfigurationEvaluator(config, namingConventions); var connectionFactory = CreateConnectionFactory(config); var channelConfig = new ChannelFactoryConfiguration(); var channelFactory = new ChannelFactory(connectionFactory, config, channelConfig); var consumerFactory = new EventingBasicConsumerFactory(); var topologyProvider = new TopologyProvider(channelFactory); var jsonSerializer = new JsonSerializer(); var serializer = new MessageSerializer(jsonSerializer); IMessageContextProvider <TMessageContext> contextProvider = new MessageContextProvider <TMessageContext>(jsonSerializer); var contextEnhancer = new ContextEnhancer(channelFactory, namingConventions); var propertiesProvider = new BasicPropertiesProvider(config); var errorHandling = new DefaultStrategy( serializer, namingConventions, propertiesProvider, topologyProvider, channelFactory); ISubscriber <TMessageContext> subscriber = new Subscriber <TMessageContext>( channelFactory, consumerFactory, topologyProvider, serializer, contextProvider, contextEnhancer, errorHandling, config); var acknowledger = new NoAckAcknowledger(); var publisher = new Publisher <TMessageContext>( channelFactory, topologyProvider, serializer, contextProvider, acknowledger, propertiesProvider, config); var responder = new Responder <TMessageContext>( channelFactory, topologyProvider, consumerFactory, serializer, contextProvider, contextEnhancer, propertiesProvider, errorHandling, config); var requester = new Requester <TMessageContext>( channelFactory, consumerFactory, serializer, contextProvider, errorHandling, propertiesProvider, topologyProvider, config); var client = new BaseBusClient <TMessageContext>( configurationEvaluator, subscriber, publisher, responder, requester); return(client); }
protected override void ValidateInfrastructure() { TopologyProvider.TopologyProviderType topologyProviderType = TopologyProvider.GetTopologyProviderTypeFromClusterManifestTypeInfrastructure(this.infrastructure); if (topologyProviderType == TopologyProvider.TopologyProviderType.ServiceRuntimeTopologyProvider) { ValidateInfrastructureWithServiceRuntimeTopologyProvider(this.infrastructure.Item as ClusterManifestTypeInfrastructureWindowsAzure); } else if (topologyProviderType == TopologyProvider.TopologyProviderType.StaticTopologyProvider) { ValidateInfrastructureWithStaticTopologyProvider(this.infrastructure.Item as ClusterManifestTypeInfrastructureWindowsAzureStaticTopology); } #if !DotNetCoreClr if (this.IsV2NodeIdGeneratorEnabled && (this.NodeIdGeneratorVersion.Equals("V3", StringComparison.InvariantCultureIgnoreCase) || this.NodeIdGeneratorVersion.Equals("V4", StringComparison.InvariantCultureIgnoreCase))) #else if (this.IsV2NodeIdGeneratorEnabled && (this.NodeIdGeneratorVersion.Equals("V3") || this.NodeIdGeneratorVersion.Equals("V4"))) #endif { throw new ArgumentException(FabricValidatorUtility.TraceTag, "V2 and V3/V4 NodeIdGenerator cannot be enabled simultaneously."); } #if !DotNetCoreClr if (!string.IsNullOrEmpty(this.NodeIdGeneratorVersion) && !this.NodeIdGeneratorVersion.Equals("V3", StringComparison.InvariantCultureIgnoreCase) && !this.NodeIdGeneratorVersion.Equals("V4", StringComparison.InvariantCultureIgnoreCase)) #else if (!string.IsNullOrEmpty(this.NodeIdGeneratorVersion) && !this.NodeIdGeneratorVersion.Equals("V3") && !this.NodeIdGeneratorVersion.Equals("V4")) #endif { throw new ArgumentException(FabricValidatorUtility.TraceTag, "v3/V3 and v4/V4 are the only allowed values for the NodeIdGeneratorVersion configuration."); } if (this.DiagnosticsFileStoreConnectionString != null) { char[] secureFileStoreConnection = FabricValidatorUtility.SecureStringToCharArray(this.DiagnosticsFileStoreConnectionString); try { if (!FabricValidatorUtility.StartsWithIgnoreCase(secureFileStoreConnection, FabricValidatorConstants.XStoreImageStoreConnectionStringPrefix)) { throw new ArgumentException(FabricValidatorUtility.TraceTag, "Only xstore store diagnostics file connection string is officially supported for file stores in azure deployment."); } } finally { Array.Clear(secureFileStoreConnection, 0, secureFileStoreConnection.Length); } } if (this.DiagnosticsTableStoreConnectionString != null) { char[] secureTableStoreConnection = FabricValidatorUtility.SecureStringToCharArray(this.DiagnosticsTableStoreConnectionString); try { if (!FabricValidatorUtility.StartsWithIgnoreCase(secureTableStoreConnection, FabricValidatorConstants.XStoreImageStoreConnectionStringPrefix)) { throw new ArgumentException("Only xstore store diagnostics table connection string is officially supported for table stores in azure deployment."); } } finally { Array.Clear(secureTableStoreConnection, 0, secureTableStoreConnection.Length); } } }