internal static ADPropertyDefinition Int32BitfieldProperty(string name, int shift, ADPropertyDefinition fieldProperty) { CustomFilterBuilderDelegate customFilterBuilderDelegate = delegate(SinglePropertyFilter filter) { ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter == null || comparisonFilter.ComparisonOperator != ComparisonOperator.Equal) { throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedFilterForProperty(filter.Property.Name, filter.GetType(), typeof(ComparisonFilter))); } int num = 1; int num2 = ((bool)comparisonFilter.PropertyValue) ? 1 : 0; int num3 = (1 << num) - 1; uint num4 = (uint)((uint)(num2 & num3) << shift); uint num5 = (uint)((uint)(~(uint)num2 & num3) << shift); QueryFilter queryFilter = new NotFilter(new BitMaskOrFilter(fieldProperty, (ulong)num5)); if (num2 != 0) { return(new AndFilter(new QueryFilter[] { new BitMaskAndFilter(fieldProperty, (ulong)num4), queryFilter })); } return(queryFilter); }; return(new ADPropertyDefinition(name, fieldProperty.VersionAdded, typeof(bool), null, ADPropertyDefinitionFlags.Calculated, false, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new ADPropertyDefinition[] { fieldProperty }, customFilterBuilderDelegate, ADObject.FlagGetterDelegate(1 << shift, fieldProperty), ADObject.FlagSetterDelegate(1 << shift, fieldProperty), null, null)); }
// Token: 0x06000DE0 RID: 3552 RVA: 0x00040AF0 File Offset: 0x0003ECF0 private void ConvertCompositeFilter(CompositeFilter compositeFilter, QueryFilter parentFilter) { if (compositeFilter.FilterCount == 0) { return; } bool flag = compositeFilter is AndFilter; if (!flag && compositeFilter.FilterCount > 1 && Filters.IsEqualityFilterOnPropertyDefinition(compositeFilter.Filters[0], new PropertyDefinition[] { ADRecipientSchema.RecipientTypeDetails })) { RecipientTypeDetails recipientTypeDetails = RecipientTypeDetails.None; foreach (QueryFilter queryFilter in compositeFilter.Filters) { if (!Filters.IsEqualityFilterOnPropertyDefinition(queryFilter, new PropertyDefinition[] { ADRecipientSchema.RecipientTypeDetails })) { recipientTypeDetails = RecipientTypeDetails.None; break; } recipientTypeDetails |= (RecipientTypeDetails)ADObject.PropertyValueFromEqualityFilter((ComparisonFilter)queryFilter); } if (recipientTypeDetails != RecipientTypeDetails.None) { this.ConvertSinglePropertyFilter(new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientTypeDetails, recipientTypeDetails), parentFilter); return; } } if (!flag && Filters.IsOrFilterOnPropertyDefinitionComparisons(compositeFilter, new PropertyDefinition[] { ADRecipientSchema.RecipientType })) { QueryFilter queryFilter2 = Filters.OptimizeRecipientTypeFilter((OrFilter)compositeFilter); if (queryFilter2 != compositeFilter) { ExTraceGlobals.LdapFilterBuilderTracer.TraceDebug <QueryFilter, CompositeFilter>(0L, "LdapFilterBuilder::ConvertCompositeFilter: Filters.OptimizeRecipientTypeFilter found an optimized filter. Will use {0} instead of {1}", queryFilter2, compositeFilter); this.BuildLdapFilter(queryFilter2, parentFilter); return; } } bool flag2 = false; if (parentFilter != null) { if (parentFilter is AndFilter) { flag2 = flag; } else { flag2 = !flag; } } if (!flag2) { this.IncrementFilterSize(); this.ldapFilter.Append("("); if (flag) { this.ldapFilter.Append("&"); } else { this.ldapFilter.Append("|"); } } if (flag) { this.CheckVirtualIndexOnIdOrAbMembership(compositeFilter); } foreach (QueryFilter queryFilter3 in compositeFilter.Filters) { this.BuildLdapFilter(queryFilter3, compositeFilter); } if (!flag2) { this.ldapFilter.Append(")"); } }
public static string GenerateLegacyDN(string parentLegacyDN, ADObject obj) { return(LegacyDN.GenerateLegacyDN(parentLegacyDN, obj, false, null)); }
internal static ADPropertyDefinition BitfieldProperty(string name, int shift, int length, ADPropertyDefinition fieldProperty) { return(ADObject.BitfieldProperty(name, shift, length, fieldProperty, null)); }
public static string GenerateLegacyDN(string parentLegacyDN, int suggestedMaxLength, ADObject obj, bool checkInvalidChar, LegacyDN.LegacyDNIsUnique dnIsUnique) { return(LegacyDN.GenerateLegacyDN(parentLegacyDN, suggestedMaxLength, obj, checkInvalidChar, dnIsUnique, null)); }
public static string GenerateLegacyDN(string parentLegacyDN, int suggestedMaxLength, ADObject obj, bool checkInvalidChar, LegacyDN.LegacyDNIsUnique dnIsUnique, string cnName) { StringBuilder stringBuilder = new StringBuilder(64); StringBuilder stringBuilder2 = new StringBuilder(parentLegacyDN).Append("/cn="); int length = stringBuilder2.Length; string text = cnName ?? obj.Name; if (checkInvalidChar && !LegacyDN.IsValidLegacyCommonName(text)) { stringBuilder.Append(obj.MostDerivedObjectClass).Append(LegacyDN.GenerateRandomString(8)); } else { stringBuilder.Append(text); } if (suggestedMaxLength > 0 && length + stringBuilder.Length > suggestedMaxLength && length <= suggestedMaxLength - 8) { stringBuilder.Length = suggestedMaxLength - length; } stringBuilder2.Append(stringBuilder.ToString()); if (dnIsUnique != null) { int num = 0; while (num < 1000 && !dnIsUnique(stringBuilder2.ToString().Trim())) { string text2 = LegacyDN.GenerateRandomString(8); int num2 = stringBuilder.Length + text2.Length; if (num2 > 64) { stringBuilder.Length -= num2 - 64; num2 = 64; } if (suggestedMaxLength > 0 && length + num2 > suggestedMaxLength && length <= suggestedMaxLength - 8) { stringBuilder.Length = suggestedMaxLength - length - 8; } stringBuilder.Append(text2); stringBuilder2.Length = length; stringBuilder2.Append(stringBuilder.ToString()); num++; } if (num >= 1000) { throw new GenerateUniqueLegacyDnException(DirectoryStrings.ErrorCannotFindUnusedLegacyDN); } } return(stringBuilder2.ToString().Trim()); }
void IDirectorySession.VerifyIsWithinScopes(ADObject entry, bool isModification) { TSession session = this.GetSession(); session.VerifyIsWithinScopes(entry, isModification); }
protected TResult ExecuteSingleObjectQueryWithFallback <TResult>(Func <TSession, TResult> query, Func <TResult, List <Tuple <string, KeyType> > > getAdditionalKeys = null, IEnumerable <PropertyDefinition> properties = null) where TResult : ADRawEntry, new() { ArgumentValidator.ThrowIfNull("query", query); if (!Configuration.IsCacheEnabled(typeof(TResult))) { return(query(this.GetSession())); } Stopwatch stopwatch = Stopwatch.StartNew(); CachePerformanceTracker.StartLogging(); CompositeDirectorySession <TSession> .TraceState traceState = CompositeDirectorySession <TSession> .TraceState.None; CacheMode cacheModeForCurrentProcess = Configuration.GetCacheModeForCurrentProcess(); double num = -1.0; double num2 = -1.0; double num3 = -1.0; double num4 = -1.0; TResult tresult = default(TResult); string text = string.Empty; Guid guid = Guid.Empty; ADCacheResultState adcacheResultState = ADCacheResultState.Succeed; bool flag = true; int num5 = 0; try { Stopwatch stopwatch2 = null; ADObject adobject = null; try { TSession session = this.GetSession(); if (session.ActivityScope != null) { TSession session2 = this.GetSession(); if (session2.ActivityScope.Status == ActivityContextStatus.ActivityStarted) { TSession session3 = this.GetSession(); guid = session3.ActivityScope.ActivityId; } } if (!this.CacheSessionForDeletingOnly && (CacheMode.Read & cacheModeForCurrentProcess) != CacheMode.Disabled) { TSession session4 = this.GetSession(); if (!session4.SessionSettings.IncludeSoftDeletedObjectLinks) { if (properties != null || !typeof(TResult).Equals(typeof(ADRawEntry))) { traceState |= CompositeDirectorySession <TSession> .TraceState.CacheRead; stopwatch2 = Stopwatch.StartNew(); tresult = query(this.GetCacheSession()); CacheDirectorySession cacheDirectorySession = this.GetCacheSession() as CacheDirectorySession; if (cacheDirectorySession != null) { adcacheResultState = cacheDirectorySession.ResultState; flag = cacheDirectorySession.IsNewProxyObject; num5 = cacheDirectorySession.RetryCount; } stopwatch2.Stop(); num = (double)stopwatch2.ElapsedMilliseconds; goto IL_19A; } goto IL_19A; } } if ((CacheMode.Read & cacheModeForCurrentProcess) == CacheMode.Disabled || this.CacheSessionForDeletingOnly) { adcacheResultState = ADCacheResultState.CacheModeIsNotRead; } else { adcacheResultState = ADCacheResultState.SoftDeletedObject; } IL_19A: if (tresult != null && tresult.Id != null) { TSession session5 = this.GetSession(); if (ADSession.ShouldFilterCNFObject(session5.SessionSettings, tresult.Id)) { tresult = default(TResult); adcacheResultState = ADCacheResultState.CNFedObject; } else { TSession session6 = this.GetSession(); if (ADSession.ShouldFilterSoftDeleteObject(session6.SessionSettings, tresult.Id)) { tresult = default(TResult); adcacheResultState = ADCacheResultState.SoftDeletedObject; } else { if (tresult.Id != null && tresult.Id.DomainId != null) { TSession session7 = this.GetSession(); if (!session7.SessionSettings.PartitionId.Equals(tresult.Id.GetPartitionId())) { if (ExEnvironment.IsTest) { TSession session8 = this.GetSession(); if (session8.SessionSettings.PartitionId.ForestFQDN.EndsWith(tresult.Id.GetPartitionId().ForestFQDN, StringComparison.OrdinalIgnoreCase)) { goto IL_341; } } ExEventLog.EventTuple tuple_WrongObjectReturned = DirectoryEventLogConstants.Tuple_WrongObjectReturned; string name = typeof(TResult).Name; object[] array = new object[2]; object[] array2 = array; int num6 = 0; TSession session9 = this.GetSession(); array2[num6] = session9.SessionSettings.PartitionId.ForestFQDN; array[1] = tresult.Id.GetPartitionId().ForestFQDN; Globals.LogEvent(tuple_WrongObjectReturned, name, array); tresult = default(TResult); adcacheResultState = ADCacheResultState.WrongForest; goto IL_3E1; } } IL_341: TSession session10 = this.GetSession(); if (session10.SessionSettings.CurrentOrganizationId != OrganizationId.ForestWideOrgId) { TSession session11 = this.GetSession(); OrganizationId currentOrganizationId = session11.SessionSettings.CurrentOrganizationId; if (!tresult.Id.IsDescendantOf(currentOrganizationId.OrganizationalUnit) && !tresult.Id.IsDescendantOf(currentOrganizationId.ConfigurationUnit.Parent)) { tresult = default(TResult); adcacheResultState = ADCacheResultState.OranizationIdMismatch; } } } } } else if (tresult != null) { tresult = default(TResult); } else { adcacheResultState = ADCacheResultState.NotFound; } IL_3E1: adobject = (tresult as ADObject); } catch (Exception ex) { tresult = default(TResult); adcacheResultState = ADCacheResultState.ExceptionHappened; Globals.LogEvent(DirectoryEventLogConstants.Tuple_CallADCacheServiceFailed, typeof(TResult).Name, new object[] { ex.ToString() }); text = ex.ToString(); } if (tresult == null) { traceState |= CompositeDirectorySession <TSession> .TraceState.ADRead; stopwatch2 = Stopwatch.StartNew(); tresult = query(this.GetSession()); adobject = (tresult as ADObject); stopwatch2.Stop(); num4 = (double)stopwatch2.ElapsedMilliseconds; stopwatch2.Restart(); bool flag2 = true; if (adobject != null) { TSession session12 = this.GetSession(); if (!session12.ReadOnly && CompositeDirectorySession <TSession> .ExchangeConfigUnitCUType.Equals(adobject.GetType()) && OrganizationId.ForestWideOrgId.Equals(adobject.OrganizationId)) { ExTraceGlobals.SessionTracer.TraceWarning <string>((long)this.GetHashCode(), "Newly created ExchangeCU with organizationId equals to RootOrgId, ignored till is fully populated. DN {0}", tresult.GetDistinguishedNameOrName()); flag2 = false; } } if (tresult != null && CacheUtils.GetObjectTypeFor(tresult.GetType(), false) == ObjectType.Unknown) { flag2 = false; } if (tresult != null && ((CacheMode.SyncWrite | CacheMode.AsyncWrite) & cacheModeForCurrentProcess) != CacheMode.Disabled && tresult.Id != null && !tresult.Id.IsDeleted && flag2) { traceState |= CompositeDirectorySession <TSession> .TraceState.CacheInsert; if ((CacheMode.SyncWrite & cacheModeForCurrentProcess) != CacheMode.Disabled) { try { this.CacheInsert <TResult>(tresult, getAdditionalKeys, properties); goto IL_5C8; } catch (Exception ex2) { Globals.LogEvent(DirectoryEventLogConstants.Tuple_CallADCacheServiceFailed, "CacheInsert", new object[] { ex2.ToString() }); text += ex2.Message; goto IL_5C8; } } TSession session13 = this.GetSession(); if (session13.ReadOnly) { this.AsyncCacheInsert <TResult>(tresult, getAdditionalKeys, properties); } else { adcacheResultState |= ADCacheResultState.WritableSession; } } IL_5C8: stopwatch2.Stop(); num3 = (double)stopwatch2.ElapsedMilliseconds; } if (adobject != null) { adobject.m_Session = this; } } finally { stopwatch.Stop(); string text2 = CachePerformanceTracker.StopLogging(); string operation = "Read"; string dn = (tresult != null) ? tresult.GetDistinguishedNameOrName() : "<NULL>"; DateTime whenReadUTC = (tresult != null) ? ((tresult.WhenReadUTC != null) ? tresult.WhenReadUTC.Value : DateTime.MinValue) : DateTime.MinValue; long elapsedMilliseconds = stopwatch.ElapsedMilliseconds; long wcfGetProcessingTime = (long)num; long wcfRemoveProcessingTime = (long)num2; long wcfPutProcessingTime = (long)num3; long adProcessingTime = (long)num4; bool isNewProxyObject = flag; int retryCount = num5; string objectType = (tresult != null) ? tresult.GetType().Name : typeof(TResult).Name; string cachePerformanceTracker = text2; Guid activityId = guid; TSession session14 = this.GetSession(); CacheProtocolLog.BeginAppend(operation, dn, whenReadUTC, elapsedMilliseconds, wcfGetProcessingTime, wcfRemoveProcessingTime, wcfPutProcessingTime, adProcessingTime, isNewProxyObject, retryCount, objectType, cachePerformanceTracker, activityId, session14.CallerInfo, string.Format("ResultState:{0};{1}", (int)adcacheResultState, text)); ExTraceGlobals.SessionTracer.TraceDebug((long)this.GetHashCode(), "ExecuteSingleObjectQueryWithFallback. Cache Mode {0}. TraceState {1}. DN {2}. WhenRead {3}. IsCached {4}.", new object[] { cacheModeForCurrentProcess, traceState, (tresult != null) ? tresult.GetDistinguishedNameOrName() : "<NULL>", (tresult != null) ? ((tresult.WhenReadUTC != null) ? tresult.WhenReadUTC.Value.ToString() : "<NULL>") : "<NULL>", tresult != null && tresult.IsCached }); ExTraceGlobals.SessionTracer.TracePerformance((long)this.GetHashCode(), "ExecuteSingleObjectQueryWithFallback. Cache Mode {0}. TraceState {1}. DN {2}. TotalTime {3}. GetCacheTime {4}. RemoveCacheTime {5}. PutCacheTime {6}. ADTime {7}. WCFDetails [{8}]", new object[] { cacheModeForCurrentProcess, traceState, (tresult != null) ? tresult.GetDistinguishedNameOrName() : "<NULL>", stopwatch.ElapsedMilliseconds, num, num2, num3, num4, text2 }); if (tresult != null) { ADProviderPerf.UpdateADDriverCacheHitRate(tresult.IsCached); } } return(tresult); }
bool IDirectorySession.TryVerifyIsWithinScopes(ADObject entry, bool isModification, out ADScopeException exception) { TSession session = this.GetSession(); return(session.TryVerifyIsWithinScopes(entry, isModification, out exception)); }
bool IDirectorySession.ReplicateSingleObjectToTargetDC(ADObject instanceToReplicate, string targetServerName) { TSession session = this.GetSession(); return(session.ReplicateSingleObjectToTargetDC(instanceToReplicate, targetServerName)); }
string[] IDirectorySession.ReplicateSingleObject(ADObject instanceToReplicate, ADObjectId[] sites) { TSession session = this.GetSession(); return(session.ReplicateSingleObject(instanceToReplicate, sites)); }
bool IDirectorySession.GetSchemaAndApplyFilter(ADRawEntry adRawEntry, ADScope scope, out ADObject dummyObject, out string[] ldapAttributes, ref QueryFilter filter, ref IEnumerable <PropertyDefinition> properties) { TSession session = this.GetSession(); return(session.GetSchemaAndApplyFilter(adRawEntry, scope, out dummyObject, out ldapAttributes, ref filter, ref properties)); }
QueryFilter IDirectorySession.ApplyDefaultFilters(QueryFilter filter, ADScope scope, ADObject dummyObject, bool applyImplicitFilter) { TSession session = this.GetSession(); return(session.ApplyDefaultFilters(filter, scope, dummyObject, applyImplicitFilter)); }