public static void CleanADOrphanAndInconsistency() { PartitionId[] allAccountPartitionIds = ADAccountPartitionLocator.GetAllAccountPartitionIds(); for (int i = 0; i < allAccountPartitionIds.Length; i++) { PartitionId partitionId = allAccountPartitionIds[i]; CommonUtils.CheckForServiceStopping(); ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); adsessionSettings.IncludeSoftDeletedObjects = true; adsessionSettings.IncludeInactiveMailbox = true; IRecipientSession recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, false, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 45, "CleanADOrphanAndInconsistency", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\ADInconsistencyCheck.cs"); IConfigurationSession configSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, false, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 52, "CleanADOrphanAndInconsistency", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\ADInconsistencyCheck.cs"); using (List <Guid> .Enumerator enumerator = MapiUtils.GetDatabasesOnThisServer().GetEnumerator()) { while (enumerator.MoveNext()) { Guid dbGuid = enumerator.Current; CommonUtils.CheckForServiceStopping(); DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(dbGuid, null, null, FindServerFlags.AllowMissing); if (databaseInformation.IsMissing) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistency Database {0} in Forest {1} is missing, skip it", new object[] { dbGuid, databaseInformation.ForestFqdn }); } else { CommonUtils.CatchKnownExceptions(delegate { ADInconsistencyCheck.CleanADOrphanAndInconsistencyForRequests(recipientSession, configSession, dbGuid); }, delegate(Exception f) { MrsTracer.Service.Error("CleanADOrphanAndInconsistency() failed for DB {0}. Error: {1}", new object[] { dbGuid, CommonUtils.FullExceptionMessage(f, true) }); MRSService.LogEvent(MRSEventLogConstants.Tuple_ScanADInconsistencyRequestFailEvent, new object[] { dbGuid, string.Empty, string.Empty, CommonUtils.FullExceptionMessage(f, true) }); }); } } } } }
// Token: 0x060007E9 RID: 2025 RVA: 0x0001D104 File Offset: 0x0001B304 internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) { if (session == null) { throw new ArgumentNullException("session"); } if (subTreeSession == null) { throw new ArgumentNullException("subTreeSession"); } EnumerableWrapper <T> enumerableWrapper = null; enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason)); if (enumerableWrapper.HasElements()) { return(enumerableWrapper); } if (!typeof(T).IsAssignableFrom(typeof(AccountPartition))) { return(enumerableWrapper); } if (this.fqdn != null) { ADObjectId adobjectId = ADSession.GetDomainNamingContextForLocalForest(); adobjectId = adobjectId.GetChildId("System").GetChildId(this.fqdn.ToString()); ADPagedReader <T> collection = session.FindPaged <T>(rootId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, AccountPartitionSchema.TrustedDomainLink, adobjectId.DistinguishedName), null, 0, null); enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, collection); if (enumerableWrapper.HasElements()) { return(enumerableWrapper); } Guid g; Guid.TryParse(this.fqdn, out g); if (TopologyProvider.LocalForestFqdn.Equals(this.fqdn.ToString(), StringComparison.OrdinalIgnoreCase) || ADObjectId.ResourcePartitionGuid.Equals(g)) { collection = session.FindPaged <T>(rootId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, AccountPartitionSchema.IsLocalForest, true), null, 0, null); enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, collection); } if (enumerableWrapper.HasElements()) { return(enumerableWrapper); } PartitionId partitionId; if (ADAccountPartitionLocator.IsSingleForestTopology(out partitionId) && this.fqdn.ToString().Equals(partitionId.ForestFQDN, StringComparison.OrdinalIgnoreCase) && partitionId.PartitionObjectId != null) { base.UpdateInternalADObjectId(new ADObjectId(partitionId.PartitionObjectId.Value)); enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetExactMatchObjects <T>(rootId, session, optionalData)); } } return(enumerableWrapper); }
private IEnumerable <string> GetForests() { Dictionary <string, bool> dictionary = new Dictionary <string, bool>(StringComparer.InvariantCultureIgnoreCase); if (ADResourceHealthMonitor.isMultiTenancyEnabled) { foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds()) { dictionary[partitionId.ForestFQDN] = true; } } dictionary[TopologyProvider.LocalForestFqdn] = true; return(dictionary.Keys); }
protected override void PopulateContextVariables() { base.PopulateContextVariables(); if (this.tenantCU != null) { string distinguishedName = this.tenantCU.OrganizationId.OrganizationalUnit.DistinguishedName; base.Fields["TenantOrganizationDN"] = distinguishedName; base.Fields["OrganizationHierarchicalPath"] = OrganizationIdParameter.GetHierarchicalIdentityFromDN(distinguishedName); base.Fields["TenantOrganizationObjectVersion"] = this.tenantCU.ObjectVersion; base.Fields["TenantDomainName"] = this.tenantFQDN.DomainName.ToString(); base.Fields["TenantExternalDirectoryOrganizationId"] = this.tenantCU.ExternalDirectoryOrganizationId; base.Fields["Partition"] = ADAccountPartitionLocator.GetAccountPartitionGuidByPartitionId(new PartitionId(this.tenantCU.Id)); } }
// Token: 0x060003B8 RID: 952 RVA: 0x00017530 File Offset: 0x00015730 private bool TryGetMailboxAccessPartnerInfo(CallContext callContext, ADRecipient callerAdRecipient, out PartnerInfo partnerInfo, out string targetTenant) { partnerInfo = null; targetTenant = null; if (!Common.IsMultiTenancyEnabled) { return(false); } if (callContext.Users.Count != 1) { return(false); } User user = callContext.Users[0]; SmtpAddress smtpAddress = new SmtpAddress(user.Mailbox); if (!smtpAddress.IsValidAddress) { return(false); } string name = callerAdRecipient.Name; SmtpDomain smtpDomain = new SmtpDomain(smtpAddress.Domain); OrganizationId organizationId = DomainToOrganizationIdCache.Singleton.Get(smtpDomain); if (organizationId != null && !ADAccountPartitionLocator.IsKnownPartition(organizationId.PartitionId)) { organizationId = null; } OrganizationId organizationId2 = callerAdRecipient.OrganizationId; if (organizationId != null && organizationId.Equals(organizationId2)) { ExTraceGlobals.FrameworkTracer.TraceDebug <string, OrganizationId>((long)this.GetHashCode(), "The caller {0} tries to query its' own org {1}", name, organizationId2); return(false); } partnerInfo = MailboxAccessPartnerInfoCache.Singleton.Get(new MailboxAccessPartnerInfoCacheKey(callerAdRecipient.Id, organizationId2)); if (partnerInfo == PartnerInfo.Invalid) { ExTraceGlobals.FrameworkTracer.TraceDebug <string>((long)this.GetHashCode(), "The caller {0} could not be acted as mailbox access partner.", name); return(false); } if (!partnerInfo.HasPartnerRelationship(organizationId)) { ExTraceGlobals.FrameworkTracer.TraceDebug <string, OrganizationId>((long)this.GetHashCode(), "The caller {0} has no partner relationship with organization {1}", name, organizationId); return(false); } targetTenant = smtpDomain.Domain; return(true); }
protected override void InternalBeginProcessing() { TaskLogger.LogEnter(); LocalizedString empty = LocalizedString.Empty; this.Name = MailboxTaskHelper.GetNameOfAcceptableLengthForMultiTenantMode(this.Name, out empty); if (empty != LocalizedString.Empty) { this.WriteWarning(empty); } base.InternalBeginProcessing(); if (this.Organization == null) { if (base.CurrentOrganizationId == OrganizationId.ForestWideOrgId) { base.WriteError(new ArgumentException(Strings.ErrorOrganizationParameterRequired), ErrorCategory.InvalidOperation, null); } else { this.Organization = new OrganizationIdParameter(base.CurrentOrganizationId.OrganizationalUnit.Name); } } base.CurrentOrganizationId = this.ResolveCurrentOrganization(); OrganizationTaskHelper.ValidateParamString("Name", this.Name, new Task.TaskErrorLoggingDelegate(base.WriteError)); if (base.Fields["AuthenticationType"] == null) { this.AuthenticationType = AuthenticationType.Managed; } if (base.Fields["LiveIdInstanceType"] == null) { this.LiveIdInstanceType = LiveIdInstanceType.Consumer; } base.Fields["OutBoundOnly"] = this.OutBoundOnly; base.Fields["MakeDefault"] = this.MakeDefault; string value = string.Empty; if (this.Organization != null) { PartitionId partitionIdByAcceptedDomainName = ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(this.Organization.RawIdentity); if (partitionIdByAcceptedDomainName != null) { value = base.ServerSettings.PreferredGlobalCatalog(partitionIdByAcceptedDomainName.ForestFQDN); } } base.Fields["PreferredServer"] = value; TaskLogger.LogExit(); }
// Token: 0x06000C79 RID: 3193 RVA: 0x000272A4 File Offset: 0x000254A4 internal OrganizationId ResolveOrganizationId() { if (string.IsNullOrEmpty(base.RawIdentity) || string.IsNullOrEmpty(base.RawIdentity.Trim())) { throw new ArgumentException("Cannot resolve tenant name - RawIdentity is null or empty"); } ExchangeConfigurationUnit exchangeConfigurationUnit = null; try { PartitionId partitionId = ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(base.RawIdentity); ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants; ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 142, "ResolveOrganizationId", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\TenantRelocationRequestIdParameter.cs"); exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByName(base.RawIdentity); } catch (CannotResolveTenantNameException) { } if (exchangeConfigurationUnit == null) { foreach (PartitionId partitionId2 in ADAccountPartitionLocator.GetAllAccountPartitionIds()) { ADSessionSettings adsessionSettings2 = ADSessionSettings.FromAllTenantsPartitionId(partitionId2); adsessionSettings2.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants; ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, adsessionSettings2, 160, "ResolveOrganizationId", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\TenantRelocationRequestIdParameter.cs"); exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByName(base.RawIdentity); if (exchangeConfigurationUnit != null) { break; } } } if (exchangeConfigurationUnit != null && !string.IsNullOrEmpty(exchangeConfigurationUnit.RelocationSourceForestRaw)) { PartitionId partitionId = new PartitionId(exchangeConfigurationUnit.RelocationSourceForestRaw); ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants; ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 175, "ResolveOrganizationId", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\TenantRelocationRequestIdParameter.cs"); exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByName(base.RawIdentity); } if (exchangeConfigurationUnit != null) { return(exchangeConfigurationUnit.OrganizationId); } throw new CannotResolveTenantNameException(DirectoryStrings.CannotResolveTenantRelocationRequestIdentity(base.RawIdentity)); }
private static PartitionId ChoosePartition(string name, bool createSharedConfiguration, Task.TaskErrorLoggingDelegate errorLogger) { PartitionId[] allAccountPartitionIdsEnabledForProvisioning = ADAccountPartitionLocator.GetAllAccountPartitionIdsEnabledForProvisioning(); if (createSharedConfiguration) { if (allAccountPartitionIdsEnabledForProvisioning.Length == 1) { return(allAccountPartitionIdsEnabledForProvisioning[0]); } if (string.IsNullOrEmpty(name)) { return(PartitionId.LocalForest); } errorLogger(new ArgumentException(Strings.ErrorAccountPartitionRequired), ErrorCategory.InvalidArgument, null); } return(ADAccountPartitionLocator.SelectAccountPartitionForNewTenant(name)); }
protected override void InternalValidate() { base.InternalValidate(); if (this.AccountPartition != null) { PartitionId partitionId; Guid guid; if (ADAccountPartitionLocator.IsSingleForestTopology(out partitionId) && Guid.TryParse(this.AccountPartition.RawIdentity, out guid) && guid.Equals(ADObjectId.ResourcePartitionGuid)) { this.accountPartitionId = partitionId; } if (null == this.accountPartitionId) { this.accountPartitionId = RecipientTaskHelper.ResolvePartitionId(this.AccountPartition, new Task.TaskErrorLoggingDelegate(base.WriteError)); } } }
// Token: 0x0600017A RID: 378 RVA: 0x00007B84 File Offset: 0x00005D84 private string GetResourceForestFqdnByAcceptedDomainName(string tenantAcceptedDomain) { string resourceForestFqdn; if (!TargetForestAnchorMailbox.domainToResourceForestMap.TryGetValue(tenantAcceptedDomain, ref resourceForestFqdn)) { long latency = 0L; resourceForestFqdn = LatencyTracker.GetLatency <string>(delegate() { resourceForestFqdn = ADAccountPartitionLocator.GetResourceForestFqdnByAcceptedDomainName(tenantAcceptedDomain); return(resourceForestFqdn); }, out latency); TargetForestAnchorMailbox.domainToResourceForestMap.TryInsertAbsolute(tenantAcceptedDomain, resourceForestFqdn, TargetForestAnchorMailbox.DomainForestAbsoluteTimeout.Value); base.RequestContext.LatencyTracker.HandleGlsLatency(latency); } return(resourceForestFqdn); }
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); } }
internal static void ValidateDomainName(AcceptedDomain domain, Task.TaskErrorLoggingDelegate errorWriter) { string domain2 = domain.DomainName.Domain; DuplicateAcceptedDomainException ex = new DuplicateAcceptedDomainException(domain2); ConflictingAcceptedDomainException conflictingAcceptedDomainException = new ConflictingAcceptedDomainException(domain2); Exception ex2; if (!ADAccountPartitionLocator.ValidateDomainName(domain, ex, conflictingAcceptedDomainException, out ex2)) { ErrorCategory category = ErrorCategory.InvalidOperation; if (ex2 == ex) { category = ErrorCategory.ResourceExists; } errorWriter(ex2, category, domain); } }
internal override ADSessionSettings FromTenantAcceptedDomain(string domain) { if (domain == null) { throw new ArgumentNullException("domain"); } ExTraceGlobals.GetConnectionTracer.TraceDebug <string>((long)domain.GetHashCode(), "FromTenantAcceptedDomain(): Resolving domainName '{0}' into partition", domain); string text = null; Guid empty = Guid.Empty; ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(domain, out text, out empty); if (empty != Guid.Empty) { return(ADSessionSettings.SessionSettingsFactory.Default.FromExternalDirectoryOrganizationId(empty)); } ExTraceGlobals.GetConnectionTracer.TraceDebug <string>((long)domain.GetHashCode(), "FromTenantAcceptedDomain(): Failed to resolve domainName '{0}' to partition", domain); throw new CannotResolveTenantNameException(DirectoryStrings.CannotResolveTenantNameByAcceptedDomain(domain)); }
// Token: 0x0600081B RID: 2075 RVA: 0x000214F4 File Offset: 0x0001F6F4 private string GetResourceForestFqdnByAcceptedDomainName(string tenantAcceptedDomain) { Stopwatch stopwatch = new Stopwatch(); string resourceForestFqdnByAcceptedDomainName; try { stopwatch.Start(); resourceForestFqdnByAcceptedDomainName = ADAccountPartitionLocator.GetResourceForestFqdnByAcceptedDomainName(tenantAcceptedDomain); } finally { stopwatch.Stop(); long elapsedMilliseconds = stopwatch.ElapsedMilliseconds; this.glsLatencies.Add(elapsedMilliseconds); } return(resourceForestFqdnByAcceptedDomainName); }
protected override void InternalStateReset() { this.accountPartition = null; if (this.AccountPartition != null) { this.accountPartition = RecipientTaskHelper.ResolvePartitionId(this.AccountPartition, new Task.TaskErrorLoggingDelegate(base.WriteError)); } PartitionId partitionId; if (this.RequestForMultipleOrgs() && this.accountPartition == null && ADAccountPartitionLocator.IsSingleForestTopology(out partitionId)) { this.accountPartition = partitionId; this.WriteWarning(Strings.ImplicitPartitionIdSupplied(this.accountPartition.ToString())); } if (this.Identity != null) { this.Identity.AccountPartition = this.accountPartition; } base.InternalStateReset(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { base.InternalValidate(); if (!base.HasErrors) { this.ServerObject = TestTopologyServiceTask.EnsureSingleObject <Server>(() => this.Server.GetObjects <Server>(null, this.SystemConfigurationSession)); if (this.ServerObject == null) { throw new CasHealthMailboxServerNotFoundException(this.Server.ToString()); } if (this.PartitionFqdn == null) { PartitionId[] array = Globals.IsDatacenter ? ADAccountPartitionLocator.GetAllAccountPartitionIds() : new PartitionId[] { PartitionId.LocalForest }; this.PartitionFqdn = array[new Random().Next(0, array.Length)].ForestFQDN; } if (this.TargetDomainController == null && (this.OperationType == TopologyServiceOperationTypeEnum.ReportServerDown || this.OperationType == TopologyServiceOperationTypeEnum.SetConfigDC)) { throw new TopologyServiceMissingDC(this.OperationType.ToString()); } } } catch (LocalizedException exception) { this.WriteError(exception, ErrorCategory.OperationStopped, this, true); } finally { TaskLogger.LogExit(); } }
protected override ADServerSettings GetCmdletADServerSettings() { PropertyBag fields = base.CurrentTaskContext.InvocationInfo.Fields; SwitchParameter switchParameter = fields.Contains("IsDatacenter") ? ((SwitchParameter)fields["IsDatacenter"]) : new SwitchParameter(false); bool flag = fields.Contains("DomainController"); OrganizationIdParameter organizationIdParameter = (OrganizationIdParameter)fields["PrimaryOrganization"]; PartitionId partitionId = (organizationIdParameter != null) ? ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(organizationIdParameter.RawIdentity) : null; string value = null; ADServerSettings serverSettings = ExchangePropertyContainer.GetServerSettings(base.CurrentTaskContext.SessionState); if (serverSettings != null && partitionId != null) { value = serverSettings.PreferredGlobalCatalog(partitionId.ForestFQDN); } if (switchParameter && organizationIdParameter != null && string.IsNullOrEmpty(value) && partitionId != null && !flag) { if (this.domainBasedADServerSettings == null) { this.domainBasedADServerSettings = RunspaceServerSettings.CreateGcOnlyRunspaceServerSettings(organizationIdParameter.RawIdentity.ToLowerInvariant(), partitionId.ForestFQDN, false); } return(this.domainBasedADServerSettings); } return(base.GetCmdletADServerSettings()); }
internal ExchangeConfigurationUnit GetConfigurationUnit(string orgName) { if (string.IsNullOrEmpty(orgName)) { throw new ArgumentException("OrgName must contain a non-empty value", "orgName"); } ExchangeConfigurationUnit exchangeConfigurationUnit = null; try { ADSessionSettings adsessionSettings = ADSessionSettings.FromTenantCUName(orgName); ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 866, "GetConfigurationUnit", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs"); adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants; exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByName(orgName); } catch (CannotResolveTenantNameException) { } SmtpDomain smtpDomain = null; if (exchangeConfigurationUnit == null && SmtpDomain.TryParse(orgName, out smtpDomain)) { try { ADSessionSettings sessionSettings = ADSessionSettings.FromTenantAcceptedDomain(orgName); ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 890, "GetConfigurationUnit", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs"); exchangeConfigurationUnit = tenantConfigurationSession.GetExchangeConfigurationUnitByNameOrAcceptedDomain(orgName); } catch (CannotResolveTenantNameException) { } } Guid externalDirectoryOrganizationId; if (exchangeConfigurationUnit == null && GuidHelper.TryParseGuid(orgName, out externalDirectoryOrganizationId)) { try { PartitionId partitionIdByExternalDirectoryOrganizationId = ADAccountPartitionLocator.GetPartitionIdByExternalDirectoryOrganizationId(externalDirectoryOrganizationId); ADSessionSettings sessionSettings2 = ADSessionSettings.FromAllTenantsPartitionId(partitionIdByExternalDirectoryOrganizationId); ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings2, 911, "GetConfigurationUnit", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\ADIdParameter.cs"); QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ExchangeConfigurationUnitSchema.ExternalDirectoryOrganizationId, externalDirectoryOrganizationId.ToString()); ExchangeConfigurationUnit[] array = tenantConfigurationSession.Find <ExchangeConfigurationUnit>(ADSession.GetConfigurationUnitsRoot(partitionIdByExternalDirectoryOrganizationId.ForestFQDN), QueryScope.SubTree, filter, null, 0); if (array.Length == 1) { exchangeConfigurationUnit = array[0]; } } catch (CannotResolveExternalDirectoryOrganizationIdException) { } } return(exchangeConfigurationUnit); }
private IList <ExchangePrincipal> GetSyncMailboxPrincipals(Guid mailboxDatabaseGuid, IDirectorySession configSession) { List <ExchangePrincipal> list = new List <ExchangePrincipal>(); ADObjectId id = new ADObjectId(mailboxDatabaseGuid); Result <MailboxDatabase>[] dataBases = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { dataBases = configSession.FindByADObjectIds <MailboxDatabase>(new ADObjectId[] { id }); }, 3); if (!adoperationResult.Succeeded) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, string.Format("GetSyncMailboxPrincipals: failed to find database {0} in active directory because of {1}", mailboxDatabaseGuid, adoperationResult.Exception), adoperationResult.Exception); } if (dataBases != null && dataBases.Length > 0) { PartitionId[] allAccountPartitionIds = ADAccountPartitionLocator.GetAllAccountPartitionIds(); for (int i = 0; i < allAccountPartitionIds.Length; i++) { PartitionId partitionId = allAccountPartitionIds[i]; IRecipientSession recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 238, "GetSyncMailboxPrincipals", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\UnifiedPolicy\\NotificationLoader.cs"); ADUser[] arbMbxs = null; adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { arbMbxs = recipientSession.FindPaged <ADUser>(RecipientFilterHelper.DiscoveryMailboxFilterUnifiedPolicy(dataBases[0].Data.Id), null, true, null, 0).ToArray <ADUser>(); }, 3); if (!adoperationResult.Succeeded) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, string.Format("GetSyncMailboxPrincipals: failed to find sync mailboxes in database {0} in active directory because of {1}", mailboxDatabaseGuid, adoperationResult.Exception), adoperationResult.Exception); } if (arbMbxs != null && arbMbxs.Length > 0) { ADUser[] arbMbxs2 = arbMbxs; int j = 0; while (j < arbMbxs2.Length) { ADUser aduser = arbMbxs2[j]; this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, string.Format("GetSyncMailboxPrincipals: found sync mailbox {0} in database {1} in partition {2}", aduser.UserPrincipalName, mailboxDatabaseGuid, partitionId), null); ExchangePrincipal item = null; try { item = ExchangePrincipal.FromADUser(ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(aduser.OrganizationId), aduser, RemotingOptions.LocalConnectionsOnly); } catch (StoragePermanentException exception) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, string.Format("GetSyncMailboxPrincipals: sync mailbox {0} is skipped because of StoragePermanentException in ExchangePrincipal construction", aduser.UserPrincipalName), exception); goto IL_20F; } catch (StorageTransientException exception2) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, string.Format("GetSyncMailboxPrincipals: sync mailbox {0} is skipped because of StorageTransientException in ExchangePrincipal construction", aduser.UserPrincipalName), exception2); goto IL_20F; } goto IL_207; IL_20F: j++; continue; IL_207: list.Add(item); goto IL_20F; } } else { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, string.Format("GetSyncMailboxPrincipals: there is no sync mailboxes in database {0} in active directory", mailboxDatabaseGuid), null); } } } return(list); }
public string FindResourceForestFqdnByExternalDirectoryOrganizationId(Guid externalDirectoryOrganizationId, IRoutingDiagnostics diagnostics) { return(ADAccountPartitionLocator.GetResourceForestFqdnByExternalDirectoryOrganizationId(externalDirectoryOrganizationId)); }
public string FindResourceForestFqdnByAcceptedDomainName(string acceptedDomain, IRoutingDiagnostics diagnostics) { return(ADAccountPartitionLocator.GetResourceForestFqdnByAcceptedDomainName(acceptedDomain)); }
// Token: 0x0600034D RID: 845 RVA: 0x000152D0 File Offset: 0x000134D0 protected bool TryGetOrganizationId(UserResultMapping userResultMapping, out OrganizationId organizationId) { organizationId = DomainToOrganizationIdCache.Singleton.Get(new SmtpDomain(userResultMapping.SmtpAddress.Domain)); bool flag = organizationId == OrganizationId.ForestWideOrgId || (organizationId != null && ADAccountPartitionLocator.IsKnownPartition(organizationId.PartitionId)); if (!flag) { organizationId = null; } return(flag); }