internal static bool IsTenantIdentity(ADObjectId id, string partitionFqdn) { if (ADSession.IsBoundToAdam || id.DomainId == null) { return(false); } if (!string.Equals(id.GetPartitionId().ForestFQDN, partitionFqdn, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("Object partition FQDN doesn't match partitionFqdn parameter."); } ADObjectId configurationNamingContext = ADSession.GetConfigurationNamingContext(partitionFqdn); if (id.Equals(configurationNamingContext)) { return(false); } ADObjectId domainNamingContext = ADSession.GetDomainNamingContext(partitionFqdn); if (id.Equals(domainNamingContext)) { return(false); } ADObjectId configurationUnitsRoot = ADSession.GetConfigurationUnitsRoot(partitionFqdn); if (id.IsDescendantOf(configurationUnitsRoot)) { return(true); } ADObjectId hostedOrganizationsRoot = ADSession.GetHostedOrganizationsRoot(partitionFqdn); return(id.IsDescendantOf(hostedOrganizationsRoot) && !id.Equals(hostedOrganizationsRoot)); }
protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { if (filter != null && !(filter is FalseFilter)) { throw new NotSupportedException("filter"); } if (rootId != null && rootId is ADObjectId && !ADObjectId.Equals((ADObjectId)rootId, base.MailboxSession.MailboxOwner.ObjectId)) { throw new NotSupportedException("rootId"); } if (!typeof(MailboxDiagnosticLogs).IsAssignableFrom(typeof(T))) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } MailboxDiagnosticLogs mailboxDiagnosticLog = (MailboxDiagnosticLogs)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); if (this.getProperties) { mailboxDiagnosticLog.LogName = "ExtendedProperties"; mailboxDiagnosticLog.MailboxLog = this.ReadMailboxTableProperties(); } else { mailboxDiagnosticLog.LogName = this.componentName; mailboxDiagnosticLog.MailboxLog = this.ReadLogs(); } if (mailboxDiagnosticLog.MailboxLog == null) { throw new ObjectNotFoundException(Strings.ExportMailboxDiagnosticLogsComponentNotFound(this.componentName ?? "$null", base.MailboxSession.MailboxOwner.MailboxInfo.DisplayName, this.GetAvailableLogNames())); } mailboxDiagnosticLog[SimpleProviderObjectSchema.Identity] = base.MailboxSession.MailboxOwner.ObjectId; yield return((T)((object)mailboxDiagnosticLog)); yield break; }
private static ADObjectId FindServerIdWithClientAccess(ITopologyConfigurationSession adSession, ADObjectId mountedSiteId, ADObjectId preferredServerId) { ADObjectId adobjectId = null; List <ADObjectId> list = new List <ADObjectId>(8); foreach (KeyValuePair <Server, ExchangeRpcClientAccess> keyValuePair in ExchangeRpcClientAccess.GetServersWithRpcClientAccessEnabled(ExchangeRpcClientAccess.GetAllPossibleServers(adSession, mountedSiteId), ExchangeRpcClientAccess.GetAll(adSession))) { if ((keyValuePair.Value.Responsibility & RpcClientAccessResponsibility.Mailboxes) != RpcClientAccessResponsibility.None) { if (preferredServerId != null && preferredServerId.Equals(keyValuePair.Key.Id)) { adobjectId = keyValuePair.Key.Id; break; } list.Add(keyValuePair.Key.Id); } } if (adobjectId == null && list.Count > 0) { adobjectId = list[0]; if (list.Count > 1) { adobjectId = list[(Environment.TickCount & int.MaxValue) % list.Count]; } } return(adobjectId); }
internal bool IsScopeSmallerOrEqualThan(ManagementScope scope, out LocalizedString notTrueReason) { notTrueReason = LocalizedString.Empty; if (object.ReferenceEquals(this, scope)) { return(true); } if (scope == null) { ExTraceGlobals.AccessCheckTracer.TraceDebug(11000L, "IsScopeSmallerOrEqualThan: cannot compare this instance with $NULL"); return(false); } ExTraceGlobals.AccessCheckTracer.TraceFunction <ADObjectId, ADObjectId>(11000L, "-->IsScopeSmallerOrEqualThan: this = {0}, other = {1}", base.Id, scope.Id); if (this.ScopeRestrictionType == scope.ScopeRestrictionType && ADObjectId.Equals(this.RecipientRoot, scope.RecipientRoot) && string.Equals(this.Filter, scope.Filter, StringComparison.OrdinalIgnoreCase)) { ExTraceGlobals.AccessCheckTracer.TraceDebug(11000L, "IsScopeSmallerOrEqualThan: both management scopes have exactly the same restrction type, root and filter."); return(true); } if (this.ScopeRestrictionType == ScopeRestrictionType.RecipientScope && scope.ScopeRestrictionType == ScopeRestrictionType.RecipientScope && string.Equals(this.Filter, scope.Filter, StringComparison.OrdinalIgnoreCase) && this.RecipientRoot != null && scope.RecipientRoot != null) { ExTraceGlobals.AccessCheckTracer.TraceDebug <ADObjectId, ADObjectId>(11000L, "IsScopeSmallerOrEqualThan: comparing the Root of two scope objects: this (Root = {0}), other (Root = {1})", this.RecipientRoot, scope.RecipientRoot); if (this.RecipientRoot.IsDescendantOf(scope.RecipientRoot)) { return(true); } notTrueReason = DirectoryStrings.OUsNotSmallerOrEqual(this.RecipientRoot.ToString(), scope.RecipientRoot.ToString()); } else { notTrueReason = DirectoryStrings.CannotCompareScopeObjects(base.Id.ToString(), scope.Id.ToString()); ExTraceGlobals.AccessCheckTracer.TraceDebug(11000L, "IsScopeSmallerOrEqualThan: non-comparable scope objects. We can only compare scope scope objects of RecipientScope with non-empty root and equivalent filter."); } ExTraceGlobals.AccessCheckTracer.TraceFunction(11000L, "<--IsScopeSmallerOrEqualThan: return false"); return(false); }
// Token: 0x06000326 RID: 806 RVA: 0x00011034 File Offset: 0x0000F234 private static bool ValidateDomainName(AcceptedDomain domain, IConfigurationSession session, Exception duplicateAcceptedDomainException, Exception conflictingAcceptedDomainException, out Exception error) { error = null; string domain2 = domain.DomainName.Domain; QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Guid, domain.Guid), new OrFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, domain2), new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, "*." + domain2) }) }); AcceptedDomain[] array = session.Find <AcceptedDomain>(null, QueryScope.SubTree, filter, null, 1); if (array.Length != 0) { error = duplicateAcceptedDomainException; return(false); } List <QueryFilter> list = new List <QueryFilter>(AcceptedDomain.ConflictingDomainFilters(domain, false)); QueryFilter filter2 = new OrFilter(list.ToArray()); foreach (AcceptedDomain acceptedDomain in session.FindPaged <AcceptedDomain>(null, QueryScope.SubTree, filter2, null, 0)) { if (!ADObjectId.Equals(domain.Id.Parent, acceptedDomain.Id.Parent)) { error = conflictingAcceptedDomainException; return(false); } } return(true); }
protected string DiscoverServerToQuery(ServerIdParameter serverToContactParam, DatabaseAvailabilityGroup dag) { string fqdn; if (serverToContactParam == null) { AmServerName primaryActiveManager = this.GetPrimaryActiveManager(dag); fqdn = primaryActiveManager.Fqdn; } else { Server server = this.LookupServer(serverToContactParam); ADObjectId databaseAvailabilityGroup = server.DatabaseAvailabilityGroup; if (databaseAvailabilityGroup == null) { base.WriteError(new ServerMustBeInDagException(server.Fqdn), ErrorCategory.InvalidData, serverToContactParam); return(null); } if (!databaseAvailabilityGroup.Equals(dag.Id)) { base.WriteError(new ServerToContactMustBeInSameDagException(server.Name, dag.Name, databaseAvailabilityGroup.Name), ErrorCategory.InvalidData, serverToContactParam); return(null); } fqdn = server.Fqdn; } return(fqdn); }
private void CheckDagMembership() { ADObjectId databaseAvailabilityGroup = this.m_server.DatabaseAvailabilityGroup; if (ADObjectId.IsNullOrEmpty(databaseAvailabilityGroup)) { base.WriteError(new AddDatabaseCopyNewCopyMustBeInDagException(this.m_server.Name, this.DataObject.Name), ErrorCategory.InvalidArgument, null); } DatabaseAvailabilityGroup databaseAvailabilityGroup2 = (DatabaseAvailabilityGroup)base.DataSession.Read <DatabaseAvailabilityGroup>(databaseAvailabilityGroup); if (databaseAvailabilityGroup2 == null) { base.WriteError(new AddDatabaseCopyNewCopyMustBeInDagException(this.m_server.Name, this.DataObject.Name), ErrorCategory.InvalidArgument, null); } if (ThirdPartyReplicationMode.Enabled == databaseAvailabilityGroup2.ThirdPartyReplication) { this.m_isThirdPartyReplicationEnabled = true; } ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession; foreach (DatabaseCopy databaseCopy in this.m_databaseCopies) { ADObjectId hostServer = databaseCopy.HostServer; MiniServer miniServer = topologyConfigurationSession.ReadMiniServer(hostServer, AddMailboxDatabaseCopy.s_miniServerProperties); ADObjectId databaseAvailabilityGroup3 = miniServer.DatabaseAvailabilityGroup; if (ADObjectId.IsNullOrEmpty(databaseAvailabilityGroup3)) { base.WriteError(new AddDatabaseCopyAllCopiesMustBeInTheDagException(this.DataObject.Name, this.m_server.Name, databaseAvailabilityGroup2.Name, miniServer.Name), ErrorCategory.InvalidArgument, null); } else if (!databaseAvailabilityGroup3.Equals(databaseAvailabilityGroup)) { base.WriteError(new AddDatabaseCopyAllCopiesMustBeInSameDagException(this.DataObject.Name, this.m_server.Name, databaseAvailabilityGroup2.Name, miniServer.Name, databaseAvailabilityGroup3.Name), ErrorCategory.InvalidArgument, null); } } }
// Token: 0x060009CA RID: 2506 RVA: 0x0002121C File Offset: 0x0001F41C internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) { if (typeof(T) != typeof(ExtendedRight)) { throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type"); } if (session == null) { throw new ArgumentNullException("session"); } if (ExtendedRightIdParameter.AllExtendedRights == null) { ADPagedReader <ExtendedRight> adpagedReader = ((ITopologyConfigurationSession)session).GetAllExtendedRights(); ExtendedRightIdParameter.allExtendedRights = adpagedReader.ReadAllPages(); } base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason); List <T> list = new List <T>(); foreach (ExtendedRight extendedRight in ExtendedRightIdParameter.AllExtendedRights) { if (ADObjectId.Equals(extendedRight.Id, base.InternalADObjectId) || (base.InternalADObjectId != null && base.InternalADObjectId.ObjectGuid == extendedRight.RightsGuid) || (base.RawIdentity != null && (string.Compare(extendedRight.DisplayName, base.RawIdentity, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(extendedRight.Name, base.RawIdentity, StringComparison.OrdinalIgnoreCase) == 0))) { list.Add((T)((object)extendedRight)); break; } } return(list); }
private ADRawEntry ChooseBetweenAmbiguousUsers(ADRawEntry[] entries, int lower, int upper) { if (lower >= upper) { throw new ArgumentException("lower bound is equal or greater than upper bound"); } if (lower + 1 == upper) { return(entries[lower]); } int num = (upper - lower) / 2; ADRawEntry adrawEntry = this.ChooseBetweenAmbiguousUsers(entries, lower, lower + num); ADRawEntry adrawEntry2 = this.ChooseBetweenAmbiguousUsers(entries, lower + num, upper); if (adrawEntry == null || adrawEntry2 == null) { return(null); } ADObjectId adobjectId = this.ChooseBetweenAmbiguousUsers(adrawEntry.Id, adrawEntry2.Id); if (adobjectId == null) { return(null); } if (ADObjectId.Equals(adrawEntry.Id, adobjectId)) { return(adrawEntry); } return(adrawEntry2); }
internal static bool AccessCheck(ADObjectId accessRequestedForId, ADObjectId executingUserId, IRecipientSession session, out string diagnosticText) { diagnosticText = string.Empty; if (executingUserId == null) { diagnosticText = "ExecutingUserId is null, access denied. BypassDelegateChecking must be specified to use message-tracking."; return(false); } ADUser aduser = session.Read(executingUserId) as ADUser; if (aduser == null) { diagnosticText = string.Format("Could not find user with ID {0}. Aborting authorization check.", executingUserId); return(false); } if (executingUserId.Equals(accessRequestedForId)) { ExTraceGlobals.TaskTracer.TraceDebug <string>(0L, "Authenticated user {0} tracking as self.", aduser.Alias); return(true); } ADUser accessRequestedForADUser = (ADUser)session.Read(accessRequestedForId); bool flag = Utils.CheckFullAccessPermissions(aduser, accessRequestedForADUser, session); if (!flag) { diagnosticText = "Access check failed."; } return(flag); }
// 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)); }
private void GetTenantRecipientStatistics(ADObjectId organizationId) { SqlDataReader sqlDataReader = null; base.TraceInfo("Getting service status for tenant: {0}", new object[] { organizationId.Name }); Guid guid = organizationId.Equals(base.RootOrgContainerId) ? Guid.Empty : organizationId.ObjectGuid; try { string sqlConnectionString = base.GetSqlConnectionString(); using (SqlConnection sqlConnection = new SqlConnection(sqlConnectionString)) { base.TraceInfo("Opening SQL connecttion: {0}", new object[] { sqlConnectionString }); sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand("[Exchange2010].[RecipientStatisticsReport]", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.Add("@TenantGuid", SqlDbType.UniqueIdentifier).Value = guid; base.TraceInfo("Executing stored procedure: {0}", new object[] { "[Exchange2010].[RecipientStatisticsReport]" }); sqlDataReader = sqlCommand.ExecuteReader(); base.TraceInfo("Processing Recipient Statistics data for tenant: {0}", new object[] { organizationId.Name }); this.ProcessTenantRecipientStatistics(organizationId, sqlDataReader); base.TraceInfo("Finished Recipient Statistics data for tenant: {0}", new object[] { organizationId.Name }); } } catch (SqlException ex) { base.WriteError(new SqlReportingConnectionException(ex.Message), (ErrorCategory)1000, null); } catch (InvalidOperationException ex2) { base.WriteError(new SqlReportingConnectionException(ex2.Message), (ErrorCategory)1001, null); } finally { if (sqlDataReader != null) { sqlDataReader.Close(); } } }
public ADObjectId ChooseBetweenAmbiguousUsers(ADObjectId user1Id, ADObjectId user2Id) { ADObjectId result = null; ADUser aduser = base.FindADUserByObjectId(user1Id); ADUser aduser2 = base.FindADUserByObjectId(user2Id); if (aduser != null && aduser2 != null && !user1Id.Equals(user2Id) && aduser.RecipientType == aduser2.RecipientType && aduser.RecipientTypeDetails == aduser2.RecipientTypeDetails && aduser.NetID != null && aduser2.NetID != null && aduser.WindowsLiveID != SmtpAddress.Empty && aduser2.WindowsLiveID != SmtpAddress.Empty && aduser.NetID.Equals(aduser2.NetID) && aduser.WindowsLiveID == aduser2.WindowsLiveID && aduser.OrganizationId != null && aduser.OrganizationId.ConfigurationUnit != null && aduser2.OrganizationId != null && aduser2.OrganizationId.ConfigurationUnit != null) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsPartitionId(base.SessionSettings.PartitionId), 142, "ChooseBetweenAmbiguousUsers", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Recipient\\ADTenantRecipientSession.cs"); ExchangeConfigurationUnit exchangeConfigurationUnit = tenantOrTopologyConfigurationSession.Read <ExchangeConfigurationUnit>(aduser.OrganizationId.ConfigurationUnit); ExchangeConfigurationUnit exchangeConfigurationUnit2 = tenantOrTopologyConfigurationSession.Read <ExchangeConfigurationUnit>(aduser2.OrganizationId.ConfigurationUnit); if (exchangeConfigurationUnit != null && exchangeConfigurationUnit2 != null) { if (exchangeConfigurationUnit.MSOSyncEnabled && exchangeConfigurationUnit2.MSOSyncEnabled && !string.IsNullOrEmpty(aduser.ExternalDirectoryObjectId) && !string.IsNullOrEmpty(aduser2.ExternalDirectoryObjectId) && !aduser.ExternalDirectoryObjectId.Equals(aduser2.ExternalDirectoryObjectId, StringComparison.OrdinalIgnoreCase)) { return(result); } if (!aduser.OrganizationId.Equals(aduser2.OrganizationId)) { if (exchangeConfigurationUnit.WhenCreatedUTC != null && exchangeConfigurationUnit2.WhenCreatedUTC != null && exchangeConfigurationUnit.WhenCreatedUTC != exchangeConfigurationUnit2.WhenCreatedUTC) { if (exchangeConfigurationUnit.WhenCreatedUTC > exchangeConfigurationUnit2.WhenCreatedUTC) { result = aduser.Id; } else { result = aduser2.Id; } } } else if (aduser.WhenCreatedUTC != null && aduser2.WhenCreatedUTC != null && aduser.WhenCreatedUTC != aduser2.WhenCreatedUTC) { if (aduser.WhenCreatedUTC > aduser2.WhenCreatedUTC) { result = aduser.Id; } else { result = aduser2.Id; } } else if (aduser.Guid.CompareTo(aduser2.Guid) > 0) { result = aduser.Id; } else { result = aduser2.Id; } } } return(result); }
private bool HierarchicalCheckForGroupEmptiness(ADGroup group, out ExchangeRoleAssignment roleAssignment) { roleAssignment = null; Result <ExchangeRoleAssignment>[] inheritedRoleAssignments = this.GetInheritedRoleAssignments(group); if (inheritedRoleAssignments == null) { return(true); } this.excludedFromEmptinessValidation.Add(group.Id); List <ADGroup> list = new List <ADGroup>(); Result <ExchangeRoleAssignment>[] array = inheritedRoleAssignments; for (int i = 0; i < array.Length; i++) { Result <ExchangeRoleAssignment> assignment = array[i]; Result <ExchangeRoleAssignment> assignment8 = assignment; if (RoleAssignmentsGlobalConstraints.IsValidCannedRoleToGroupAssignment(assignment8.Data)) { if (!list.Exists(delegate(ADGroup x) { ADObjectId id = x.Id; Result <ExchangeRoleAssignment> assignment7 = assignment; return(id.Equals(assignment7.Data.User)); })) { Result <ExchangeRoleAssignment> assignment2 = assignment; if (this.IsUserRequiredForAssignment(assignment2.Data)) { Result <ExchangeRoleAssignment> assignment3 = assignment; if (!this.IsGroupEmpty(assignment3.Data.User)) { list.Add(group); } else { Result <ExchangeRoleAssignment> assignment4 = assignment; ExchangeRoleAssignment data = assignment4.Data; Result <ExchangeRoleAssignment> assignment5 = assignment; if (!this.ExistDistinctRoleAssignmentForGroup(data, this.GetRole(assignment5.Data.Role), true)) { Result <ExchangeRoleAssignment> assignment6 = assignment; roleAssignment = assignment6.Data; return(false); } } } } } } return(true); }
public static bool TryGetTenantRelocationStateByObjectId(ADObjectId identity, out TenantRelocationState state, out bool isSourceTenant) { ArgumentValidator.ThrowIfNull("identity", identity); state = null; isSourceTenant = true; PartitionId partitionId = identity.GetPartitionId(); if (!ForestTenantRelocationsCache.IsTenantRelocationAllowed(partitionId.ForestFQDN)) { return(false); } ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 595, "TryGetTenantRelocationStateByObjectId", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs"); ADObjectId configurationUnitsRoot = tenantConfigurationSession.GetConfigurationUnitsRoot(); if (configurationUnitsRoot.Equals(identity)) { return(false); } ADObjectId adobjectId = null; if (identity.IsDescendantOf(configurationUnitsRoot)) { adobjectId = identity.GetFirstGenerationDecendantOf(configurationUnitsRoot); } else { ADObjectId hostedOrganizationsRoot = tenantConfigurationSession.GetHostedOrganizationsRoot(); if (hostedOrganizationsRoot.Equals(identity)) { return(false); } if (identity.IsDescendantOf(hostedOrganizationsRoot)) { adobjectId = identity.GetFirstGenerationDecendantOf(hostedOrganizationsRoot); } } if (adobjectId == null) { return(false); } try { state = TenantRelocationStateCache.GetTenantRelocationState(adobjectId.Name, partitionId, out isSourceTenant, false); } catch (CannotResolveTenantNameException) { return(false); } return(true); }
// Token: 0x06000BCE RID: 3022 RVA: 0x0004DF24 File Offset: 0x0004C124 internal static bool InRole(IRecipientSession rs, ADRecipient recipient, MultiValuedProperty <string> roleMembersLegDN, MultiValuedProperty <ADObjectId> roleMemberslegacy) { if (recipient == null) { return(false); } if (roleMemberslegacy == null && roleMembersLegDN == null) { return(false); } if (roleMembersLegDN != null && roleMembersLegDN.Count != 0) { foreach (string text in roleMembersLegDN) { if (string.Equals(text, recipient.LegacyExchangeDN, StringComparison.InvariantCultureIgnoreCase)) { return(true); } ADRecipient adrecipient = rs.FindByLegacyExchangeDN(text); if (adrecipient != null && adrecipient is ADGroup && recipient.IsMemberOf(adrecipient.Id, false)) { BookingPolicy.Tracer.TraceDebug((long)recipient.GetHashCode(), "{0}: Group match", new object[] { TraceContext.Get() }); return(true); } } } if (roleMemberslegacy != null && roleMemberslegacy.Count != 0) { foreach (ADObjectId adobjectId in roleMemberslegacy) { if (ADObjectId.Equals(adobjectId, recipient.Id)) { return(true); } ADRecipient adrecipient2 = rs.Read(adobjectId); if (adrecipient2 != null && adrecipient2 is ADGroup && recipient.IsMemberOf(adrecipient2.Id, false)) { BookingPolicy.Tracer.TraceDebug((long)recipient.GetHashCode(), "{0}: Group match", new object[] { TraceContext.Get() }); return(true); } } } return(false); }
private void TestArguments <T>(QueryFilter filter, ObjectId rootId) { if (filter != null && !(filter is FalseFilter)) { throw new NotSupportedException("filter"); } if (rootId != null && rootId is ADObjectId && !ADObjectId.Equals((ADObjectId)rootId, base.MailboxSession.MailboxOwner.ObjectId)) { throw new NotSupportedException("rootId"); } if (!typeof(MailboxJunkEmailConfiguration).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } }
// Token: 0x06001209 RID: 4617 RVA: 0x0003817C File Offset: 0x0003637C internal static Server FindMailboxServer(string domainController, OfflineAddressBook currentOABSettings, LogMessageDelegate logger) { ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController); QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, Server.E14MinVersion), new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL), new ComparisonFilter(ComparisonOperator.Equal, ActiveDirectoryServerSchema.IsExcludedFromProvisioning, false) }); PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(topologyConfigurationSession, typeof(Server), filter, null, true), logger); ADPagedReader <Server> adpagedReader = topologyConfigurationSession.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0); List <Server> list = new List <Server>(); foreach (Server server in adpagedReader) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbFoundMailboxServer(server.Identity.ToString()), logger); list.Add(server); } if (currentOABSettings.Server != null) { Server currentOABServer = topologyConfigurationSession.Read <Server>(currentOABSettings.Server); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOABIsCurrentlyOnServer((currentOABServer == null) ? Strings.VerboseLbDeletedServer : currentOABServer.Identity.ToString()), logger); if (currentOABServer != null && list.Find((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id)) != null) { if (list.Count == 1) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOnlyOneEligibleServer(currentOABServer.Identity.ToString()), logger); return(currentOABServer); } list.RemoveAll((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id)); } } if (list.Count == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoEligibleServers, logger); return(null); } if (list.Count == 1) { return(list[0]); } Random random = new Random(); Server server2 = list[random.Next(0, list.Count)]; PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbReturningServer(server2.Identity.ToString()), logger); return(server2); }
public static void ValidatePrimaryOnlyMoveArchiveDatabase(ADUser user, Action <Exception, ErrorCategory> writeError) { if (user.HasLocalArchive) { if (user.ArchiveDatabaseRaw == null) { writeError(new ArchiveDatabaseNotStampedPermanentException(), ErrorCategory.InvalidArgument); } if (!ADObjectId.Equals(user.ArchiveDatabase, user.ArchiveDatabaseRaw)) { string archiveDb = (user.ArchiveDatabase != null) ? user.ArchiveDatabase.ToString() : "null"; string archiveDbRaw = (user.ArchiveDatabaseRaw != null) ? user.ArchiveDatabaseRaw.ToString() : "null"; writeError(new ArchiveDatabaseDifferentFromRawValuePermanentException(archiveDb, archiveDbRaw), ErrorCategory.InvalidArgument); } } }
public bool Equals(ADScope obj) { if (obj == null) { return(false); } if (!ADObjectId.Equals(this.Root, obj.Root)) { return(false); } if (this.Filter != null) { return(this.Filter.Equals(obj.Filter)); } return(obj.Filter == null); }
protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { if (filter != null && !(filter is FalseFilter)) { throw new NotSupportedException("filter"); } ADObjectId adUserId = (!base.MailboxSession.MailboxOwner.ObjectId.IsNullOrEmpty()) ? base.MailboxSession.MailboxOwner.ObjectId : null; if (rootId != null && rootId is ADObjectId && !ADObjectId.Equals((ADObjectId)rootId, adUserId)) { throw new NotSupportedException("rootId"); } if (!typeof(XsoMailboxConfigurationObject).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } XsoMailboxConfigurationObject configObject = (XsoMailboxConfigurationObject)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); if (adUserId != null) { configObject.MailboxOwnerId = adUserId; } HashSet <string> uniqueConfigurationNames = new HashSet <string>(from x in configObject.Schema.AllProperties where x is XsoDictionaryPropertyDefinition select((XsoDictionaryPropertyDefinition)x).UserConfigurationName); foreach (string userConfigurationName in uniqueConfigurationNames) { try { this.LoadUserConfigurationToConfigObject(userConfigurationName, configObject); } catch (CorruptDataException) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "The calendar configuration for {0} is corrupt", base.MailboxSession.MailboxOwner); yield break; } catch (VirusDetectedException) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "The calendar configuration for {0} is virus infected.", base.MailboxSession.MailboxOwner); yield break; } } yield return((T)((object)configObject)); yield break; }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); TDataObject dataObject = this.DataObject; ADObjectId parent = dataObject.Id.Parent; ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(parent); if (!parent.Equals(ADSession.GetRootDomainNamingContext(adsessionSettings.GetAccountOrResourceForestFqdn()))) { IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 264, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs"); tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC; ADRawEntry adrawEntry = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[] { ADObjectSchema.ExchangeVersion, ADObjectSchema.ObjectClass }); if (adrawEntry == null) { if (string.IsNullOrEmpty(base.DomainController)) { TDataObject dataObject2 = this.DataObject; base.WriteError(new TaskException(Strings.ErrorParentNotFound(dataObject2.Name, parent.ToString())), (ErrorCategory)1003, null); } else { TDataObject dataObject3 = this.DataObject; base.WriteError(new TaskException(Strings.ErrorParentNotFoundOnDomainController(dataObject3.Name, base.DomainController, parent.ToString(), parent.DomainId.ToString())), (ErrorCategory)1003, null); } } ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion]; MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass]; TDataObject dataObject4 = this.DataObject; if (dataObject4.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass) && this.EnforceExchangeObjectVersion) { TDataObject dataObject5 = this.DataObject; string name = dataObject5.Name; TDataObject dataObject6 = this.DataObject; base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject6.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null); } } if (base.IsVerboseOn) { base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(this.DataObject)); } base.InternalProcessRecord(); TaskLogger.LogExit(); }
private bool IsEligibleOabServiceBasedOnVersionAndVirtualDirectory(OabService oabService, OABCache.OABCacheEntry oabCacheEntry) { bool result = false; if (oabService != null && !oabService.IsOutOfService && oabService.ServerVersionNumber < Server.E15MinVersion) { foreach (ADObjectId x in oabCacheEntry.VirtualDirectories) { if (ADObjectId.Equals(x, oabService.ADObjectId)) { result = true; break; } } } return(result); }
public static Identity ToIdentity(this MailboxFolder entry) { string name = entry.Name; if (entry.DefaultFolderType == DefaultFolderType.Root) { Microsoft.Exchange.Data.Storage.Management.MailboxFolderId mailboxFolderId = (Microsoft.Exchange.Data.Storage.Management.MailboxFolderId)entry.Identity; if (ADObjectId.Equals(mailboxFolderId.MailboxOwnerId, EacRbacPrincipal.Instance.ExecutingUserId)) { name = EacRbacPrincipal.Instance.Name; } else { name = mailboxFolderId.MailboxOwnerId.Name; } } return(new Identity(entry.FolderStoreObjectId, name)); }
protected override void PerformGroupMemberAction() { try { ADRecipient memberRecipient = (ADRecipient)base.GetDataObject <ADRecipient>(base.Member, base.GlobalCatalogRBACSession, this.DataObject.OrganizationId.OrganizationalUnit, null, new LocalizedString?(Strings.ErrorRecipientNotFound((string)base.Member)), new LocalizedString?(Strings.ErrorRecipientNotUnique((string)base.Member)), ExchangeErrorCategory.Client); MailboxTaskHelper.ValidateAndAddMember(this.DataObject, base.Member, memberRecipient, new Task.ErrorLoggerDelegate(base.WriteError)); } catch (ManagementObjectNotFoundException) { ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(base.Member, base.PartitionOrRootOrgGlobalCatalogSession, this.DataObject.OrganizationId.OrganizationalUnit, null, new LocalizedString?(Strings.ErrorRecipientNotFound((string)base.Member)), new LocalizedString?(Strings.ErrorRecipientNotUnique((string)base.Member)), ExchangeErrorCategory.Client); ADObjectId x; if (adrecipient == null || !base.TryGetExecutingUserId(out x) || !ADObjectId.Equals(x, adrecipient.Id) || !adrecipient.HiddenFromAddressListsEnabled) { throw; } MailboxTaskHelper.ValidateAndAddMember(this.DataObject, base.Member, adrecipient, new Task.ErrorLoggerDelegate(base.WriteError)); } }
public TrackingAuthority GetAuthorityForSiteUser(ADObjectId siteId, ADUser user) { ADObjectId id = LocalSiteCache.LocalSite.Id; if (siteId.Equals(id)) { TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Using local tracking authority for requested user.", new object[0]); return(CurrentSiteTrackingAuthority.Instance); } List <ServerInfo> casServers = ServerCache.Instance.GetCasServers(siteId); if (casServers == null || casServers.Count == 0) { TraceWrapper.SearchLibraryTracer.TraceDebug <ADObjectId>(this.GetHashCode(), "No suitable CAS servers found in site: {0}", siteId); return(LegacyExchangeServerTrackingAuthority.Instance); } return(RemoteSiteInCurrentOrgTrackingAuthority.Create(siteId, this.directoryContext, user)); }
private List <ADObjectId> GetServersToConnectPreferringLocalToSite(HashSet <ADObjectId> serversInDag, int numEntries) { List <ADObjectId> list = new List <ADObjectId>(numEntries); List <ADObjectId> list2 = new List <ADObjectId>(serversInDag.Count); List <ADObjectId> list3 = new List <ADObjectId>(serversInDag.Count); foreach (ADObjectId adobjectId in serversInDag) { ADObjectId adobjectId2 = null; if (this.serverToSiteMap.TryGetValue(adobjectId, out adobjectId2) && adobjectId2.Equals(this.localSiteId)) { list2.Add(adobjectId); } else { list3.Add(adobjectId); } } if (list2.Count > 0) { RoutingUtils.ShuffleList <ADObjectId>(list2); foreach (ADObjectId item in list2) { list.Add(item); if (list.Count == numEntries) { break; } } } if (list.Count < numEntries) { RoutingUtils.ShuffleList <ADObjectId>(list3); foreach (ADObjectId item2 in list3) { list.Add(item2); if (list.Count == numEntries) { break; } } } return(list); }
public TrackingAuthority GetAuthorityForSite(ADObjectId siteId, int minimumCasVersionRequested) { ADObjectId localServerSiteId = ServerCache.Instance.GetLocalServerSiteId(this.directoryContext); if (siteId.Equals(localServerSiteId)) { TraceWrapper.SearchLibraryTracer.TraceDebug <ADObjectId>(this.GetHashCode(), "Using local tracking authority for site: {0}", siteId); return(CurrentSiteTrackingAuthority.Instance); } List <ServerInfo> casServers = ServerCache.Instance.GetCasServers(siteId); if (casServers == null || casServers.Count == 0) { TraceWrapper.SearchLibraryTracer.TraceDebug <ADObjectId>(this.GetHashCode(), "No suitable CAS servers found in site: {0}", siteId); return(LegacyExchangeServerTrackingAuthority.Instance); } bool enabled = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MessageTracking.UseBackEndLocator.Enabled; return(RemoteSiteInCurrentOrgTrackingAuthority.Create(siteId, this.directoryContext, minimumCasVersionRequested, enabled)); }
public override bool Equals(XsoMailboxObjectId other) { MailboxFolderId mailboxFolderId = other as MailboxFolderId; if (null == mailboxFolderId) { return(false); } if (!ADObjectId.Equals(base.MailboxOwnerId, other.MailboxOwnerId)) { return(false); } bool flag = object.Equals(this.StoreObjectIdValue, mailboxFolderId.StoreObjectIdValue); if (flag && this.StoreObjectIdValue != null) { return(true); } bool flag2 = object.Equals(this.MailboxFolderPath, mailboxFolderId.MailboxFolderPath); return((flag2 && null != this.MailboxFolderPath) || (flag2 && flag)); }
public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate) { DDIHelper.CheckDataTableForSingleObject(dataTable); DataRow dataRow = dataTable.Rows[0]; if (!(dataRow[base.IdentityVariable] is ADObjectId)) { throw new NotSupportedException("Currently we don't support Back-Link look up based on the UMC type Identity!"); } if (this.EnableFilter) { base.Command.AddParameter("Filter", string.Format("{0} -{1} '{2}'", this.LinkProperty, this.FilterOperator, DDIHelper.ToQuotationEscapedString(((ADObjectId)dataRow[base.IdentityVariable]).DistinguishedName))); } RunResult runResult = new RunResult(); PowerShellResults <PSObject> powerShellResults; base.ExecuteCmdlet(null, runResult, out powerShellResults, false); if (!runResult.ErrorOccur) { List <ADObjectId> list = new List <ADObjectId>(); foreach (PSObject psobject in powerShellResults.Output) { if (!this.EnableFilter) { ADObjectId adobjectId = (ADObjectId)psobject.Properties[this.LinkProperty].Value; if (adobjectId != null && adobjectId.Equals(dataRow[base.IdentityVariable])) { list.Add(psobject.Properties["Identity"].Value as ADObjectId); } } else { list.Add(psobject.Properties["Identity"].Value as ADObjectId); } } dataRow[this.OutputVariable] = list; } return(runResult); }