Ejemplo n.º 1
0
        protected override void InternalBeginProcessing()
        {
            TaskLogger.LogEnter();
            if (this.Credential != null)
            {
                base.NetCredential = this.Credential.GetNetworkCredential();
            }
            base.InternalBeginProcessing();
            base.WriteVerbose(Strings.VerboseIgnoreDefaultScope);
            this.domainRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, base.NetCredential, base.OrgWideSessionSettings, 106, "InternalBeginProcessing", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\recipient\\UpdateRecipient.cs");
            this.domainRecipientSession.EnforceDefaultScope = false;
            ADSessionSettings sessionSettings = ADSessionSettings.FromRootOrgScopeSet();

            if (!OrganizationId.ForestWideOrgId.Equals(base.OrgWideSessionSettings.CurrentOrganizationId))
            {
                sessionSettings = ADSessionSettings.FromAccountPartitionRootOrgScopeSet(base.OrgWideSessionSettings.CurrentOrganizationId.PartitionId);
            }
            this.configurationSession            = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, string.IsNullOrEmpty(base.DomainController) ? null : base.NetCredential, sessionSettings, 120, "InternalBeginProcessing", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\recipient\\UpdateRecipient.cs");
            this.localForestLinkResolutionServer = ADSession.GetCurrentConfigDC(base.OrgWideSessionSettings.GetAccountOrResourceForestFqdn());
            string fqdn = NativeHelpers.CanonicalNameFromDistinguishedName(this.configurationSession.GetRootDomainNamingContextFromCurrentReadConnection());

            if (ADForest.IsLocalForestFqdn(fqdn) || !OrganizationId.ForestWideOrgId.Equals(base.OrgWideSessionSettings.CurrentOrganizationId))
            {
                this.domainRecipientSession.LinkResolutionServer = this.localForestLinkResolutionServer;
            }
            TaskLogger.LogExit();
        }
 // Token: 0x060005E0 RID: 1504 RVA: 0x0001657C File Offset: 0x0001477C
 protected override void InternalStateReset()
 {
     if (this.AccountPartition != null)
     {
         PartitionId partitionId = RecipientTaskHelper.ResolvePartitionId(this.AccountPartition, new Task.TaskErrorLoggingDelegate(base.WriteError));
         this.sessionSettings = ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId);
     }
     else
     {
         this.sessionSettings = ADSessionSettings.FromCustomScopeSet(base.ScopeSet, base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);
     }
     base.InternalStateReset();
 }
Ejemplo n.º 3
0
        public static ITopologyConfigurationSession GetConfigSessionForDatabase(ITopologyConfigurationSession originalConfigSession, ADObjectId database)
        {
            ITopologyConfigurationSession result = originalConfigSession;

            if (database != null && ConfigBase <MRSConfigSchema> .GetConfig <bool>("CrossResourceForestEnabled"))
            {
                PartitionId partitionId = database.GetPartitionId();
                if (!partitionId.IsLocalForestPartition())
                {
                    ADSessionSettings sessionSettings = ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId);
                    result = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, 612, "GetConfigSessionForDatabase", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\RequestBase\\RequestTaskHelper.cs");
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        protected override IConfigurable ResolveDataObject()
        {
            IConfigurable configurable   = null;
            Exception     innerException = null;
            ADObjectId    adobjectId     = null;
            ADObjectId    rootID         = RecipientTaskHelper.IsValidDistinguishedName(this.Identity, out adobjectId) ? adobjectId.Parent : null;

            try
            {
                configurable = base.GetDataObject <ADRecipient>(this.Identity, base.DataSession, rootID, null, new LocalizedString?(Strings.ErrorRecipientNotUnique(this.Identity.ToString())));
            }
            catch (ADTransientException ex)
            {
                innerException = ex;
                base.WriteVerbose(Strings.VerboseCannotReadObject(this.Identity.ToString(), base.DataSession.Source, ex.Message));
            }
            catch (ADOperationException ex2)
            {
                innerException = ex2;
                base.WriteVerbose(Strings.VerboseCannotReadObject(this.Identity.ToString(), base.DataSession.Source, ex2.Message));
            }
            catch (ManagementObjectNotFoundException ex3)
            {
                innerException = ex3;
                base.WriteVerbose(Strings.VerboseCannotReadObject(this.Identity.ToString(), base.DataSession.Source, ex3.Message));
            }
            if (configurable == null)
            {
                base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(this.Identity.ToString()), innerException), ErrorCategory.ObjectNotFound, this.Identity);
            }
            if (this.globalCatalog == null || (base.DomainController == null && !StringComparer.InvariantCultureIgnoreCase.Equals(this.configurationSession.DomainController, ((ADObject)configurable).OriginatingServer)))
            {
                if (base.DomainController == null)
                {
                    ADObject          adobject          = (ADObject)configurable;
                    string            originatingServer = adobject.OriginatingServer;
                    ADSessionSettings sessionSettings   = ADSessionSettings.FromRootOrgScopeSet();
                    if (!adobject.OrganizationId.Equals(OrganizationId.ForestWideOrgId))
                    {
                        sessionSettings = ADSessionSettings.FromAccountPartitionRootOrgScopeSet(adobject.OrganizationId.PartitionId);
                    }
                    this.configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(originatingServer, true, ConsistencyMode.PartiallyConsistent, base.NetCredential, sessionSettings, 210, "ResolveDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\recipient\\UpdateRecipient.cs");
                }
                string text = NativeHelpers.CanonicalNameFromDistinguishedName(this.configurationSession.GetRootDomainNamingContextFromCurrentReadConnection());
                this.globalCatalog = null;
                if (this.IsServerSuitableAsGC(this.configurationSession.DomainController, this.configurationSession.NetworkCredential))
                {
                    this.globalCatalog = this.configurationSession.DomainController;
                }
                else
                {
                    NetworkCredential             credentials        = ADForest.IsLocalForestFqdn(text) ? null : this.configurationSession.NetworkCredential;
                    ADForest                      forest             = ADForest.GetForest(text, credentials);
                    ReadOnlyCollection <ADServer> readOnlyCollection = forest.FindAllGlobalCatalogs(false);
                    if (readOnlyCollection != null && readOnlyCollection.Count != 0)
                    {
                        foreach (ADServer adserver in readOnlyCollection)
                        {
                            if (this.IsServerSuitableAsGC(adserver.DnsHostName, this.configurationSession.NetworkCredential))
                            {
                                this.globalCatalog = adserver.DnsHostName;
                                break;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(this.globalCatalog))
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorNoGlobalGatalogFound(text)), (ErrorCategory)1011, this.Identity);
                    }
                }
                if (ADForest.IsLocalForestFqdn(text) || !OrganizationId.ForestWideOrgId.Equals(base.OrgWideSessionSettings.CurrentOrganizationId))
                {
                    this.domainRecipientSession.LinkResolutionServer = this.localForestLinkResolutionServer;
                }
                else
                {
                    this.domainRecipientSession.LinkResolutionServer = null;
                }
            }
            return(configurable);
        }
Ejemplo n.º 5
0
        public static ExDateTime GetPasswordExpirationDate(ADObjectId adUserObjectId, IRecipientSession recipientSession)
        {
            if (adUserObjectId.IsNullOrEmpty())
            {
                throw new ArgumentException("ADUser object ID cannot be null or empty", "adUserObjectId");
            }
            ADUser aduser = recipientSession.Read(adUserObjectId) as ADUser;

            if (aduser == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            if ((aduser.UserAccountControl & UserAccountControlFlags.DoNotExpirePassword) != UserAccountControlFlags.None)
            {
                return(ExDateTime.MaxValue);
            }
            ExDateTime?exDateTime = null;

            if (aduser.PasswordLastSet != null)
            {
                exDateTime = new ExDateTime?(new ExDateTime(ExTimeZone.UtcTimeZone, aduser.PasswordLastSet.Value));
            }
            if (exDateTime == null)
            {
                return(ExDateTime.MaxValue);
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(adUserObjectId.GetPartitionId()), 86, "GetPasswordExpirationDate", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\DirectoryHelper.cs");

            tenantOrTopologyConfigurationSession.UseConfigNC = false;
            ADDomain addomain = tenantOrTopologyConfigurationSession.Read <ADDomain>(aduser.Id.DomainId);

            if (addomain == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            EnhancedTimeSpan?maximumPasswordAge = addomain.MaximumPasswordAge;
            TimeSpan?        timeSpan           = (maximumPasswordAge != null) ? new TimeSpan?(maximumPasswordAge.GetValueOrDefault()) : null;

            if (timeSpan == null || timeSpan == TimeSpan.Zero)
            {
                return(ExDateTime.MaxValue);
            }
            return(exDateTime.Value.Add(timeSpan.Value));
        }
Ejemplo n.º 6
0
        internal static ADObjectId GetRootOrgUsgContainerId(IConfigurationSession configurationSession, ADServerSettings adServerSettings, IRecipientSession globalCatalogSession, OrganizationId organizationId)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(adServerSettings.PreferredGlobalCatalog(globalCatalogSession.SessionSettings.PartitionId.ForestFQDN), true, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(globalCatalogSession.SessionSettings.PartitionId), 110, "GetRootOrgUsgContainerId", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RBAC\\RoleGroup\\RoleGroupCommon.cs");

            return(RoleGroupCommon.RoleGroupContainerId(tenantOrRootOrgRecipientSession, configurationSession));
        }
Ejemplo n.º 7
0
 internal IConfigurationSession CreateGlobalWritableConfigSession()
 {
     return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(this.DataObject.OriginatingServer, false, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(this.DataObject.Id.GetPartitionId()), 90, "CreateGlobalWritableConfigSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\InstallAddressBookContainer.cs"));
 }
Ejemplo n.º 8
0
        private long ReadDcHighestUSN(PartitionId partitionId, string domainController, bool useConfigNC, out Guid invocationId, out WatermarkMap watermarks)
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 452, "ReadDcHighestUSN", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\RemoveTenantRelocationRequest.cs");

            invocationId = topologyConfigurationSession.GetInvocationIdByFqdn(domainController);
            topologyConfigurationSession.UseConfigNC = useConfigNC;
            watermarks = SyncConfiguration.GetReplicationCursors(topologyConfigurationSession, useConfigNC, false);
            return(watermarks[invocationId]);
        }
Ejemplo n.º 9
0
        private IRecipientSession ReconstructRecipientSession(PartitionId partitionId, OrganizationId orgId)
        {
            ADSessionSettings sessionSettings = Datacenter.IsMultiTenancyEnabled() ? ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId) : ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId);

            return(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 307, "ReconstructRecipientSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\IsMemberOfProvider\\IsMemberOfResolver.cs"));
        }
Ejemplo n.º 10
0
        private ITopologyConfigurationSession CreateConfigNcSession()
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(this.domainController, true, ConsistencyMode.FullyConsistent, this.networkCredential, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(this.partitionId), 144, "CreateConfigNcSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADForest.cs");

            topologyConfigurationSession.UseGlobalCatalog = false;
            return(topologyConfigurationSession);
        }
Ejemplo n.º 11
0
        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]);
        }
Ejemplo n.º 12
0
        protected static Guid FindInvocationIdByFqdn(string dcFqdn, PartitionId partitionId)
        {
            ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "FindInvocationIdByFqdn dcFqdn {0}", dcFqdn);
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 678, "FindInvocationIdByFqdn", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\Configuration\\SyncConfiguration.cs");
            Guid invocationIdByFqdn = topologyConfigurationSession.GetInvocationIdByFqdn(dcFqdn);

            ExTraceGlobals.BackSyncTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "FindInvocationIdByFqdn invocationId {0}", invocationIdByFqdn);
            return(invocationIdByFqdn);
        }
Ejemplo n.º 13
0
        internal static string FindDomainControllerByInvocationId(Guid dcInvocationId, Exception exceptionOnDcNotFound, PartitionId partitionId)
        {
            string result = null;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 467, "FindDomainControllerByInvocationId", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\Configuration\\SyncConfiguration.cs");
            ADServer adserver = topologyConfigurationSession.FindDCByInvocationId(dcInvocationId);

            if (adserver != null)
            {
                result = adserver.DnsHostName;
                ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "adServer.DnsHostName{0}", adserver.DnsHostName);
            }
            else
            {
                ExTraceGlobals.BackSyncTracer.TraceError <Guid>((long)SyncConfiguration.TraceId, "Unable to find a DC for the invocation id {0}", dcInvocationId);
                if (exceptionOnDcNotFound != null)
                {
                    throw exceptionOnDcNotFound;
                }
            }
            return(result);
        }
        // Token: 0x06000812 RID: 2066 RVA: 0x00020B9C File Offset: 0x0001ED9C
        private void InitializeConfigSession()
        {
            PartitionId partitionId = PartitionId.LocalForest;

            if (this.ResourceForestFqdn != null)
            {
                partitionId = new PartitionId(this.ResourceForestFqdn);
            }
            this.configSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 650, "InitializeConfigSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\MailboxServerLocator.cs");
        }
Ejemplo n.º 15
0
        private ADObjectId GetRandomDatabasesFromForest(string resourceForestFqdn)
        {
            List <ADObjectId> list = null;
            bool flag = TargetForestAnchorMailbox.resourceForestToDatabaseMap.TryGetValue(resourceForestFqdn, out list);

            if (!flag || list == null || list.Count <= 0)
            {
                lock (TargetForestAnchorMailbox.forestDatabaseLock)
                {
                    flag = TargetForestAnchorMailbox.resourceForestToDatabaseMap.TryGetValue(resourceForestFqdn, out list);
                    if (!flag || list == null || list.Count <= 0)
                    {
                        list = new List <ADObjectId>();
                        PartitionId partitionId = new PartitionId(resourceForestFqdn);
                        ITopologyConfigurationSession resourceForestSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 318, "GetRandomDatabasesFromForest", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\AnchorMailbox\\TargetForestAnchorMailbox.cs");
                        SortBy sortBy = new SortBy(ADObjectSchema.WhenCreatedUTC, SortOrder.Ascending);
                        List <PropertyDefinition> databaseSchema = new List <PropertyDefinition>
                        {
                            ADObjectSchema.Id
                        };
                        long latency = 0L;
                        ADPagedReader <ADRawEntry> latency2 = LatencyTracker.GetLatency <ADPagedReader <ADRawEntry> >(() => resourceForestSession.FindPagedADRawEntry(resourceForestSession.ConfigurationNamingContext, QueryScope.SubTree, TargetForestAnchorMailbox.DatabaseQueryFilter, sortBy, TargetForestAnchorMailbox.DatabasesToLoadPerForest.Value, databaseSchema), out latency);
                        base.RequestContext.LatencyTracker.HandleResourceLatency(latency);
                        if (latency2 != null)
                        {
                            foreach (ADRawEntry adrawEntry in latency2)
                            {
                                list.Add(adrawEntry.Id);
                            }
                        }
                        if (list.Count > 0)
                        {
                            TargetForestAnchorMailbox.resourceForestToDatabaseMap[resourceForestFqdn] = list;
                            if (list.Count < TargetForestAnchorMailbox.MinimumDatabasesForEffectiveLoadBalancing.Value)
                            {
                                base.RequestContext.Logger.AppendGenericError("TooFewDbsForLoadBalancing", string.Format("DbCount:{0}/Forest:{1}", list.Count, resourceForestFqdn));
                            }
                        }
                    }
                }
            }
            if (list != null && list.Count > 0)
            {
                int index = TargetForestAnchorMailbox.seededRand.Next(0, list.Count);
                return(list[index]);
            }
            return(null);
        }
Ejemplo n.º 16
0
        private bool WaitForReplicationConvergenceInTargetForest(string domainController, TimeSpan timeout)
        {
            base.WriteVerbose(Strings.VerboseWaitingForReplicationInTargetForest);
            WatermarkMap watermarkMap = new WatermarkMap();
            ReadOnlyCollection <ADServer> readOnlyCollection = ADForest.GetForest(this.DataObject.TargetForest, null).FindRootDomain().FindAllDomainControllers();
            DateTime utcNow = DateTime.UtcNow;

            foreach (ADServer adserver in readOnlyCollection)
            {
                string          text;
                LocalizedString localizedString;
                if (SuitabilityVerifier.IsServerSuitableIgnoreExceptions(adserver.DnsHostName, false, null, out text, out localizedString))
                {
                    Guid         key;
                    WatermarkMap watermarkMap2;
                    long         value = this.ReadDcHighestUSN(this.DataObject.TargetOrganizationId.PartitionId, adserver.DnsHostName, false, out key, out watermarkMap2);
                    watermarkMap[key] = value;
                }
            }
            ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(this.DataObject.TargetOrganizationId.PartitionId), 514, "WaitForReplicationConvergenceInTargetForest", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\RemoveTenantRelocationRequest.cs");
            bool flag = false;

            while (!flag)
            {
                flag = this.CheckReplicationStatus(session, watermarkMap, false);
                if (flag || utcNow + timeout < DateTime.UtcNow)
                {
                    break;
                }
                Thread.Sleep(5000);
            }
            if (flag)
            {
                base.WriteVerbose(Strings.VerboseTargetDcIsUpToDate(domainController));
            }
            return(flag);
        }
Ejemplo n.º 17
0
        private IConfigurationSession CreateDomainNcSession()
        {
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(this.globalCatalog, true, ConsistencyMode.FullyConsistent, this.networkCredential, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(this.partitionId), 156, "CreateDomainNcSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ADForest.cs");

            tenantOrTopologyConfigurationSession.UseConfigNC         = false;
            tenantOrTopologyConfigurationSession.UseGlobalCatalog    = true;
            tenantOrTopologyConfigurationSession.EnforceDefaultScope = false;
            return(tenantOrTopologyConfigurationSession);
        }
Ejemplo n.º 18
0
        private void PopulateSingleServerMetrics(ADServerMetrics dcMetrics)
        {
            Exception ex = null;

            try
            {
                ExTraceGlobals.ResourceHealthManagerTracer.TraceDebug <string>((long)this.GetHashCode(), "[ADMetrics::PopulateSingleServerMetrics] Reading metrics for {0}.", dcMetrics.DnsHostName);
                string          text;
                LocalizedString localizedString;
                if (!SuitabilityVerifier.IsServerSuitableIgnoreExceptions(dcMetrics.DnsHostName, false, null, out text, out localizedString))
                {
                    ExTraceGlobals.ResourceHealthManagerTracer.TraceError <string, LocalizedString>((long)this.GetHashCode(), "[ADMetrics::PopulateSingleServerMetrics] Suitability checks failed for {0}: {1}", dcMetrics.DnsHostName, localizedString);
                    dcMetrics.ErrorMessage = localizedString;
                    return;
                }
                ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(dcMetrics.DnsHostName, true, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(new PartitionId(this.forestFqdn)), 470, "PopulateSingleServerMetrics", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\throttling\\ResourceHealth\\ADMetrics.cs");
                topologyConfigurationSession.UseGlobalCatalog = false;
                ExDateTime utcNow  = ExDateTime.UtcNow;
                RootDse    rootDse = topologyConfigurationSession.GetRootDse();
                dcMetrics.IsSynchronized = rootDse.IsSynchronized;
                if (!dcMetrics.IsSynchronized)
                {
                    ExTraceGlobals.ResourceHealthManagerTracer.TraceError <string>((long)this.GetHashCode(), "[ADMetrics::PopulateSingleServerMetrics] {0} is not synchronized yet.", dcMetrics.DnsHostName);
                    return;
                }
                MultiValuedProperty <ReplicationCursor>   source;
                MultiValuedProperty <ReplicationNeighbor> neighbors;
                topologyConfigurationSession.ReadReplicationData(topologyConfigurationSession.ConfigurationNamingContext, out source, out neighbors);
                IEnumerable <ReplicationCursor> replicationCursors = from cursor in source
                                                                     where neighbors.Any((ReplicationNeighbor neighbor) => this.NotNullAndEquals(neighbor.SourceDsa, cursor.SourceDsa))
                                                                     select cursor;
                ICollection <ADReplicationLinkMetrics> configReplicationMetrics = this.ReadReplicationMetrics(replicationCursors);
                topologyConfigurationSession.UseConfigNC = false;
                topologyConfigurationSession.ReadReplicationData(dcMetrics.ServerId.DomainId, out source, out neighbors);
                replicationCursors = from cursor in source
                                     where neighbors.Any((ReplicationNeighbor neighbor) => this.NotNullAndEquals(neighbor.SourceDsa, cursor.SourceDsa))
                                     select cursor;
                ICollection <ADReplicationLinkMetrics> domainReplicationMetrics = this.ReadReplicationMetrics(replicationCursors);
                dcMetrics.Initialize(utcNow, rootDse.HighestCommittedUSN, configReplicationMetrics, domainReplicationMetrics);
                dcMetrics.IsSuitable = true;
                ExTraceGlobals.ResourceHealthManagerTracer.TraceDebug <string>((long)this.GetHashCode(), "[ADMetrics::PopulateSingleServerMetrics] Finished reading metrics for {0}.", dcMetrics.DnsHostName);
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (ADOperationException ex3)
            {
                ex = ex3;
            }
            catch (OperationCanceledException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                ExTraceGlobals.ResourceHealthManagerTracer.TraceError <string, Exception>((long)this.GetHashCode(), "[ADMetrics::PopulateSingleServerMetrics] Failed to get read AD metrics from {0}: {1}", dcMetrics.DnsHostName, ex);
                dcMetrics.ErrorMessage = new LocalizedString(ex.Message);
            }
        }
Ejemplo n.º 19
0
        // Token: 0x0600017B RID: 379 RVA: 0x00007C0C File Offset: 0x00005E0C
        private ADObjectId GetRandomDatabasesFromForest(string resourceForestFqdn)
        {
            if (HttpProxySettings.LocalForestDatabaseEnabled.Value && Utilities.IsLocalForest(resourceForestFqdn))
            {
                return(LocalForestDatabaseProvider.Instance.GetRandomDatabase());
            }
            List <ADObjectId> list = null;

            if (!TargetForestAnchorMailbox.resourceForestToDatabaseMap.TryGetValue(resourceForestFqdn, out list) || list == null || list.Count <= 0)
            {
                object obj = TargetForestAnchorMailbox.forestDatabaseLock;
                lock (obj)
                {
                    if (!TargetForestAnchorMailbox.resourceForestToDatabaseMap.TryGetValue(resourceForestFqdn, out list) || list == null || list.Count <= 0)
                    {
                        list = new List <ADObjectId>();
                        PartitionId partitionId = new PartitionId(resourceForestFqdn);
                        ITopologyConfigurationSession resourceForestSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(2, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 306, "GetRandomDatabasesFromForest", "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\AnchorMailbox\\TargetForestAnchorMailbox.cs");
                        SortBy sortBy = new SortBy(ADObjectSchema.WhenCreatedUTC, 0);
                        List <PropertyDefinition> databaseSchema = new List <PropertyDefinition>
                        {
                            ADObjectSchema.Id
                        };
                        long latency = 0L;
                        ADPagedReader <ADRawEntry> latency2 = LatencyTracker.GetLatency <ADPagedReader <ADRawEntry> >(() => resourceForestSession.FindPagedADRawEntry(resourceForestSession.ConfigurationNamingContext, 2, TargetForestAnchorMailbox.DatabaseQueryFilter, sortBy, TargetForestAnchorMailbox.DatabasesToLoadPerForest.Value, databaseSchema, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\AnchorMailbox\\TargetForestAnchorMailbox.cs", 323, "GetRandomDatabasesFromForest"), out latency);
                        base.RequestContext.LatencyTracker.HandleResourceLatency(latency);
                        if (latency2 != null)
                        {
                            foreach (ADRawEntry adrawEntry in latency2)
                            {
                                list.Add(adrawEntry.Id);
                            }
                        }
                        if (list.Count > 0)
                        {
                            TargetForestAnchorMailbox.resourceForestToDatabaseMap[resourceForestFqdn] = list;
                            if (list.Count < TargetForestAnchorMailbox.MinimumDatabasesForEffectiveLoadBalancing.Value)
                            {
                                base.RequestContext.Logger.AppendGenericError("TooFewDbsForLoadBalancing", string.Format("DbCount:{0}/Forest:{1}", list.Count, resourceForestFqdn));
                            }
                        }
                    }
                }
            }
            if (list != null && list.Count > 0)
            {
                int index = TargetForestAnchorMailbox.seededRand.Next(0, list.Count);
                return(list[index]);
            }
            return(null);
        }
        private ExchangeConfigurationUnit CreateOrgConfigurationContainer(ADObjectId enclosureContainerId, OrganizationId targetSharedOrgId, string externalDirectoryOrganizationId, string programId, string offerId, bool isDehydrated, bool isStaticConfigurationShared, string sourceForestFqdn, Guid sourceObjectGuid, Guid sourceObjectExchangeObjectId, ITenantConfigurationSession targetForestTenantSession)
        {
            ExchangeConfigurationUnit exchangeConfigurationUnit = new ExchangeConfigurationUnit();

            exchangeConfigurationUnit.SetId(enclosureContainerId.GetChildId("Configuration"));
            exchangeConfigurationUnit.ExternalDirectoryOrganizationId = externalDirectoryOrganizationId;
            exchangeConfigurationUnit.RelocationStatusDetailsRaw      = RelocationStatusDetails.InitializationStarted;
            exchangeConfigurationUnit.OrganizationStatus        = OrganizationStatus.PendingArrival;
            exchangeConfigurationUnit.RelocationSourceForestRaw = sourceForestFqdn;
            exchangeConfigurationUnit.ProgramId    = programId;
            exchangeConfigurationUnit.OfferId      = offerId;
            exchangeConfigurationUnit.IsDehydrated = isDehydrated;
            exchangeConfigurationUnit.IsStaticConfigurationShared = isStaticConfigurationShared;
            exchangeConfigurationUnit.CorrelationId    = sourceObjectGuid;
            exchangeConfigurationUnit.ExchangeObjectId = sourceObjectExchangeObjectId;
            if (targetSharedOrgId != null)
            {
                exchangeConfigurationUnit.SupportedSharedConfigurations = new MultiValuedProperty <ADObjectId>();
                exchangeConfigurationUnit.SupportedSharedConfigurations.Add(targetSharedOrgId.ConfigurationUnit);
            }
            exchangeConfigurationUnit.Name = "Configuration";
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(targetForestTenantSession.SessionSettings.PartitionId), 546, "CreateOrgConfigurationContainer", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs");
            string parentLegacyDN = string.Format("{0}{1}", topologyConfigurationSession.GetAdministrativeGroup().LegacyExchangeDN, this.GetRelativeDNTillConfigurationUnits(exchangeConfigurationUnit.Id));

            exchangeConfigurationUnit.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, exchangeConfigurationUnit);
            targetForestTenantSession.Save(exchangeConfigurationUnit);
            return(exchangeConfigurationUnit);
        }