internal override void ProcessRedirectionEntry(IGlobalDirectorySession session)
 {
     if (this.DomainName == null)
     {
         try
         {
             session.RemoveTenant(this.ExternalDirectoryOrganizationId);
             return;
         }
         catch (GlsTenantNotFoundException ex)
         {
             base.WriteWarning(string.Format("GlsTenantNotFoundException ignored during removal. exception: {0}", ex.Message));
             return;
         }
     }
     try
     {
         session.RemoveAcceptedDomain(this.ExternalDirectoryOrganizationId, this.DomainName.Domain);
     }
     catch (GlsPermanentException ex2)
     {
         if (ex2.Message.IndexOf("DomainBelongsToDifferentTenantException", StringComparison.OrdinalIgnoreCase) == -1 && ex2.Message.IndexOf("DataNotFound", StringComparison.OrdinalIgnoreCase) == -1)
         {
             throw ex2;
         }
         base.WriteWarning(string.Format("Gls exception ignored during removal. exception: {0}", ex2.Message));
     }
     catch (GlsTenantNotFoundException)
     {
     }
 }
        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);
        }
        protected override void InternalProcessRecord()
        {
            base.InternalProcessRecord();
            if (!ManagementEndpointBase.IsGlobalDirectoryConfigured())
            {
                base.WriteWarning("Management endpoint code skipped in test environment.");
                return;
            }
            IGlobalDirectorySession session = this.GlobalDirectorySession(this.GetRedirectionTemplate());

            this.ProcessRedirectionEntry(session);
        }
Esempio n. 4
0
 internal override void ProcessRedirectionEntry(IGlobalDirectorySession session)
 {
     if (this.accountPartitionId != null)
     {
         ADForest localForest = ADForest.GetLocalForest();
         session.UpdateTenant(this.ExternalDirectoryOrganizationId, localForest.Fqdn, this.accountPartitionId.ForestFQDN, ManagementEndpointBase.GetSmtpNextHopDomain(), GlsTenantFlags.None, this.TenantContainerCN);
         return;
     }
     if (this.TenantFlag != null)
     {
         session.SetTenantFlag(this.ExternalDirectoryOrganizationId, this.TenantFlag.Value, true);
         return;
     }
     session.UpdateAcceptedDomain(this.ExternalDirectoryOrganizationId, this.DomainName.Domain);
 }
Esempio n. 5
0
        internal static int GetMserveEntryTenantNegoConfig(string domainName)
        {
            IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(null);
            bool flag;

            if (!globalSession.TryGetDomainFlag(domainName, GlsDomainFlags.Nego2Enabled, out flag))
            {
                return(-1);
            }
            if (!flag)
            {
                return(0);
            }
            return(1);
        }
 internal override void ProcessRedirectionEntry(IGlobalDirectorySession session)
 {
     if (this.accountPartitionId != null)
     {
         ADForest localForest = ADForest.GetLocalForest();
         session.AddTenant(this.ExternalDirectoryOrganizationId, localForest.Fqdn, this.accountPartitionId.ForestFQDN, ManagementEndpointBase.GetSmtpNextHopDomain(), GlsTenantFlags.None, this.TenantContainerCN);
         if (this.PopulateCacheWithDomainName != null)
         {
             ADAccountPartitionLocator.AddTenantDataToCache(this.ExternalDirectoryOrganizationId, localForest.Fqdn, this.accountPartitionId.ForestFQDN, this.PopulateCacheWithDomainName.Domain, this.TenantContainerCN);
             return;
         }
     }
     else
     {
         session.AddAcceptedDomain(this.ExternalDirectoryOrganizationId, this.DomainName.Domain, this.InitialDomain);
     }
 }
Esempio n. 7
0
        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);
        }
        // Token: 0x0600032A RID: 810 RVA: 0x00011460 File Offset: 0x0000F660
        private static bool TryLookUpAccountForest(Guid externalDirectoryOrganizationId, string acceptedDomain, string msaUserNetID, out TenantPartitionCacheItem cacheItem)
        {
            cacheItem = null;
            Exception ex = null;

            if (acceptedDomain == string.Empty)
            {
                throw new ArgumentException(acceptedDomain);
            }
            if (msaUserNetID == string.Empty)
            {
                throw new ArgumentException(msaUserNetID);
            }
            try
            {
                IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(null);
                bool   dataFromOfflineService         = false;
                string resourceForestFqdn;
                string text;
                string tenantName;
                bool   flag;
                if (acceptedDomain != null)
                {
                    if (ADAccountPartitionLocator.acceptedDomainPartitionCache.TryGetValue(acceptedDomain, out cacheItem))
                    {
                        ADProviderPerf.UpdateGlsCacheHitRatio(GlsLookupKey.AcceptedDomain, true);
                        return(true);
                    }
                    ADProviderPerf.UpdateGlsCacheHitRatio(GlsLookupKey.AcceptedDomain, false);
                    string text2;
                    flag = globalSession.TryGetTenantForestsByDomain(acceptedDomain, out externalDirectoryOrganizationId, out resourceForestFqdn, out text, out text2, out tenantName, out dataFromOfflineService);
                }
                else if (externalDirectoryOrganizationId != Guid.Empty)
                {
                    if (ADAccountPartitionLocator.externalOrgIdPartitionCache.TryGetValue(externalDirectoryOrganizationId, out cacheItem))
                    {
                        ADProviderPerf.UpdateGlsCacheHitRatio(GlsLookupKey.ExternalDirectoryObjectId, true);
                        return(true);
                    }
                    ADProviderPerf.UpdateGlsCacheHitRatio(GlsLookupKey.ExternalDirectoryObjectId, false);
                    flag = globalSession.TryGetTenantForestsByOrgGuid(externalDirectoryOrganizationId, out resourceForestFqdn, out text, out tenantName, out dataFromOfflineService);
                }
                else
                {
                    if (ADAccountPartitionLocator.msaUserNetIdPartitionCache.TryGetValue(msaUserNetID, out cacheItem))
                    {
                        ADProviderPerf.UpdateGlsCacheHitRatio(GlsLookupKey.MSAUserNetID, true);
                        return(true);
                    }
                    ADProviderPerf.UpdateGlsCacheHitRatio(GlsLookupKey.MSAUserNetID, false);
                    flag = globalSession.TryGetTenantForestsByMSAUserNetID(msaUserNetID, out externalDirectoryOrganizationId, out resourceForestFqdn, out text, out tenantName);
                }
                if (flag)
                {
                    ADAccountPartitionLocator.LoadPartitionCacheIfNecessary();
                    Guid accountPartitionGuid;
                    ADAccountPartitionLocator.partitionsFQDNToGuid.TryGetValue(text, out accountPartitionGuid);
                    cacheItem = new TenantPartitionCacheItem(accountPartitionGuid, text, resourceForestFqdn, externalDirectoryOrganizationId, tenantName, dataFromOfflineService);
                    ADAccountPartitionLocator.InsertCacheMaps(cacheItem, acceptedDomain, msaUserNetID);
                    return(true);
                }
            }
            catch (MServTransientException ex2)
            {
                ex = ex2;
                if (!GlsMServDirectorySession.ShouldScanAllForests)
                {
                    throw;
                }
            }
            catch (MServPermanentException ex3)
            {
                ex = ex3;
                if (!GlsMServDirectorySession.ShouldScanAllForests)
                {
                    throw;
                }
            }
            catch (TransientException ex4)
            {
                ex = ex4;
                if (!GlsMServDirectorySession.ShouldScanAllForests)
                {
                    throw;
                }
            }
            catch (GlsPermanentException ex5)
            {
                ex = ex5;
                if (!GlsMServDirectorySession.ShouldScanAllForests)
                {
                    throw;
                }
            }
            catch (GlsTenantNotFoundException ex6)
            {
                ex = ex6;
                if (!GlsMServDirectorySession.ShouldScanAllForests)
                {
                    throw;
                }
            }
            if (ex != null)
            {
                ExTraceGlobals.GLSTracer.TraceWarning <Exception>(0L, "Got exception while doing GLS lookup in ADAccountPartitionLocator, ignoring it until 2605034 is fixed {0}", ex);
            }
            return(false);
        }
Esempio n. 9
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.makeDefault && !this.DataObject.Default)
            {
                this.DataObject.Default = true;
                ADPagedReader <AcceptedDomain> adpagedReader = ((IConfigurationSession)base.DataSession).FindPaged <AcceptedDomain>(this.DataObject.Id.Parent, QueryScope.OneLevel, null, null, 0);
                foreach (AcceptedDomain acceptedDomain in adpagedReader)
                {
                    if (acceptedDomain.Default)
                    {
                        acceptedDomain.Default = false;
                        base.DataSession.Save(acceptedDomain);
                    }
                }
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.IsCoexistenceDomain) && this.DataObject.IsCoexistenceDomain != this.IsCoexistenceDomain)
            {
                if (!this.IsCoexistenceDomain)
                {
                    try
                    {
                        AcceptedDomainUtility.DeregisterCoexistenceDomain(this.DataObject.DomainName.Domain);
                        goto IL_162;
                    }
                    catch (TimeoutException exception)
                    {
                        base.WriteError(exception, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                    catch (InvalidOperationException exception2)
                    {
                        base.WriteError(exception2, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                    catch (SecurityAccessDeniedException exception3)
                    {
                        base.WriteError(exception3, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                    catch (CommunicationException exception4)
                    {
                        base.WriteError(exception4, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                }
                try
                {
                    AcceptedDomainUtility.RegisterCoexistenceDomain(this.DataObject.DomainName.Domain);
                }
                catch (TimeoutException exception5)
                {
                    base.WriteError(exception5, ErrorCategory.InvalidArgument, null);
                }
                catch (InvalidOperationException exception6)
                {
                    base.WriteError(exception6, ErrorCategory.InvalidArgument, null);
                }
                catch (SecurityAccessDeniedException exception7)
                {
                    base.WriteError(exception7, ErrorCategory.InvalidArgument, null);
                }
                catch (CommunicationException exception8)
                {
                    base.WriteError(exception8, ErrorCategory.InvalidArgument, null);
                }
IL_162:
                this.DataObject.IsCoexistenceDomain = this.IsCoexistenceDomain;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.RawAuthenticationType))
            {
                this.DataObject.RawAuthenticationType = this.AuthenticationType;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.InitialDomain))
            {
                this.DataObject.InitialDomain = this.InitialDomain;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.RawLiveIdInstanceType))
            {
                this.DataObject.RawLiveIdInstanceType = this.LiveIdInstanceType;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.EnableNego2Authentication))
            {
                this.DataObject.EnableNego2Authentication = this.EnableNego2Authentication;
                if (ManagementEndpointBase.IsGlobalDirectoryConfigured())
                {
                    IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(null);
                    globalSession.SetDomainFlag(this.DataObject.Name, GlsDomainFlags.Nego2Enabled, this.EnableNego2Authentication);
                }
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.CatchAllRecipient))
            {
                if (this.resolvedCatchAllRecipient != null)
                {
                    this.DataObject.CatchAllRecipientID = this.resolvedCatchAllRecipient.OriginalId;
                }
                else
                {
                    this.DataObject.CatchAllRecipientID = null;
                }
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.MatchSubDomains))
            {
                this.DataObject.MatchSubDomains = this.MatchSubDomains;
            }
            base.InternalProcessRecord();
            FfoDualWriter.SaveToFfo <AcceptedDomain>(this, this.DataObject, TenantSettingSyncLogType.SYNCACCEPTEDDOM, null);
            TaskLogger.LogExit();
        }
 internal abstract void ProcessRedirectionEntry(IGlobalDirectorySession session);