Ejemplo n.º 1
0
        // Token: 0x06001055 RID: 4181 RVA: 0x0004F074 File Offset: 0x0004D274
        internal void PopulateRootAndFilter(OrganizationId organizationId, IReadOnlyPropertyBag propertyBag)
        {
            if (this.Root != null || this.Filter != null)
            {
                return;
            }
            if (this.isFromEndUserRole && propertyBag == null)
            {
                throw new ArgumentNullException("propertyBag");
            }
            if (organizationId != null)
            {
                this.SelfRoot = organizationId.OrganizationalUnit;
            }
            if (propertyBag != null)
            {
                this.SelfFilter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, propertyBag[ADObjectSchema.Id]);
            }
            switch (this.scopeType)
            {
            case ScopeType.None:
                this.Root   = null;
                this.Filter = ADScope.NoObjectFilter;
                return;

            case ScopeType.NotApplicable:
                this.Root   = null;
                this.Filter = null;
                return;

            case ScopeType.Organization:
                this.Root   = organizationId.OrganizationalUnit;
                this.Filter = null;
                return;

            case ScopeType.MyGAL:
            {
                AddressBookBase globalAddressList = this.GetGlobalAddressList(organizationId);
                this.Root = organizationId.OrganizationalUnit;
                if (globalAddressList == null)
                {
                    this.Filter = ADScope.NoObjectFilter;
                    return;
                }
                this.Filter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.AddressListMembership, globalAddressList.Id);
                return;
            }

            case ScopeType.Self:
                this.Root   = organizationId.OrganizationalUnit;
                this.Filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, propertyBag[ADObjectSchema.Id]);
                return;

            case ScopeType.MyDirectReports:
                this.Root   = organizationId.OrganizationalUnit;
                this.Filter = new ComparisonFilter(ComparisonOperator.Equal, ADOrgPersonSchema.Manager, propertyBag[ADObjectSchema.Id]);
                return;

            case ScopeType.OU:
                this.Root   = this.ouId;
                this.Filter = null;
                return;

            case ScopeType.CustomRecipientScope:
            case ScopeType.CustomConfigScope:
            case ScopeType.PartnerDelegatedTenantScope:
            case ScopeType.ExclusiveRecipientScope:
            case ScopeType.ExclusiveConfigScope:
                this.Root   = this.managementScope.RecipientRoot;
                this.Filter = this.managementScope.QueryFilter;
                return;

            case ScopeType.MyDistributionGroups:
            {
                this.Root = organizationId.OrganizationalUnit;
                QueryFilter[] array = new QueryFilter[3];
                array[0] = new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.ManagedBy, propertyBag[ADObjectSchema.Id]);
                array[1] = new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.CoManagedBy, propertyBag[ADObjectSchema.Id]);
                array[2] = new CSharpFilter <IReadOnlyPropertyBag>(delegate(IReadOnlyPropertyBag obj)
                    {
                        ADGroup adgroup = obj as ADGroup;
                        return(adgroup != null && adgroup.IsExecutingUserGroupOwner);
                    });
                this.Filter = new OrFilter(array);
                return;
            }

            case ScopeType.MyExecutive:
                break;

            case ScopeType.OrganizationConfig:
                this.Root   = organizationId.ConfigurationUnit;
                this.Filter = null;
                return;

            case ScopeType.MailboxICanDelegate:
            {
                this.Root = organizationId.OrganizationalUnit;
                QueryFilter[] array2 = new QueryFilter[2];
                array2[0] = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.MasterAccountSid, this.securityAccessToken.UserSid);
                array2[1] = new CSharpFilter <IReadOnlyPropertyBag>(delegate(IReadOnlyPropertyBag obj)
                    {
                        RawSecurityDescriptor rawSecurityDescriptor = ((ADObject)obj).ReadSecurityDescriptor();
                        if (rawSecurityDescriptor != null)
                        {
                            using (AuthzContextHandle authzContext = AuthzAuthorization.GetAuthzContext(new SecurityIdentifier(this.securityAccessToken.UserSid), false))
                            {
                                bool[] array3 = AuthzAuthorization.CheckExtendedRights(authzContext, rawSecurityDescriptor, new Guid[]
                                {
                                    WellKnownGuid.PersonalInfoPropSetGuid
                                }, null, AccessMask.WriteProp);
                                return(array3[0]);
                            }
                            return(false);
                        }
                        return(false);
                    });
                this.Filter = new OrFilter(array2);
                return;
            }

            default:
                this.Root   = null;
                this.Filter = ADScope.NoObjectFilter;
                break;
            }
        }