Ejemplo n.º 1
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (typeof(T) != typeof(ADSchemaClassObject) && typeof(T) != typeof(ADSchemaAttributeObject))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            IEnumerable <T>       enumerable = base.GetObjects <T>(session.GetSchemaNamingContext(), session, subTreeSession, optionalData, out notFoundReason);
            EnumerableWrapper <T> wrapper    = EnumerableWrapper <T> .GetWrapper(enumerable);

            if (!wrapper.HasElements() && base.InternalADObjectId != null && base.InternalADObjectId.ObjectGuid != Guid.Empty)
            {
                QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADSchemaObjectSchema.SchemaIDGuid, base.InternalADObjectId.ObjectGuid);
                enumerable = base.PerformPrimarySearch <T>(filter, ADSession.GetSchemaNamingContextForLocalForest(), session, true, optionalData);
                wrapper    = EnumerableWrapper <T> .GetWrapper(enumerable);
            }
            if (!wrapper.HasElements() && !string.IsNullOrEmpty(base.RawIdentity))
            {
                QueryFilter filter2 = new ComparisonFilter(ComparisonOperator.Equal, ADSchemaObjectSchema.DisplayName, base.RawIdentity);
                enumerable = base.PerformPrimarySearch <T>(filter2, ADSession.GetSchemaNamingContextForLocalForest(), session, true, optionalData);
                wrapper    = EnumerableWrapper <T> .GetWrapper(enumerable);
            }
            return(wrapper);
        }