internal override void ProcessRedirectionEntry(IGlobalDirectorySession session) { string memberName = string.Format("E5CB63F56E8B4b69A1F70C192276D6AD@{0}", this.DomainName); string redirectServer = session.GetRedirectServer(memberName); if (string.IsNullOrEmpty(redirectServer)) { base.WriteError(new CannotDetermineManagementEndpointException(Strings.ErrorCannotDetermineEndpointForTenant(this.DomainName.ToString())), ErrorCategory.InvalidData, null); } string remotePowershellUrl = string.Format("https://{0}/PowerShell/", redirectServer); ManagementEndpoint managementEndpoint = new ManagementEndpoint(remotePowershellUrl, ManagementEndpointVersion.Version3) { DomainName = this.DomainName }; Guid guid; string resourceForest; string accountPartition; string smtpNextHopDomain; string text; bool flag; if (((GlsMServDirectorySession.GlsLookupMode != GlsLookupMode.MServOnly && session is GlsMServDirectorySession) || session is GlsDirectorySession) && session.TryGetTenantForestsByDomain(this.DomainName.ToString(), out guid, out resourceForest, out accountPartition, out smtpNextHopDomain, out text, out flag) && Guid.Empty != guid) { managementEndpoint.AccountPartition = accountPartition; managementEndpoint.SmtpNextHopDomain = smtpNextHopDomain; managementEndpoint.ResourceForest = resourceForest; managementEndpoint.ExternalDirectoryOrganizationId = guid; } ExTraceGlobals.LogTracer.Information <string, ManagementEndpointVersion>(0L, "Get-ManagementEndPoint URL/Version {0}/{1}", managementEndpoint.RemotePowershellUrl, managementEndpoint.Version); base.WriteObject(managementEndpoint); }
internal static string GetRedirectServer(string redirectFormat, string address, int currentSiteId, int startRange, int endRange, bool overrideCurrentSiteCheck, bool throwExceptions) { string result; try { IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(redirectFormat); result = globalSession.GetRedirectServer(address); } catch (MServTransientException) { if (throwExceptions) { throw; } result = string.Empty; } catch (MServPermanentException) { if (throwExceptions) { throw; } result = string.Empty; } catch (InvalidOperationException) { if (throwExceptions) { throw; } result = string.Empty; } catch (TransientException) { if (throwExceptions) { throw; } result = string.Empty; } return(result); }