protected internal ADGenericPagedReader(IDirectorySession session, ADObjectId rootId, QueryScope scope, QueryFilter filter, SortBy sortBy, int pageSize, IEnumerable <PropertyDefinition> properties, bool skipCheckVirtualIndex) : base(session, rootId, scope, sortBy)
        {
            if (!typeof(ADRawEntry).IsAssignableFrom(typeof(TResult)))
            {
                throw new InvalidOperationException(DirectoryStrings.ErrorMustBeADRawEntry);
            }
            if (pageSize < 0 || pageSize > 10000)
            {
                throw new ArgumentOutOfRangeException("pageSize", pageSize, string.Format("pageSize should be between 1 and {0} or 0 to use the default page size: {1}", 10000, ADGenericPagedReader <TResult> .DefaultPageSize));
            }
            this.dummyInstance = (ADRawEntry)((object)((default(TResult) == null) ? Activator.CreateInstance <TResult>() : default(TResult)));
            QueryFilter  filter2 = filter;
            ConfigScopes configScopes;
            ADScope      readScope = session.GetReadScope(rootId, this.dummyInstance, false, out configScopes);
            ADObject     adobject;

            string[] ldapAttributes;
            base.Session.GetSchemaAndApplyFilter(this.dummyInstance, readScope, out adobject, out ldapAttributes, ref filter, ref properties);
            ADDataSession addataSession = base.Session as ADDataSession;

            if (addataSession != null)
            {
                addataSession.UpdateFilterforInactiveMailboxSearch(this.dummyInstance, ref filter);
            }
            base.LdapAttributes   = ldapAttributes;
            this.pageSize         = ((pageSize == 0) ? ADGenericPagedReader <TResult> .DefaultPageSize : pageSize);
            this.retrievedAllData = null;
            this.properties       = properties;
            session.CheckFilterForUnsafeIdentity(filter2);
            base.LdapFilter           = LdapFilterBuilder.LdapFilterFromQueryFilter(filter, skipCheckVirtualIndex, base.Session.SessionSettings.PartitionSoftLinkMode, base.Session.SessionSettings.IsTenantScoped);
            this.skipNonUniqueResults = (session is IConfigurationSession);
        }
Exemple #2
0
        public static void VerifyIsWithinScopes(ADRawEntry obj, ADScope readScope, IList <ADScopeCollection> writeScopes, ADScopeCollection invalidScopes, bool emptyObjectSessionOnException)
        {
            ADScopeException ex;

            if (!ADSession.TryVerifyIsWithinScopes(obj, readScope, writeScopes, invalidScopes, emptyObjectSessionOnException, out ex))
            {
                throw ex;
            }
        }
Exemple #3
0
        // Token: 0x0600108B RID: 4235 RVA: 0x0004FC28 File Offset: 0x0004DE28
        internal static ScopeSet GetAllTenantsDefaultScopeSet(string partitionFqdn)
        {
            ADScope           item  = new ADScope(ADSession.GetHostedOrganizationsRoot(partitionFqdn), null);
            ADScopeCollection item2 = new ADScopeCollection(new List <ADScope>(1)
            {
                item
            });

            return(new ScopeSet(item, new List <ADScopeCollection>(1)
            {
                item2
            }, new ADScope(ADSession.GetHostedOrganizationsRoot(partitionFqdn), null), null));
        }
Exemple #4
0
 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);
 }
Exemple #5
0
        internal static ADScope CombineScopeCollections(IList <ADScopeCollection> combinableScopeCollections)
        {
            QueryFilter[] array = new QueryFilter[combinableScopeCollections.Count];
            for (int i = 0; i < combinableScopeCollections.Count; i++)
            {
                ADScopeCollection combinableScopes = combinableScopeCollections[i];
                if (combinableScopeCollections[i][0].Root != combinableScopeCollections[0][0].Root)
                {
                    throw new ArgumentException("combinableScopeCollections");
                }
                array[i] = ADScope.CombineScopes(combinableScopes);
            }
            QueryFilter queryFilter = (array.Length == 1) ? array[0] : new AndFilter(array);

            return(new ADScope(combinableScopeCollections[0][0].Root, queryFilter));
        }
Exemple #6
0
        internal ADVirtualListView(IDirectorySession session, ADObjectId rootId, ADObjectId[] addressListIds, SortBy sortBy, int rowsToPrefetch, IEnumerable <PropertyDefinition> properties) : base(session, rootId, QueryScope.SubTree, sortBy)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }
            if (sortBy == null)
            {
                throw new ArgumentNullException("sortBy");
            }
            if (rowsToPrefetch < 1)
            {
                throw new ArgumentOutOfRangeException("rowsToPrefetch");
            }
            this.rowsToPrefetch = rowsToPrefetch;
            QueryFilter[] array;
            if (addressListIds == null)
            {
                array    = new QueryFilter[2];
                array[0] = new ExistsFilter(ADRecipientSchema.AddressListMembership);
            }
            else
            {
                array = new QueryFilter[addressListIds.Length + 1];
                for (int i = 0; i < addressListIds.Length; i++)
                {
                    array[i] = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.AddressListMembership, addressListIds[i]);
                }
            }
            array[array.Length - 1] = new ExistsFilter(ADRecipientSchema.DisplayName);
            QueryFilter queryFilter  = new AndFilter(array);
            QueryFilter queryFilter2 = (addressListIds == null) ? queryFilter : new ExistsFilter(ADObjectSchema.ObjectClass);

            this.requestedProperties = properties;
            ADScope  readScope = session.GetReadScope(rootId, ADVirtualListView.dummyADRawEntry);
            ADObject adobject;

            string[] ldapAttributes;
            session.GetSchemaAndApplyFilter(ADVirtualListView.dummyADRawEntry, readScope, out adobject, out ldapAttributes, ref queryFilter2, ref properties);
            base.LdapAttributes               = ldapAttributes;
            this.properties                   = properties;
            base.LdapFilter                   = LdapFilterBuilder.LdapFilterFromQueryFilter((addressListIds == null) ? queryFilter2 : queryFilter, false, base.Session.SessionSettings.PartitionSoftLinkMode, base.Session.SessionSettings.IsTenantScoped);
            this.vlvRequestControl            = new VlvRequestControl();
            this.vlvRequestControl.AfterCount = this.rowsToPrefetch;
            base.DirectoryControls.Add(this.vlvRequestControl);
        }
Exemple #7
0
 // Token: 0x06001088 RID: 4232 RVA: 0x0004FACC File Offset: 0x0004DCCC
 public ScopeSet(ADScope recipientReadScope, IList <ADScopeCollection> recipientWriteScopes, IList <ADScope> exclusiveRecipientScopes, ADScope configReadScope, ADScope configWriteScope, Dictionary <string, IList <ADScopeCollection> > objectSpecificConfigWriteScopes, Dictionary <string, ADScopeCollection> objectSpecificExclusiveConfigWriteScopes, IList <ValidationRule> applicableValidationRules)
 {
     this.recipientReadScope       = (recipientReadScope ?? ADScope.Empty);
     this.recipientWriteScopes     = new ReadOnlyCollection <ADScopeCollection>(recipientWriteScopes ?? ((IList <ADScopeCollection>)ADScopeCollection.EmptyArray));
     this.exclusiveRecipientScopes = ((exclusiveRecipientScopes == null || exclusiveRecipientScopes.Count == 0) ? ADScopeCollection.Empty : new ADScopeCollection(exclusiveRecipientScopes));
     this.configReadScope          = (configReadScope ?? ADScope.Empty);
     this.configWriteScope         = (configWriteScope ?? ADScope.Empty);
     if (this.configWriteScope != ADScope.NoAccess && this.configReadScope == ADScope.NoAccess)
     {
         throw new ArgumentException("configReadScope must be granted when configWriteScope is allowed");
     }
     this.objectSpecificConfigWriteScopes = objectSpecificConfigWriteScopes;
     if (this.objectSpecificConfigWriteScopes != null && this.configWriteScope == ADScope.NoAccess)
     {
         throw new ArgumentException("configWriteScope must be granted when objectSpecificConfigWriteScopes is defined");
     }
     this.objectSpecificExclusiveConfigWriteScopes = objectSpecificExclusiveConfigWriteScopes;
     this.validationRules = ((applicableValidationRules == null) ? new List <ValidationRule>(0) : applicableValidationRules);
 }
        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));
        }
Exemple #10
0
 // Token: 0x06001087 RID: 4231 RVA: 0x0004FAAC File Offset: 0x0004DCAC
 public ScopeSet(ADScope recipientReadScope, IList <ADScopeCollection> recipientWriteScopes, IList <ADScope> exclusiveRecipientScopes, ADScope configReadScope, ADScope configWriteScope, Dictionary <string, IList <ADScopeCollection> > objectSpecificConfigWriteScopes, Dictionary <string, ADScopeCollection> objectSpecificExclusiveConfigWriteScopes) : this(recipientReadScope, recipientWriteScopes, exclusiveRecipientScopes, configReadScope, configWriteScope, objectSpecificConfigWriteScopes, objectSpecificExclusiveConfigWriteScopes, null)
 {
 }
Exemple #11
0
 // Token: 0x06001086 RID: 4230 RVA: 0x0004FA99 File Offset: 0x0004DC99
 public ScopeSet(ADScope recipientReadScope, IList <ADScopeCollection> recipientWriteScopes, ADScope configReadScope, ADScope configWriteScope) : this(recipientReadScope, recipientWriteScopes, null, configReadScope, configWriteScope, null, null)
 {
 }
Exemple #12
0
 internal static bool IsWithinScope(ADRawEntry obj, ADScope scope, out bool outOfScopeBecauseOfFilter)
 {
     return(ADDataSession.IsWithinScope(obj, scope, out outOfScopeBecauseOfFilter));
 }
Exemple #13
0
        internal static bool IsWithinScope(ADRawEntry obj, ADScope scope)
        {
            bool flag;

            return(ADSession.IsWithinScope(obj, scope, out flag));
        }
Exemple #14
0
 public static bool TryVerifyIsWithinScopes(ADRawEntry obj, ADScope readScope, IList <ADScopeCollection> writeScopes, ADScopeCollection exclusiveScopes, bool emptyObjectSessionOnException, out ADScopeException exception)
 {
     return(ADSession.TryVerifyIsWithinScopes(obj, readScope, writeScopes, exclusiveScopes, null, emptyObjectSessionOnException, out exception));
 }
Exemple #15
0
        internal static bool TryVerifyIsWithinScopes(ADRawEntry obj, ADScope readScope, IList <ADScopeCollection> writeScopes, ADScopeCollection exclusiveScopes, IList <ValidationRule> validationRules, bool emptyObjectSessionOnException, ConfigScopes sessionScopeHint, out ADScopeException exception)
        {
            if (readScope == null)
            {
                throw new ArgumentNullException("readScope");
            }
            if (writeScopes == null)
            {
                throw new ArgumentNullException("writeScopes");
            }
            exception = null;
            bool flag;

            if (!ADSession.IsWithinScope(obj, readScope, out flag))
            {
                if (!flag || sessionScopeHint != ConfigScopes.RootOrg || ADSession.IsTenantIdentity(obj.Id, obj.Id.GetPartitionId().ForestFQDN))
                {
                    if (obj is ADObject && emptyObjectSessionOnException)
                    {
                        ((ADObject)obj).m_Session = null;
                    }
                    exception = new ADScopeException(DirectoryStrings.ErrorNotInReadScope(obj.Id.ToString()));
                    return(false);
                }
                ExTraceGlobals.ScopeVerificationTracer.TraceDebug <ADObjectId>(0L, "ADSession::TryVerifyIsWithinScopes Allowing unfilterable object '{0}' in RootOrg-scoped session to bypass filter verification", obj.Id);
            }
            bool flag2 = false;

            if (exclusiveScopes != null)
            {
                foreach (ADScope scope in exclusiveScopes)
                {
                    if (ADSession.IsWithinScope(obj, scope))
                    {
                        flag2 = true;
                        break;
                    }
                }
            }
            foreach (ADScopeCollection adscopeCollection in writeScopes)
            {
                bool flag3 = false;
                foreach (ADScope adscope in adscopeCollection)
                {
                    bool flag4 = false;
                    bool flag5 = false;
                    bool flag6 = false;
                    if (adscope is RbacScope)
                    {
                        RbacScope rbacScope = (RbacScope)adscope;
                        flag4 = rbacScope.Exclusive;
                        flag5 = rbacScope.IsFromEndUserRole;
                        flag6 = (rbacScope.ScopeType == ScopeType.Self);
                    }
                    if (!flag2 && flag4)
                    {
                        ExTraceGlobals.ScopeVerificationTracer.TraceDebug(0L, "ADSession::TryVerifyIsWithinScopes Ignoring scope ScopeRoot '{0}', ScopeFilter '{1}', IsWithinExclusiveScope '{2}', IsExclusive '{3}'", new object[]
                        {
                            (adscope.Root == null) ? "<null>" : adscope.Root.ToDNString(),
                            (adscope.Filter == null) ? "<null>" : adscope.Filter.ToString(),
                            flag2,
                            flag4
                        });
                    }
                    else
                    {
                        ADScope adscope2 = adscope;
                        if (flag2 && !flag4)
                        {
                            if (!flag5)
                            {
                                ExTraceGlobals.ScopeVerificationTracer.TraceDebug(0L, "ADSession::TryVerifyIsWithinScopes Ignoring scope ScopeRoot '{0}', ScopeFilter '{1}', IsWithinExclusiveScope '{2}', IsExclusive '{3}'", new object[]
                                {
                                    (adscope2.Root == null) ? "<null>" : adscope2.Root.ToDNString(),
                                    (adscope2.Filter == null) ? "<null>" : adscope2.Filter.ToString(),
                                    flag2,
                                    flag4
                                });
                                continue;
                            }
                            if (!flag6)
                            {
                                if (((RbacScope)adscope2).SelfFilter == null)
                                {
                                    exception = new ADScopeException(DirectoryStrings.ExArgumentNullException("RbacScope.SelfFilter"));
                                    return(false);
                                }
                                adscope2 = new RbacScope(ScopeType.Self)
                                {
                                    Root   = ((RbacScope)adscope2).SelfRoot,
                                    Filter = ((RbacScope)adscope2).SelfFilter
                                };
                            }
                        }
                        if (ADSession.IsWithinScope(obj, adscope2))
                        {
                            flag3 = true;
                            break;
                        }
                    }
                }
                if (!flag3)
                {
                    if (obj is ADObject && emptyObjectSessionOnException)
                    {
                        ((ADObject)obj).m_Session = null;
                    }
                    exception = new ADScopeException(DirectoryStrings.ErrorNoWriteScope(obj.Id.ToString()));
                    return(false);
                }
            }
            if (validationRules != null)
            {
                RuleValidationException ex = null;
                foreach (ValidationRule validationRule in validationRules)
                {
                    if (!validationRule.TryValidate(obj, out ex))
                    {
                        exception = ex;
                        return(false);
                    }
                }
            }
            return(true);
        }