private UserWithCredential GetMonitoringAccount() { UserWithCredential result = default(UserWithCredential); string datacenter = Datacenter.IsMicrosoftHostedOnly(true) ? ".Datacenter" : string.Empty; ADSite localSite = this.ConfigSession.GetLocalSite(); try { result = CommonTestTasks.GetDefaultTestAccount(new CommonTestTasks.ClientAccessContext { Instance = this, MonitoringContext = true, ConfigurationSession = this.ConfigSession, RecipientSession = this.RecipientSession, Site = localSite, WindowsDomain = localSite.Id.DomainId.ToCanonicalName() }); } catch (Exception ex) { base.WriteError(new TestWebServicesTaskException(Strings.ErrorTestMailboxNotFound(ExchangeSetupContext.ScriptPath, datacenter, ex.ToString())), ErrorCategory.InvalidData, null); } if (string.IsNullOrEmpty(result.Credential.Password)) { base.WriteError(new TestWebServicesTaskException(Strings.ErrorTestMailboxPasswordNotFound(result.User.Identity.ToString(), ExchangeSetupContext.ScriptPath, datacenter)), ErrorCategory.InvalidData, null); } return(result); }
protected override void RedirectIfNeeded(BackEndServer mailboxServer) { if (mailboxServer == null) { throw new ArgumentNullException("mailboxServer"); } if (!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossSiteRedirect.Enabled) { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 537); Site targetSite = currentServiceTopology.GetSite(mailboxServer.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 538); ADSite localSite = LocalSiteCache.LocalSite; if (!localSite.DistinguishedName.Equals(targetSite.DistinguishedName) && (!this.IsLocalRequest(LocalServerCache.LocalServerFqdn) || !this.IsLAMUserAgent(base.ClientRequest.UserAgent))) { HttpService targetService = currentServiceTopology.FindAny <ServiceType>(ClientAccessType.Internal, (ServiceType internalService) => internalService != null && internalService.IsFrontEnd && internalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 550); if (!this.ShouldExecuteSSORedirect(targetService)) { HttpService httpService = currentServiceTopology.FindAny <ServiceType>(ClientAccessType.External, (ServiceType externalService) => externalService != null && externalService.IsFrontEnd && externalService.Site.DistinguishedName.Equals(targetSite.DistinguishedName), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\OwaEcpProxyRequestHandler.cs", "RedirectIfNeeded", 561); if (httpService != null) { Uri url = httpService.Url; if (Uri.Compare(url, base.ClientRequest.Url, UriComponents.Host, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0) { UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url); uriBuilder.Host = url.Host; ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaEcpProxyRequestHandler::RedirectIfNeeded]: Stop processing and redirect to {0}.", uriBuilder.Uri.AbsoluteUri); throw new ServerSideTransferException(uriBuilder.Uri.AbsoluteUri, LegacyRedirectTypeOptions.Silent); } } } } } }
internal FederationTrustCertificateStatus(ADSite site, TopologyServer server, FederationTrustCertificateState state, string thumbprint) { this.site = site; this.server = server; this.state = state; this.thumbprint = thumbprint; }
public static bool IsGlobalDirectoryConfigured() { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 111, "IsGlobalDirectoryConfigured", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\ManagementEndpoint\\ManagementEndpointBase.cs"); ADSite localSite = topologyConfigurationSession.GetLocalSite(); return(localSite.PartnerId != -1 || !localSite.DistinguishedName.EndsWith("DC=extest,DC=microsoft,DC=com")); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); this.configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(this.DomainController, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 148, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\um\\setUMConnectivityTestCredentials.cs"); ADSite localSite = this.configurationSession.GetLocalSite(); UmConnectivityCredentialsHelper umConnectivityCredentialsHelper = new UmConnectivityCredentialsHelper(localSite, this.serv); umConnectivityCredentialsHelper.InitializeUser(false); if (!umConnectivityCredentialsHelper.IsUserFound || !umConnectivityCredentialsHelper.IsUserUMEnabled) { this.HandleSuccess(); } if (umConnectivityCredentialsHelper.IsExchangePrincipalFound) { if (umConnectivityCredentialsHelper.SuccessfullyGotPin) { this.SaveThePin(umConnectivityCredentialsHelper); this.HandleSuccess(); } else { SUC_CouldnotRetreivePasswd localizedException = new SUC_CouldnotRetreivePasswd(); this.HandleError(localizedException, SetUMConnectivityTestCredentials.EventId.ADError, "MSExchange Monitoring UMConnectivityTestCredentials"); } } else { SUC_ExchangePrincipalError localizedException2 = new SUC_ExchangePrincipalError(); this.HandleError(localizedException2, SetUMConnectivityTestCredentials.EventId.ADError, "MSExchange Monitoring UMConnectivityTestCredentials"); } TaskLogger.LogExit(); }
public bool InitializeIfNeeded(HostId identity) { if (this.HostId == HostId.NotInitialized) { lock (this.initLock) { if (this.HostId == HostId.NotInitialized) { CommonDiagnosticsLog.Initialize(identity); ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), OrganizationId.ForestWideOrgId, null, false); ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 500, "InitializeIfNeeded", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs"); Server server = topologyConfigurationSession.FindLocalServer(); if (server == null || string.IsNullOrEmpty(server.Fqdn) || string.IsNullOrEmpty(server.Domain)) { TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Failed to get local server, or it is invalid Fqdn={0}, Domain={1}", (server == null) ? "<null>" : server.Fqdn, (server == null) ? "<null>" : server.Domain); return(false); } this.localServer = server; ADSite localSite = topologyConfigurationSession.GetLocalSite(); if (localSite == null) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Failed to get local site.", new object[0]); return(false); } this.localServerSiteId = localSite.Id; this.HostId = identity; } } return(true); } return(true); }
internal override void InvokeWebService(IConfigurationSession session, EhfTargetServerConfig config, EhfProvisioningService provisioningService) { IPAddress[] array = null; IPAddress[] array2 = null; if (this.dnsServerIPAddresses != null && this.fqdnTemplate != null) { ADSite site = null; ADNotificationAdapter.TryRunADOperation(delegate() { site = ((ITopologyConfigurationSession)session).GetLocalSite(); }); if (site == null) { base.WriteError(new InvalidOperationException("Unable to find ADSite object"), ErrorCategory.InvalidOperation, null); } Dns dns = new Dns(); dns.Timeout = TimeSpan.FromSeconds(30.0); dns.ServerList = new DnsServerList(); dns.ServerList.Initialize(this.dnsServerIPAddresses.ToArray()); array = this.ResolveInboundVirtualIPs(dns, site.PartnerId, this.fqdnTemplate); } if (this.outboundIPAddresses != null && this.outboundIPAddresses.Count > 0) { array2 = this.outboundIPAddresses.ToArray(); } if (array != null || array2 != null) { CompanyResponseInfo companyResponseInfo = provisioningService.UpdateReseller(config.ResellerId, array, array2); if (companyResponseInfo.Status != ResponseStatus.Success) { this.HandleFailure(companyResponseInfo); } } }
public static ADServer PickGlobalCatalog(string configDCName) { ADServer adserver = DirectoryUtilities.DomainControllerFromName(configDCName); if (adserver != null && DirectoryUtilities.IsGlobalCatalog(adserver) && adserver.IsAvailable()) { return(adserver); } ADForest localForest = ADForest.GetLocalForest(); ADSite localSite = DirectoryUtilities.ConfigurationSession.GetLocalSite(); if (localSite == null) { throw new ADInitializationException(Strings.LocalSiteNotFound); } ReadOnlyCollection <ADServer> readOnlyCollection = localForest.FindAllGlobalCatalogs(); foreach (ADServer adserver2 in readOnlyCollection) { if (adserver2.ValidateRead().Length == 0 && adserver2.Site.Equals(localSite.Id) && adserver2.IsAvailable()) { return(adserver2); } } foreach (ADServer adserver3 in readOnlyCollection) { if (adserver3.ValidateRead().Length == 0 && adserver3.IsAvailable()) { return(adserver3); } } throw new ADInitializationException(Strings.NoGCsAvailableException(localForest.Fqdn)); }
protected override IConfigurable PrepareDataObject() { ADSite localSite = ((ITopologyConfigurationSession)this.ConfigurationSession).GetLocalSite(); ExchangeConfigurationUnit exchangeConfigurationUnit = (ExchangeConfigurationUnit)base.PrepareDataObject(); exchangeConfigurationUnit.ManagementSiteLink = localSite.Id; return(exchangeConfigurationUnit); }
private void ResolveAdSite() { foreach (AdSiteIdParameter adSiteIdParameter in this.Site) { ADSite adSite = base.GetDataObject <ADSite>(adSiteIdParameter, this.session, null, new LocalizedString?(Strings.GetQueueDigestSiteNotFound(adSiteIdParameter)), new LocalizedString?(Strings.GetQueueDigestAmbiguosSite(adSiteIdParameter))) as ADSite; this.impl.ResolveAdSite(adSite); } }
public static ADSiteWrapper CreateWrapper(ADSite adSite) { if (adSite == null) { return(null); } return(new ADSiteWrapper(adSite)); }
public static bool TryLoadLocalSiteTopology(string domainController, out ReplicationTopology topology, out Exception exception) { topology = null; exception = null; ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 154, "TryLoadLocalSiteTopology", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\ReplicationTopology.cs"); ADSite localSite = null; EdgeSyncServiceConfig edgeSyncServiceConfig = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { localSite = session.GetLocalSite(); if (localSite == null) { throw new ADTransientException(Strings.CannotGetLocalSite); } edgeSyncServiceConfig = session.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService")); }, 3); if (!adoperationResult.Succeeded) { exception = adoperationResult.Exception; return(false); } if (edgeSyncServiceConfig == null) { topology = new ReplicationTopology(session, null, localSite, null); return(true); } ReplicationTopology resultTopology = null; adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { Server server = session.FindLocalServer(); resultTopology = new ReplicationTopology(session, server, localSite, edgeSyncServiceConfig); QueryFilter filter = Util.BuildServerFilterForSite(localSite.Id); ADPagedReader <Server> adpagedReader = session.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0); resultTopology.siteEdgeServers.Clear(); resultTopology.siteHubServers.Clear(); foreach (Server server2 in adpagedReader) { if (server2.IsEdgeServer) { resultTopology.siteEdgeServers.Add(server2); } if (server2.IsHubTransportServer) { resultTopology.siteHubServers.Add(server2); } } }, 3); if (!adoperationResult.Succeeded) { exception = adoperationResult.Exception; return(false); } topology = resultTopology; return(true); }
// Token: 0x06000033 RID: 51 RVA: 0x000034F8 File Offset: 0x000016F8 internal static Uri GetRedirectUrlForTenantSite(string organization, string redirectTemplate, Uri originalUrl, ExEventLog eventLogger) { if (organization == null) { return(null); } ADSessionSettings sessionSettings; try { Guid externalDirectoryOrganizationId; sessionSettings = (Guid.TryParse(organization, out externalDirectoryOrganizationId) ? ADSessionSettings.FromExternalDirectoryOrganizationId(externalDirectoryOrganizationId) : ADSessionSettings.FromTenantCUName(organization)); } catch (CannotResolveTenantNameException) { return(null); } catch (CannotResolveExternalDirectoryOrganizationIdException) { return(null); } ITenantConfigurationSession session = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 180, "GetRedirectUrlForTenantSite", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\RedirectionModule\\RedirectionHelper.cs"); ExchangeConfigurationUnit exchangeConfigurationUnit = RedirectionHelper.ResolveConfigurationUnitByName(organization, session); if (exchangeConfigurationUnit == null || exchangeConfigurationUnit.ManagementSiteLink == null) { return(null); } ADSite localSite = LocalSiteCache.LocalSite; ADObjectId adobjectId = ADObjectIdResolutionHelper.ResolveDN(exchangeConfigurationUnit.ManagementSiteLink); Logger.LogEvent(eventLogger, TaskEventLogConstants.Tuple_LiveIdRedirection_UsingManagementSiteLink, organization, new object[] { organization, exchangeConfigurationUnit.AdminDisplayVersion, exchangeConfigurationUnit.ManagementSiteLink }); if (adobjectId.Equals(localSite.Id)) { return(null); } foreach (ADObjectId adobjectId2 in localSite.ResponsibleForSites) { if (adobjectId2.Equals(adobjectId)) { Logger.LogEvent(eventLogger, TaskEventLogConstants.Tuple_LiveIdRedirection_TargetSitePresentOnResponsibleForSite, organization, new object[] { organization, adobjectId, adobjectId2 }); return(null); } } return(RedirectionHelper.GetRedirectUrlForTenantSite(adobjectId, redirectTemplate, originalUrl)); }
public override void ResolveAdSite(ADSite adSite) { foreach (Server server in this.GetAllServersInForest()) { if (adSite.Id.Equals(server.ServerSite)) { this.ResolveServer(server); } } }
internal UmConnectivityCredentialsHelper(ADSite site, Server server) { UmConnectivityCredentialsHelper.DebugTrace("Inside UmConnectivityCredentialsHelper(). ADSite = {0}, Server = {1}", new object[] { site, server }); SmtpAddress?enterpriseAutomatedTaskUser = TestConnectivityCredentialsManager.GetEnterpriseAutomatedTaskUser(site, server.Domain); this.userName = TestCasConnectivity.GetInstanceUserNameFromTestUser(enterpriseAutomatedTaskUser); this.domain = server.Domain; }
protected override void InternalValidate() { if (this.Site != null) { ADSite adsite = (ADSite)base.GetDataObject <ADSite>(this.Site, base.DataSession, null, new LocalizedString?(Strings.ErrorSiteNotFound(this.Site.ToString())), new LocalizedString?(Strings.ErrorSiteNotUnique(this.Site.ToString()))); if (base.HasErrors) { return; } this.rootId = adsite.Id; } base.InternalValidate(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); this.m_adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 146, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Cluster\\DatabaseAvailabilityGroupAction.cs"); this.m_output = new HaTaskOutputHelper(this.TaskName, new Microsoft.Exchange.Configuration.Tasks.Task.TaskErrorLoggingDelegate(base.WriteError), new Microsoft.Exchange.Configuration.Tasks.Task.TaskWarningLoggingDelegate(this.WriteWarning), new Microsoft.Exchange.Configuration.Tasks.Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Microsoft.Exchange.Configuration.Tasks.Task.TaskProgressLoggingDelegate(base.WriteProgress), this.GetHashCode()); this.m_output.CreateTempLogFile(); this.NeedToUpdateAD = true; this.NeedToUpdateCluster = true; if (this.ConfigurationOnly && this.QuorumOnly) { this.m_output.WriteErrorSimple(new TaskBothConfigurationOnlyAndQuorumOnlySpecifiedException()); } if (this.ConfigurationOnly) { this.NeedToUpdateCluster = false; } if (this.QuorumOnly) { this.NeedToUpdateAD = false; } this.m_dag = DagTaskHelper.DagIdParameterToDag(this.Identity, base.DataSession); DagTaskHelper.VerifyDagAndServersAreWithinScopes <DatabaseAvailabilityGroup>(this, this.m_dag, true); if (this.m_dag.DatacenterActivationMode != DatacenterActivationModeOption.DagOnly) { this.m_output.WriteErrorSimple(new TaskCanOnlyRunOnDacException(this.m_dag.Name)); } DatabaseAvailabilityGroupAction.ResolveServers(this.m_output, this.m_dag, this.m_serversInDag, this.m_startedServers, this.m_stoppedServers); if (this.MailboxServer != null) { this.m_mailboxServer = (Server)base.GetDataObject <Server>(this.MailboxServer, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(this.MailboxServer.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.MailboxServer.ToString()))); if (!this.m_mailboxServer.IsMailboxServer) { this.m_output.WriteErrorSimple(new OperationOnlyOnMailboxServerException(this.m_mailboxServer.Name)); } if (this.m_mailboxServer.MajorVersion != Server.CurrentExchangeMajorVersion) { this.m_output.WriteErrorSimple(new DagTaskErrorServerWrongVersion(this.m_mailboxServer.Name)); } } if (this.ActiveDirectorySite != null) { IConfigurationSession configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 225, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Cluster\\DatabaseAvailabilityGroupAction.cs"); configurationSession.UseConfigNC = false; configurationSession.UseGlobalCatalog = true; ADSite adsite = (ADSite)base.GetDataObject <ADSite>(this.ActiveDirectorySite, configurationSession, null, new LocalizedString?(Strings.ErrorSiteNotFound(this.ActiveDirectorySite.ToString())), new LocalizedString?(Strings.ErrorSiteNotUnique(this.ActiveDirectorySite.ToString()))); } base.InternalValidate(); TaskLogger.LogExit(); }
internal bool TryGetForestFqdnFromPartnerId(int partnerId, out string forestFqdn) { if (MServDirectorySession.partnerIdToForestMap.TryGetValue(partnerId, out forestFqdn)) { ExTraceGlobals.MServTracer.TraceDebug((long)this.GetHashCode(), string.Format("The partner id {0} mapped to forest {1}", partnerId, forestFqdn)); return(true); } ADSite adsite = this.GetLocalSite(); if (adsite != null && partnerId == adsite.PartnerId) { ExTraceGlobals.MServTracer.TraceDebug((long)this.GetHashCode(), string.Format("The partner id {0} is the same as the current site id", partnerId)); forestFqdn = PartitionId.LocalForest.ForestFQDN; return(true); } return(false); }
private static void LoadPartnerId() { ADSite localSite = null; ADOperationResult adoperationResult = ADOperationResult.Success; adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { localSite = MserveSynchronizationProvider.ConfigSession.GetLocalSite(); if (localSite == null) { throw new ExDirectoryException(Strings.CannotGetLocalSite, null); } }, 3); if (!adoperationResult.Succeeded) { throw new ExDirectoryException(Strings.CannotGetLocalSite, adoperationResult.Exception); } MserveSynchronizationProvider.partnerId = localSite.PartnerId; }
public static ADServer PickLocalDomainController() { ADServer adserver = DirectoryUtilities.DomainControllerFromName("localhost"); if (adserver != null && DirectoryUtilities.IsGlobalCatalog(adserver) && adserver.IsAvailable()) { return(adserver); } ADSite localSite = DirectoryUtilities.ConfigurationSession.GetLocalSite(); if (localSite == null) { throw new ADInitializationException(Strings.LocalSiteNotFound); } ADDomain addomain = ADForest.GetLocalForest().FindLocalDomain(); if (addomain == null) { throw new ADInitializationException(Strings.LocalDomainNotFoundException); } ReadOnlyCollection <ADServer> readOnlyCollection = addomain.FindAllDomainControllers(); foreach (ADServer adserver2 in readOnlyCollection) { if (adserver2.ValidateRead().Length == 0 && adserver2.Site.Equals(localSite.Id) && adserver2.IsAvailable() && DirectoryUtilities.IsGlobalCatalog(adserver2)) { return(adserver2); } } if (adserver != null) { return(adserver); } foreach (ADServer adserver3 in readOnlyCollection) { if (adserver3.ValidateRead().Length == 0 && adserver3.Site.Equals(localSite.Id) && adserver3.IsAvailable()) { return(adserver3); } } throw new ADInitializationException(Strings.NoDCsAvailableException(addomain.Name, localSite.Name)); }
// Token: 0x06001214 RID: 4628 RVA: 0x00038DB8 File Offset: 0x00036FB8 private static Server[] GetMailboxServers(ITopologyConfigurationSession configSession, bool localSiteOnly, LogMessageDelegate logger) { QueryFilter queryFilter = new AndFilter(new QueryFilter[] { new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL), new ComparisonFilter(ComparisonOperator.NotEqual, ActiveDirectoryServerSchema.IsOutOfService, true), new ExistsFilter(ActiveDirectoryServerSchema.HostedDatabaseCopies) }); QueryFilter filter; if (PhysicalResourceLoadBalancing.IsDatacenter) { if (localSiteOnly) { ADSite localSite = configSession.GetLocalSite(); queryFilter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, localSite.Id) }); } QueryFilter mailboxServerVersionFilter = PhysicalResourceLoadBalancing.GetMailboxServerVersionFilter(); filter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, mailboxServerVersionFilter }); } else { filter = queryFilter; } PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configSession, typeof(Server), filter, null, false), logger); Server[] array = configSession.Find <Server>(null, QueryScope.SubTree, filter, null, 0); if (array == null || array.Length == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoServerForDatabaseException("Can not find any available mailbox server."), logger); throw new NoServersForDatabaseException("Can not find any mailbox server in local site"); } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGeneralTrace(string.Format("Retrieved {0} mailbox servers.", array.Length)), logger); return(array); }
private void GetTestMailbox() { ADSite localSite = this.SystemConfigurationSession.GetLocalSite(); base.WriteVerbose(Strings.RunCmdletOnSite(localSite.ToString())); string domain = this.ServerObject.Domain; base.WriteVerbose(Strings.RunCmdletOnDomain(domain)); NetworkCredential defaultTestAccount = TestLiveIdAuthenticationTask.GetDefaultTestAccount(new TestLiveIdAuthenticationTask.ClientAccessContext { Instance = this, MonitoringContext = this.MonitoringContext, ConfigurationSession = this.SystemConfigurationSession, WindowsDomain = domain, Site = localSite }, this.UserType); base.WriteVerbose(Strings.RunCmdletOnUser(defaultTestAccount.UserName)); this.MailboxCredential = TestLiveIdAuthenticationTask.MakePSCredential(defaultTestAccount); }
private static GlsLookupMode InitializeLookupMode() { string value = null; try { using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(GlsMServDirectorySession.RegistryKey)) { value = ((registryKey != null) ? ((string)registryKey.GetValue(GlsMServDirectorySession.GlobalDirectoryLookupTypeValue, null)) : null); } } catch (SecurityException ex) { ExTraceGlobals.GLSTracer.TraceError <string>(0L, "SecurityException: {0}", ex.Message); } catch (UnauthorizedAccessException ex2) { ExTraceGlobals.GLSTracer.TraceError <string>(0L, "UnauthorizedAccessException: {0}", ex2.Message); } GlsLookupMode result; if (Enum.TryParse <GlsLookupMode>(value, true, out result)) { return(result); } if (DatacenterRegistry.IsForefrontForOffice()) { return(GlsLookupMode.GlsOnly); } ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 694, "InitializeLookupMode", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\GlsMServDirectorySession.cs"); ADSite localSite = topologyConfigurationSession.GetLocalSite(); if (localSite.DistinguishedName.EndsWith("DC=extest,DC=microsoft,DC=com")) { return(GlsLookupMode.MServOnly); } return(GlsLookupMode.BothGLSAndMServ); }
protected override void InternalProcessRecord() { ADSite adsite = null; try { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 41, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\EdgeSync\\GetLocalADSite.cs"); adsite = topologyConfigurationSession.GetLocalSite(); } catch (ADExternalException exception) { base.WriteError(exception, ErrorCategory.ObjectNotFound, null); } catch (ADTransientException exception2) { base.WriteError(exception2, ErrorCategory.ObjectNotFound, null); } if (adsite == null) { base.WriteError(new ADExternalException(Strings.LocalSiteNotFound), ErrorCategory.ObjectNotFound, null); return; } base.WriteObject(adsite); }
protected override void InternalValidate() { if (this.UserIdentity == null) { ADSite localSite = base.RootOrgGlobalConfigSession.GetLocalSite(); string text; if (TestConnectivityCredentialsManager.IsExchangeMultiTenant()) { SmtpAddress?multiTenantAutomatedTaskUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(this, base.RootOrgGlobalConfigSession, localSite); text = ((multiTenantAutomatedTaskUser != null) ? multiTenantAutomatedTaskUser.Value.ToString() : null); } else { SmtpAddress?enterpriseAutomatedTaskUser = TestConnectivityCredentialsManager.GetEnterpriseAutomatedTaskUser(localSite, "CasDomain.com"); text = ((enterpriseAutomatedTaskUser != null) ? enterpriseAutomatedTaskUser.Value.Local : null); } if (text != null) { this.UserIdentity = new RecipientIdParameter(text); return; } base.ThrowTerminatingError(new NoDefaultTestAccountException(), (ErrorCategory)1003, null); } }
internal bool TryGetPartnerIdFromForestFqdn(string forestFqdn, out int partnerId) { foreach (KeyValuePair <int, string> keyValuePair in MServDirectorySession.partnerIdToForestMap) { if (keyValuePair.Value.Equals(forestFqdn, StringComparison.OrdinalIgnoreCase)) { partnerId = keyValuePair.Key; ExTraceGlobals.MServTracer.TraceDebug((long)this.GetHashCode(), string.Format("The partner id {0} mapped to forest {1}", partnerId, forestFqdn)); return(true); } } if (PartitionId.LocalForest.ForestFQDN.Equals(forestFqdn, StringComparison.OrdinalIgnoreCase)) { ADSite adsite = this.GetLocalSite(); if (adsite != null) { partnerId = adsite.PartnerId; ExTraceGlobals.MServTracer.TraceDebug((long)this.GetHashCode(), string.Format("The partner id {0} is the same as the current site id", partnerId)); return(true); } } partnerId = -1; return(false); }
private void ResolveTargets() { if (base.Fields.IsChanged("Server") && this.Server != null) { foreach (ServerIdParameter serverIdParameter in this.Server) { Server item = (Server)base.GetDataObject <Server>(serverIdParameter, base.RootOrgGlobalConfigSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString()))); if (!this.servers.Contains(item)) { this.servers.Add(item); } } } if (base.Fields.IsChanged("Dag") && this.Dag != null) { foreach (DatabaseAvailabilityGroupIdParameter databaseAvailabilityGroupIdParameter in this.Dag) { DatabaseAvailabilityGroup item2 = (DatabaseAvailabilityGroup)base.GetDataObject <DatabaseAvailabilityGroup>(databaseAvailabilityGroupIdParameter, base.RootOrgGlobalConfigSession, null, new LocalizedString?(Strings.ErrorDagNotFound(databaseAvailabilityGroupIdParameter.ToString())), new LocalizedString?(Strings.ErrorDagNotUnique(databaseAvailabilityGroupIdParameter.ToString()))); if (!this.dags.Contains(item2)) { this.dags.Add(item2); } } } if (base.Fields.IsChanged("Site") && this.Site != null) { foreach (AdSiteIdParameter adSiteIdParameter in this.Site) { ADSite item3 = (ADSite)base.GetDataObject <ADSite>(adSiteIdParameter, base.RootOrgGlobalConfigSession, null, new LocalizedString?(Strings.ErrorSiteNotFound(adSiteIdParameter.ToString())), new LocalizedString?(Strings.ErrorSiteNotUnique(adSiteIdParameter.ToString()))); if (!this.sites.Contains(item3)) { this.sites.Add(item3); } } } }
internal string FindRpcClientAccessArrayOrServer(ITopologyConfigurationSession session, ADObjectId localServerId) { ADSite localSite = session.GetLocalSite(); if (localSite == null) { return(null); } ClientAccessArray[] array = session.Find <ClientAccessArray>(null, QueryScope.SubTree, QueryFilter.AndTogether(new QueryFilter[] { this.GetSiteFilter(localSite.Id), ClientAccessArray.PriorTo15ExchangeObjectVersionFilter }), null, 2); if (array.Length > 0) { return(array[0].ExchangeLegacyDN); } List <string> list = new List <string>(); foreach (KeyValuePair <Server, ExchangeRpcClientAccess> keyValuePair in ExchangeRpcClientAccess.GetServersWithRpcClientAccessEnabled(ExchangeRpcClientAccess.GetAllPossibleServers(session, localSite.Id), ExchangeRpcClientAccess.GetAll(session))) { if ((keyValuePair.Value.Responsibility & RpcClientAccessResponsibility.Mailboxes) != RpcClientAccessResponsibility.None) { if (localServerId.Equals(keyValuePair.Key.Id)) { return(keyValuePair.Key.ExchangeLegacyDN); } list.Add(keyValuePair.Key.ExchangeLegacyDN); } } if (list.Count == 0) { return(null); } return(NewRpcClientAccess.SelectServerWithEqualProbability(list)); }
private EdgeSyncRecord TestSyncHealth(string domainController) { ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 383, "TestSyncHealth", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\EdgeSync\\TestEdgeSyncBase.cs"); ADSite localSite = null; EdgeSyncServiceConfig config = null; ADNotificationAdapter.RunADOperation(delegate() { localSite = session.GetLocalSite(); if (localSite == null) { throw new TransientException(Strings.CannotGetLocalSite); } config = session.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService")); }, 3); if (config == null) { return(EdgeSyncRecord.GetEdgeSyncServiceNotConfiguredForCurrentSiteRecord(this.Service, localSite.Name)); } bool flag = false; string primaryLeaseFilePath; string backupLeaseFilePath; if (!this.ReadConnectorLeasePath(session, config.Id, out primaryLeaseFilePath, out backupLeaseFilePath, out flag)) { if (!flag) { return(EdgeSyncRecord.GetEdgeSyncConnectorNotConfiguredForEntireForestRecord(this.Service)); } return(EdgeSyncRecord.GetEdgeSyncConnectorNotConfiguredForCurrentSiteRecord(this.Service, localSite.Name)); } else { string additionalInfo = null; LeaseToken lease = TestEdgeSyncBase.GetLease(primaryLeaseFilePath, backupLeaseFilePath, out additionalInfo); if (lease.NotHeld) { return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "There is no lease file detected. It suggests synchronization has not started at all.", lease, null, additionalInfo)); } Cookie cookie = null; string text = null; if (!this.TryGetNewestCookieFromAllDomainControllers(out cookie, out text)) { throw new InvalidOperationException("Failed accessing all DCs: " + text); } if (cookie == null) { return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "There is no cookie detected. It suggests we haven't had a single successful synchronization.", lease, null, text)); } EnhancedTimeSpan syncInterval = this.GetSyncInterval(config); switch (lease.Type) { case LeaseTokenType.Lock: if (DateTime.UtcNow > lease.AlertTime) { return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Synchronization has completely stopped because lock has expired. It suggests the EdgeSync service died in the middle of the synchronization and no other service instance has taken over.", lease, cookie, text, true)); } if (DateTime.UtcNow > cookie.LastUpdated + config.OptionDuration + 3L * syncInterval + TimeSpan.FromHours(1.0)) { return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Cookie has not been updated as expected. It might be caused by failure to synchronize some items which means that the sychronization might still be running but not efficiently. It might also be caused by a long full sync. Check EdgeSync log for further troubleshooting.", lease, cookie, text)); } return(EdgeSyncRecord.GetInconclusiveRecord(this.Service, base.MyInvocation.MyCommand.Name, "Synchronization status is inconclusive because EdgeSync is in the middle of synchronizing data. Try running this cmdlet again later.", lease, cookie, text)); case LeaseTokenType.Option: if (DateTime.UtcNow > lease.AlertTime) { return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Synchronization has completely stopped. We have failed to failover to another instance within the same AD site or to another AD site.", lease, cookie, text, true)); } if (DateTime.UtcNow > cookie.LastUpdated + config.FailoverDCInterval + TimeSpan.FromMinutes(30.0)) { return(EdgeSyncRecord.GetFailedRecord(this.Service, base.MyInvocation.MyCommand.Name, "Cookie has not been updated as expected. It might be caused by failure to synchronize some items which means that the sychronization might still be running but not efficiently. It might also be caused by a long full sync. Check EdgeSync log for further troubleshooting.", lease, cookie, text)); } return(EdgeSyncRecord.GetNormalRecord(this.Service, "The synchronization is operating normally.", lease, cookie, text)); default: throw new ArgumentException("Unknown lease type: " + lease.Type); } } }
public AdSiteIdParameter(ADSite site) : base(site.Id) { }