// Token: 0x06000DED RID: 3565 RVA: 0x00029C98 File Offset: 0x00027E98
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            notFoundReason = new LocalizedString?(LocalizedString.Empty);
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .Empty;
            SecurityIdentifier    sid     = SecurityPrincipalIdParameter.TryParseToSID(base.RawIdentity);
            string userAccountNameFromSid = SecurityPrincipalIdParameter.GetUserAccountNameFromSid(sid, this.ToString(), null);

            if (!string.IsNullOrEmpty(userAccountNameFromSid))
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjectsByAccountName <T>(userAccountNameFromSid, rootId, (IRecipientSession)session, optionalData));
                if (enumerableWrapper.HasElements())
                {
                    return(enumerableWrapper);
                }
            }
            enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            if (enumerableWrapper.HasElements())
            {
                return(enumerableWrapper);
            }
            sid = SecurityPrincipalIdParameter.GetUserSidAsSAMAccount(this, null, null);
            userAccountNameFromSid = SecurityPrincipalIdParameter.GetUserAccountNameFromSid(sid, this.ToString(), null);
            if (!string.IsNullOrEmpty(userAccountNameFromSid))
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(EnumerableWrapper <T> .Empty, base.GetObjectsByAccountName <T>(userAccountNameFromSid, rootId, (IRecipientSession)session, optionalData));
            }
            return(enumerableWrapper);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        internal virtual IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (subTreeSession == null)
            {
                throw new ArgumentNullException("subTreeSession");
            }
            notFoundReason = null;
            EnumerableWrapper <T> enumerableWrapper = null;

            if (string.IsNullOrEmpty(this.RawIdentity))
            {
                throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
            }
            enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetExactMatchObjects <T>(rootId, subTreeSession, optionalData));
            if (!enumerableWrapper.HasElements() && VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetMultitenancyObjects <T>(this.RawIdentity, rootId, session, optionalData, out notFoundReason));
            }
            if (!enumerableWrapper.HasElements())
            {
                enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsInOrganization <T>(this.RawIdentity, rootId, session, optionalData));
            }
            if (!enumerableWrapper.HasElements() && !string.IsNullOrEmpty(this.displayName) && this.displayName != this.RawIdentity)
            {
                enumerableWrapper = this.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsInOrganization <T>(this.displayName, rootId, session, optionalData));
            }
            return(enumerableWrapper);
        }
        // Token: 0x060007E9 RID: 2025 RVA: 0x0001D104 File Offset: 0x0001B304
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (subTreeSession == null)
            {
                throw new ArgumentNullException("subTreeSession");
            }
            EnumerableWrapper <T> enumerableWrapper = null;

            enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            if (enumerableWrapper.HasElements())
            {
                return(enumerableWrapper);
            }
            if (!typeof(T).IsAssignableFrom(typeof(AccountPartition)))
            {
                return(enumerableWrapper);
            }
            if (this.fqdn != null)
            {
                ADObjectId adobjectId = ADSession.GetDomainNamingContextForLocalForest();
                adobjectId = adobjectId.GetChildId("System").GetChildId(this.fqdn.ToString());
                ADPagedReader <T> collection = session.FindPaged <T>(rootId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, AccountPartitionSchema.TrustedDomainLink, adobjectId.DistinguishedName), null, 0, null);
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, collection);
                if (enumerableWrapper.HasElements())
                {
                    return(enumerableWrapper);
                }
                Guid g;
                Guid.TryParse(this.fqdn, out g);
                if (TopologyProvider.LocalForestFqdn.Equals(this.fqdn.ToString(), StringComparison.OrdinalIgnoreCase) || ADObjectId.ResourcePartitionGuid.Equals(g))
                {
                    collection        = session.FindPaged <T>(rootId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, AccountPartitionSchema.IsLocalForest, true), null, 0, null);
                    enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, collection);
                }
                if (enumerableWrapper.HasElements())
                {
                    return(enumerableWrapper);
                }
                PartitionId partitionId;
                if (ADAccountPartitionLocator.IsSingleForestTopology(out partitionId) && this.fqdn.ToString().Equals(partitionId.ForestFQDN, StringComparison.OrdinalIgnoreCase) && partitionId.PartitionObjectId != null)
                {
                    base.UpdateInternalADObjectId(new ADObjectId(partitionId.PartitionObjectId.Value));
                    enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetExactMatchObjects <T>(rootId, session, optionalData));
                }
            }
            return(enumerableWrapper);
        }
Ejemplo n.º 5
0
        // Token: 0x06000E58 RID: 3672 RVA: 0x0002AA78 File Offset: 0x00028C78
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T>       objects = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(objects);

            if (!wrapper.HasElements())
            {
                LocalizedString value;
                if (((IConfigDataProvider)session).Source != null)
                {
                    value = Strings.ErrorManagementObjectNotFoundWithSource(this.ToString(), ((IConfigDataProvider)session).Source);
                }
                else
                {
                    value = Strings.ErrorManagementObjectNotFound(this.ToString());
                }
                if (notFoundReason != null)
                {
                    string          notFound        = value;
                    LocalizedString?localizedString = notFoundReason;
                    value = Strings.ErrorNotFoundWithReason(notFound, (localizedString != null) ? localizedString.GetValueOrDefault() : null);
                }
                notFoundReason = new LocalizedString?(Strings.ErrorRoleAssignmentNotFound(value));
            }
            return(objects);
        }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(MobileDevice).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            notFoundReason = new LocalizedString?(Strings.WrongActiveSyncDeviceIdParameter(this.ToString()));
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetExactMatchObjects <T>(rootId, subTreeSession, optionalData));

            if (!wrapper.HasElements() && base.RawIdentity != null)
            {
                string[] array = base.RawIdentity.Split(new char[]
                {
                    '\\'
                });
                if (array.Length == 3)
                {
                    string text  = array[0];
                    string text2 = array[2];
                    if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
                    {
                        wrapper = EnumerableWrapper <T> .GetWrapper(this.GetObjectsInOrganization <T>(text2, rootId, session, optionalData), new MobileDeviceIdParameter.MobileDeviceUsernameFilter <T>(text));
                    }
                }
            }
            return(wrapper);
        }
        // Token: 0x0600096A RID: 2410 RVA: 0x00020668 File Offset: 0x0001E868
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(Database).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            new List <T>();
            notFoundReason = null;
            if (rootId != null)
            {
                Server server = (Server)((IConfigDataProvider)session).Read <Server>(rootId);
                if (server != null)
                {
                    if (optionalData != null && optionalData.AdditionalFilter != null)
                    {
                        throw new NotSupportedException("Supplying Additional Filters and a RootId is not currently supported by this IdParameter.");
                    }
                    return(server.GetDatabases <T>(this.AllowInvalid));
                }
            }
            IEnumerable <T> objects    = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            IEnumerable <T> enumerable = from tmpDb in objects
                                         where tmpDb.IsValid || this.AllowInvalid
                                         select tmpDb;
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(enumerable);

            if (!wrapper.HasElements() && this.legacyParameter != null)
            {
                wrapper = EnumerableWrapper <T> .GetWrapper(this.legacyParameter.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            return(wrapper);
        }
Ejemplo n.º 8
0
        // Token: 0x06000AD6 RID: 2774 RVA: 0x000232D4 File Offset: 0x000214D4
        internal override IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjectsInOrganization <T>(identityString, rootId, session, optionalData));

            if (wrapper.HasElements())
            {
                return(wrapper);
            }
            int num = identityString.IndexOf('\\');

            if (0 < num && identityString.Length > num + 1)
            {
                string propertyValue       = identityString.Substring(num + 1);
                string unescapedCommonName = identityString.Substring(0, num);
                OptionalIdentityData optionalIdentityData = null;
                if (optionalData != null)
                {
                    optionalIdentityData = optionalData.Clone();
                    optionalIdentityData.ConfigurationContainerRdn = null;
                }
                ADObjectId  adobjectId = (rootId == null) ? MessageClassificationIdParameter.DefaultRoot((IConfigDataProvider)session) : rootId;
                ADObjectId  childId    = adobjectId.Parent.GetChildId(unescapedCommonName);
                QueryFilter filter     = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, propertyValue);
                return(base.PerformPrimarySearch <T>(filter, childId, session, false, optionalIdentityData));
            }
            return(new T[0]);
        }
Ejemplo n.º 9
0
        internal override IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData)
        {
            IConfigurationSession scSession = session as IConfigurationSession;

            string[]              commonNames = AddressListIdParameter.GetCommonNames(identityString);
            ADObjectId            identity    = this.ResolveAddressListId(AddressListIdParameter.GetRootContainerId(scSession), commonNames);
            EnumerableWrapper <T> wrapper     = EnumerableWrapper <T> .GetWrapper(base.GetADObjectIdObjects <T>(identity, rootId, session, optionalData));

            if (wrapper.HasElements())
            {
                return(wrapper);
            }
            wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjectsInOrganization <T>(identityString, rootId, session, optionalData));

            if (wrapper.HasElements() || commonNames.Length == 1 || !identityString.Contains("*"))
            {
                return(wrapper);
            }
            Queue <ADObjectId> queue = new Queue <ADObjectId>();

            queue.Enqueue(rootId ?? AddressListIdParameter.GetRootContainerId(scSession));
            for (int i = 0; i < commonNames.Length - 1; i++)
            {
                Queue <ADObjectId> queue2 = new Queue <ADObjectId>();
                string             name   = commonNames[i];
                foreach (ADObjectId rootId2 in queue)
                {
                    QueryFilter     filter     = base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, name);
                    IEnumerable <T> enumerable = this.PerformSearch <T>(filter, rootId2, session, false);
                    foreach (T t in enumerable)
                    {
                        queue2.Enqueue((ADObjectId)t.Identity);
                    }
                }
                queue = queue2;
            }
            string name2 = commonNames[commonNames.Length - 1];
            List <IEnumerable <T> > list = new List <IEnumerable <T> >();

            foreach (ADObjectId rootId3 in queue)
            {
                QueryFilter     filter2 = base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, name2);
                IEnumerable <T> item    = base.PerformPrimarySearch <T>(filter2, rootId3, session, false, optionalData);
                list.Add(item);
            }
            return(EnumerableWrapper <T> .GetWrapper(list));
        }
Ejemplo n.º 10
0
        // Token: 0x06000DCD RID: 3533 RVA: 0x00029468 File Offset: 0x00027668
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            notFoundReason = null;
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements())
            {
                wrapper = EnumerableWrapper <T> .GetWrapper(this.TryGetObjectsFromDC <T>(rootId, subTreeSession, optionalData));
            }
            if (!wrapper.HasElements() && !Guid.Empty.Equals(this.guid) && typeof(T).IsAssignableFrom(typeof(ADGroup)))
            {
                ADObjectId containerId;
                if (session.SessionSettings.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId))
                {
                    containerId = session.GetConfigurationNamingContext();
                }
                else
                {
                    containerId = session.SessionSettings.CurrentOrganizationId.ConfigurationUnit;
                }
                bool    useGlobalCatalog = session.UseGlobalCatalog;
                bool    useConfigNC      = session.UseConfigNC;
                ADGroup adgroup          = null;
                try
                {
                    session.UseGlobalCatalog = true;
                    session.UseConfigNC      = false;
                    adgroup = session.ResolveWellKnownGuid <ADGroup>(this.guid, containerId);
                }
                finally
                {
                    session.UseGlobalCatalog = useGlobalCatalog;
                    session.UseConfigNC      = useConfigNC;
                }
                if (adgroup != null)
                {
                    wrapper = EnumerableWrapper <T> .GetWrapper(new List <ADGroup>(1)
                    {
                        adgroup
                    }.Cast <T>());
                }
            }
            return(wrapper);
        }
Ejemplo n.º 11
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (notFoundReason == null && !wrapper.HasElements() && ADRawEntryIdParameter.IsSingleOrDoubleAsterisks(base.RawIdentity))
            {
                notFoundReason = new LocalizedString?(Strings.ErrorNotSupportSingletonWildcard);
            }
            return(wrapper);
        }
        // Token: 0x06000AE0 RID: 2784 RVA: 0x000233F0 File Offset: 0x000215F0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements() && base.RawIdentity.StartsWith("\\") && base.RawIdentity.Length > 1)
            {
                string identityString = base.RawIdentity.Substring(1);
                wrapper = EnumerableWrapper <T> .GetWrapper(this.GetObjectsInOrganization <T>(identityString, rootId, session, optionalData));
            }
            return(wrapper);
        }
        // Token: 0x06000B8C RID: 2956 RVA: 0x00024868 File Offset: 0x00022A68
        internal static ADObject GetRawRoleAssignee(RoleAssigneeIdParameter user, IConfigurationSession configSession, IRecipientSession recipientSession)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            if (configSession == null)
            {
                throw new ArgumentNullException("configSession");
            }
            IEnumerable <ADObject>       enumerable = user.GetObjects <RoleAssignmentPolicy>(null, configSession).Cast <ADObject>();
            EnumerableWrapper <ADObject> wrapper    = EnumerableWrapper <ADObject> .GetWrapper(enumerable);

            if (!wrapper.HasElements())
            {
                SecurityIdentifier securityIdentifier = SecurityPrincipalIdParameter.TryParseToSID(user.RawIdentity);
                if (null != securityIdentifier)
                {
                    ADRecipient adrecipient = recipientSession.FindBySid(securityIdentifier);
                    if (adrecipient != null)
                    {
                        enumerable = new ADObject[]
                        {
                            adrecipient
                        };
                        wrapper = EnumerableWrapper <ADObject> .GetWrapper(enumerable);
                    }
                }
                else
                {
                    enumerable = user.GetObjects <ADRecipient>(null, recipientSession).Cast <ADObject>();
                    wrapper    = EnumerableWrapper <ADObject> .GetWrapper(enumerable);
                }
            }
            ADObject result = null;

            using (IEnumerator <ADObject> enumerator = wrapper.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    throw new ManagementObjectNotFoundException(Strings.ErrorPolicyUserOrSecurityGroupNotFound(user.ToString()));
                }
                result = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    throw new ManagementObjectAmbiguousException(Strings.ErrorPolicyUserOrSecurityGroupNotUnique(user.ToString()));
                }
            }
            return(result);
        }
        // Token: 0x06000DBB RID: 3515 RVA: 0x00028ED0 File Offset: 0x000270D0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (!typeof(RemovedMailbox).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (base.InternalADObjectId == null && string.IsNullOrEmpty(base.RawIdentity))
            {
                throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
            }
            notFoundReason = null;
            string     orgName    = null;
            string     text       = base.RawIdentity;
            ADObjectId adobjectId = base.InternalADObjectId ?? RemovedMailboxIdParameter.GetObjectIdFromCanonicalName(base.RawIdentity);

            if (adobjectId == null && !string.IsNullOrEmpty(base.RawIdentity))
            {
                int num = base.RawIdentity.IndexOf('\\');
                if (num > 0 && base.RawIdentity.Length > num + 1)
                {
                    orgName = base.RawIdentity.Substring(0, num);
                    text    = base.RawIdentity.Substring(num + 1);
                }
            }
            QueryFilter      queryFilter;
            bool             flag = this.TryGetOrganizationFilter(rootId, adobjectId, orgName, out queryFilter);
            ComparisonFilter databaseRetentionPeriodFilter = this.GetDatabaseRetentionPeriodFilter();
            QueryFilter      basicFilter = QueryFilter.AndTogether(new QueryFilter[]
            {
                queryFilter,
                new ExistsFilter(RemovedMailboxSchema.PreviousDatabase),
                databaseRetentionPeriodFilter
            });
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .Empty;

            if (adobjectId != null)
            {
                enumerableWrapper = this.SearchByObjectId <T>(adobjectId, session, optionalData, basicFilter);
            }
            if (flag && (enumerableWrapper == null || !enumerableWrapper.HasElements()) && !string.IsNullOrEmpty(text))
            {
                enumerableWrapper = this.SearchByObjectAttributes <T>(session, optionalData, text, basicFilter);
            }
            enumerableWrapper = EnumerableWrapper <T> .GetWrapper(enumerableWrapper);

            TaskLogger.LogExit();
            return(enumerableWrapper);
        }
Ejemplo n.º 15
0
        internal virtual IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData) where T : IConfigurable, new()
        {
            if (string.IsNullOrEmpty(identityString))
            {
                throw new ArgumentException("IdentityString must contain a non-empty value", "identityString");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(this.PerformPrimarySearch <T>(this.GetNameMatchingFilter(identityString, false), rootId, session, true, optionalData));

            if (!wrapper.HasElements() && this.IsWildcardDefined(identityString))
            {
                wrapper = EnumerableWrapper <T> .GetWrapper(this.PerformPrimarySearch <T>(this.GetNameMatchingFilter(identityString, true), rootId, session, true, optionalData));
            }
            return(wrapper);
        }
Ejemplo n.º 16
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (!typeof(ADRecipient).IsAssignableFrom(typeof(T)) && !typeof(ReducedRecipient).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (Globals.IsConsumerOrganization(session.SessionSettings.CurrentOrganizationId) && ADSessionFactory.UseAggregateSession(session.SessionSettings))
            {
                return(ConsumerMailboxIdParameter.Parse(base.RawIdentity).GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!enumerableWrapper.HasElements() && session is IRecipientSession)
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsByAccountName <T>(base.RawIdentity, rootId, (IRecipientSession)session, optionalData));
            }
            if (enumerableWrapper.HasUnfilteredElements() && !enumerableWrapper.HasElements())
            {
                notFoundReason = new LocalizedString?(this.GetErrorMessageForWrongType(this.ToString()));
            }
            TaskLogger.LogExit();
            return(enumerableWrapper);
        }
        // Token: 0x060009FE RID: 2558 RVA: 0x000217C8 File Offset: 0x0001F9C8
        internal override IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData)
        {
            string[] commonNames = AddressListIdParameter.GetCommonNames(identityString);
            if (commonNames.Length == 1)
            {
                ADObjectId            rootContainerId = GlobalAddressListIdParameter.GetRootContainerId((IConfigurationSession)session);
                ADObjectId            childId         = rootContainerId.GetChildId(commonNames[0]);
                EnumerableWrapper <T> wrapper         = EnumerableWrapper <T> .GetWrapper(base.GetADObjectIdObjects <T>(childId, rootId, session, optionalData), this.GetEnumerableFilter <T>());

                if (wrapper.HasElements())
                {
                    return(wrapper);
                }
            }
            return(base.GetObjectsInOrganization <T>(identityString, rootId, session, optionalData));
        }
Ejemplo n.º 18
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(Container).IsAssignableFrom(typeof(T)) && !typeof(ADContainer).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements())
            {
                notFoundReason = null;
                QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, base.RawIdentity);
                wrapper = EnumerableWrapper <T> .GetWrapper(base.PerformPrimarySearch <T>(filter, ((IConfigurationSession)session).GetOrgContainerId(), session, false, optionalData));
            }
            return(wrapper);
        }
Ejemplo n.º 19
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (wrapper.HasElements())
            {
                return(wrapper);
            }
            SecurityPrincipalIdParameter securityPrincipalIdParameter = new SecurityPrincipalIdParameter(base.RawIdentity);
            OptionalIdentityData         optionalIdentityData         = (optionalData == null) ? new OptionalIdentityData() : optionalData.Clone();

            optionalIdentityData.AdditionalFilter = QueryFilter.AndTogether(new QueryFilter[]
            {
                optionalIdentityData.AdditionalFilter,
                RecipientIdParameter.GetRecipientTypeFilter(this.RecipientTypes)
            });
            return(securityPrincipalIdParameter.GetObjects <T>(rootId, session, subTreeSession, optionalIdentityData, out notFoundReason));
        }
        // Token: 0x060008C1 RID: 2241 RVA: 0x0001EC1C File Offset: 0x0001CE1C
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (typeof(T) != typeof(ClientAccessArray))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements() && this.fqdn != null)
            {
                QueryFilter filter = new OrFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ClientAccessArraySchema.Fqdn, this.fqdn),
                    new ComparisonFilter(ComparisonOperator.Equal, ClientAccessArraySchema.ExchangeLegacyDN, this.fqdn)
                });
                wrapper = EnumerableWrapper <T> .GetWrapper(base.PerformPrimarySearch <T>(filter, rootId, session, true, optionalData));
            }
            return(wrapper);
        }
Ejemplo n.º 21
0
        public bool MoveNext()
        {
            if (this.mainEnum == null)
            {
                EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(this.conditionalEnumerable);

                if (wrapper.HasElements())
                {
                    this.mainEnum         = wrapper.GetEnumerator();
                    this.secondEnumerable = null;
                }
                else
                {
                    this.mainEnum = this.secondEnumerable.GetEnumerator();
                    this.conditionalEnumerable = null;
                }
            }
            return(this.mainEnum.MoveNext());
        }
Ejemplo n.º 22
0
        internal IEnumerable <T> GetExactMatchObjects <T>(ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData) where T : IConfigurable, new()
        {
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .Empty;
            ADObjectId            identity;

            if (this.InternalADObjectId != null)
            {
                enumerableWrapper = EnumerableWrapper <T> .GetWrapper(this.GetADObjectIdObjects <T>(this.InternalADObjectId, rootId, session, optionalData));
            }
            else if (ADIdParameter.TryResolveCanonicalName(this.RawIdentity, out identity))
            {
                enumerableWrapper = EnumerableWrapper <T> .GetWrapper(this.GetADObjectIdObjects <T>(identity, rootId, session, optionalData));

                if (enumerableWrapper.HasElements())
                {
                    this.UpdateInternalADObjectId(identity);
                }
            }
            return(enumerableWrapper);
        }
        // Token: 0x06000977 RID: 2423 RVA: 0x000208F0 File Offset: 0x0001EAF0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            IEnumerable <T> enumerable = null;

            notFoundReason = null;
            if (typeof(T) != typeof(DetailsTemplate))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            try
            {
                if (base.InternalADObjectId != null)
                {
                    return(base.GetADObjectIdObjects <T>(base.InternalADObjectId, rootId, subTreeSession, optionalData));
                }
                ADObjectId  childId = ((IConfigurationSession)session).GetOrgContainerId().GetChildId("Addressing").GetChildId("Display-Templates");
                QueryFilter filter  = null;
                if (this.language != null)
                {
                    childId = childId.GetChildId(this.language.LCID.ToString("X"));
                }
                if (this.type != null)
                {
                    filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, this.type);
                }
                enumerable = base.PerformPrimarySearch <T>(filter, childId, session, true, optionalData);
                EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(enumerable);

                if (wrapper.HasElements())
                {
                    return(wrapper);
                }
                enumerable = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            }
            finally
            {
                TaskLogger.LogExit();
            }
            return(enumerable);
        }
        // Token: 0x060008DA RID: 2266 RVA: 0x0001EEE8 File Offset: 0x0001D0E8
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (typeof(T) != typeof(Server) && typeof(T) != typeof(MiniServer) && typeof(T) != typeof(MiniClientAccessServerOrArray))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!wrapper.HasElements() && this.Fqdn != null)
            {
                QueryFilter filter = new OrFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.Fqdn, this.Fqdn),
                    new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ExchangeLegacyDN, this.Fqdn)
                });
                wrapper = EnumerableWrapper <T> .GetWrapper(base.PerformPrimarySearch <T>(filter, rootId, session, true, optionalData));
            }
            if (typeof(T) == typeof(Server))
            {
                List <T> list = new List <T>();
                foreach (T t in wrapper)
                {
                    list.Add(t);
                    string     key        = ((ADObjectId)t.Identity).ToDNString().ToLowerInvariant();
                    Server     server     = (Server)((object)t);
                    ServerInfo serverInfo = new ServerInfo();
                    serverInfo.Identity = server.Id;
                    serverInfo.Role     = server.CurrentServerRole;
                    lock (ServerIdParameter.serverRoleCache)
                    {
                        ServerIdParameter.serverRoleCache[key] = serverInfo;
                        ServerIdParameter.serverRoleCache[server.Name.ToLowerInvariant()] = serverInfo;
                        ServerIdParameter.serverRoleCache[server.Fqdn.ToLowerInvariant()] = serverInfo;
                    }
                }
                return(list);
            }
            return(wrapper);
        }
Ejemplo n.º 25
0
        // Token: 0x06000D66 RID: 3430 RVA: 0x00028850 File Offset: 0x00026A50
        internal sealed override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            notFoundReason = null;
            bool flag = false;

            if (base.InternalADObjectId == null && this.folderId != null)
            {
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(session.ConsistencyMode, session.SessionSettings, 205, "GetObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\RecipientParameters\\MailPublicFolderIdParameter.cs");
                using (PublicFolderDataProvider publicFolderDataProvider = new PublicFolderDataProvider(tenantOrTopologyConfigurationSession, "resolve-MailPublicFolderIdParameter", Guid.Empty))
                {
                    PublicFolder publicFolder = (PublicFolder)publicFolderDataProvider.Read <PublicFolder>(this.folderId);
                    if (publicFolder == null)
                    {
                        return(new List <T>());
                    }
                    flag = true;
                    if (!publicFolder.MailEnabled)
                    {
                        notFoundReason = new LocalizedString?(Strings.ErrorPublicFolderMailDisabled(this.folderId.ToString()));
                        return(new List <T>());
                    }
                    if (publicFolder.ProxyGuid == null)
                    {
                        notFoundReason = new LocalizedString?(Strings.ErrorPublicFolderGeneratingProxy(this.folderId.ToString()));
                        return(new List <T>());
                    }
                    this.Initialize(new ADObjectId(publicFolder.ProxyGuid));
                }
            }
            IEnumerable <T>       objects = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(objects);

            if (!wrapper.HasElements() && flag)
            {
                notFoundReason = new LocalizedString?(Strings.ErrorPublicFolderMailDisabled(this.folderId.ToString()));
            }
            return(wrapper);
        }
Ejemplo n.º 26
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.Identity
            });
            if (this.Identity != null)
            {
                LocalizedString?localizedString;
                IEnumerable <ReducedRecipient>       dataObjects = base.GetDataObjects <ReducedRecipient>(this.Identity, base.DataSession, this.RootId, base.OptionalIdentityData, out localizedString);
                EnumerableWrapper <ReducedRecipient> wrapper     = EnumerableWrapper <ReducedRecipient> .GetWrapper(dataObjects);

                if (!base.HasErrors && !wrapper.HasElements())
                {
                    base.WriteError(new ManagementObjectNotFoundException(localizedString ?? base.GetErrorMessageObjectNotFound(this.Identity.ToString(), typeof(ReducedRecipient).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, null);
                }
                this.WriteResult <ReducedRecipient>(dataObjects);
            }
            else
            {
                base.InternalProcessRecord();
            }
            TaskLogger.LogExit();
        }
        // Token: 0x06000A34 RID: 2612 RVA: 0x00021EB4 File Offset: 0x000200B4
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T>       enumerable        = null;
            EnumerableWrapper <T> enumerableWrapper = null;

            notFoundReason = null;
            if (string.IsNullOrEmpty(this.storageGroupName))
            {
                enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            if (!string.IsNullOrEmpty(base.CommonName) && (enumerableWrapper == null || !enumerableWrapper.HasElements()))
            {
                string            serverName        = this.storageGroupName;
                ServerIdParameter serverIdParameter = base.ServerId;
                if (string.IsNullOrEmpty(this.storageGroupName))
                {
                    serverName        = base.ServerName;
                    serverIdParameter = new ServerIdParameter();
                }
                ADObjectId[] matchingIdentities = serverIdParameter.GetMatchingIdentities((IConfigDataProvider)session);
                for (int i = 0; i < matchingIdentities.Length; i++)
                {
                    if (ServerIdParameter.HasRole(matchingIdentities[i], this.RoleRestriction, (IConfigDataProvider)session) || (base.AllowLegacy && !ServerIdParameter.HasRole(matchingIdentities[i], ServerRole.All, (IConfigDataProvider)session)))
                    {
                        if (string.IsNullOrEmpty(this.storageGroupName))
                        {
                            rootId     = matchingIdentities[i].GetChildId("InformationStore").GetChildId(serverName);
                            enumerable = base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, base.CommonName), rootId, session, true, optionalData);
                        }
                        else
                        {
                            List <T> list = new List <T>();
                            IEnumerable <StorageGroup> enumerable2 = base.PerformSearch <StorageGroup>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, this.storageGroupName), matchingIdentities[i], session, true);
                            foreach (StorageGroup storageGroup in enumerable2)
                            {
                                enumerable = base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, base.CommonName), storageGroup.Id, session, true, optionalData);
                                list.AddRange(enumerable);
                            }
                            enumerable = list;
                        }
                    }
                }
            }
            else
            {
                enumerable = enumerableWrapper;
            }
            if (enumerable == null)
            {
                enumerable = new List <T>();
            }
            return(enumerable);
        }
Ejemplo n.º 28
0
        // Token: 0x06000A29 RID: 2601 RVA: 0x00021A8C File Offset: 0x0001FC8C
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T> enumerable = null;
            List <T>        list       = new List <T>();

            notFoundReason = null;
            int num  = 0;
            int num2 = 0;

            if (base.InternalADObjectId != null)
            {
                enumerable = base.GetADObjectIdObjects <T>(base.InternalADObjectId, rootId, subTreeSession, optionalData);
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(enumerable);

            if (wrapper.HasElements())
            {
                using (IEnumerator <T> enumerator = wrapper.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        T item = enumerator.Current;
                        if (ServerIdParameter.HasRole((ADObjectId)item.Identity, this.RoleRestriction, (IConfigDataProvider)session) || (this.AllowLegacy && !ServerIdParameter.HasRole((ADObjectId)item.Identity, ServerRole.All, (IConfigDataProvider)session)))
                        {
                            list.Add(item);
                        }
                        else if (!ServerIdParameter.HasRole((ADObjectId)item.Identity, ServerRole.All, (IConfigDataProvider)session))
                        {
                            num2++;
                        }
                        else
                        {
                            num++;
                        }
                    }
                    goto IL_21B;
                }
            }
            if (!string.IsNullOrEmpty(this.CommonName) && this.ServerId != null)
            {
                ADObjectId[] matchingIdentities = this.ServerId.GetMatchingIdentities((IConfigDataProvider)session);
                foreach (ADObjectId rootId2 in matchingIdentities)
                {
                    enumerable = base.GetObjectsInOrganization <T>(this.CommonName, rootId2, session, optionalData);
                    foreach (T item2 in enumerable)
                    {
                        if (ServerIdParameter.HasRole((ADObjectId)item2.Identity, this.RoleRestriction, (IConfigDataProvider)session) || (this.AllowLegacy && !ServerIdParameter.HasRole((ADObjectId)item2.Identity, ServerRole.All, (IConfigDataProvider)session)))
                        {
                            list.Add(item2);
                        }
                        else if (!ServerIdParameter.HasRole((ADObjectId)item2.Identity, ServerRole.All, (IConfigDataProvider)session))
                        {
                            num2++;
                        }
                        else
                        {
                            num++;
                        }
                    }
                }
            }
IL_21B:
            if (list.Count == 0)
            {
                if (num2 != 0)
                {
                    notFoundReason = new LocalizedString?(Strings.ExceptionLegacyObjects(this.ToString()));
                }
                if (num != 0)
                {
                    notFoundReason = new LocalizedString?(Strings.ExceptionRoleNotFoundObjects(this.ToString()));
                }
            }
            return(list);
        }
Ejemplo n.º 29
0
        internal IEnumerable <T> GetADObjectIdObjects <T>(ADObjectId identity, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData) where T : IConfigurable, new()
        {
            if (identity != null)
            {
                OrganizationId organizationId;
                if (this.InternalADObjectId != null && this.InternalADObjectId.Equals(identity) && this.orgIdResolved)
                {
                    organizationId = this.resolvedOrganizationId;
                }
                else
                {
                    organizationId = this.GetOrganizationId(session.SessionSettings.CurrentOrganizationId, identity);
                }
                IDirectorySession directorySession = session;
                if (organizationId != null)
                {
                    directorySession = TaskHelper.UnderscopeSessionToOrganization(session, organizationId, true);
                }
                if (session.ConfigScope == ConfigScopes.TenantSubTree)
                {
                    directorySession = ADSession.RescopeSessionToTenantSubTree(directorySession);
                }
                if (directorySession.IsRootIdWithinScope <T>(rootId))
                {
                    if (ADObjectId.Equals(identity, identity.DomainId) && !typeof(OrganizationalUnitIdParameterBase).IsAssignableFrom(base.GetType()))
                    {
                        if (!typeof(ADRawEntryIdParameter).IsAssignableFrom(base.GetType()))
                        {
                            goto IL_15F;
                        }
                    }
                    try
                    {
                        ADObjectId rootId2 = rootId;
                        bool       enforceContainerizedScoping = directorySession.EnforceContainerizedScoping;
                        bool       flag = directorySession is IRecipientSession;
                        if (rootId == null && !string.IsNullOrEmpty(identity.DistinguishedName))
                        {
                            if (!ADObjectId.Equals(identity, identity.DomainId) && directorySession.IsRootIdWithinScope <T>(identity.Parent))
                            {
                                rootId2 = identity.Parent;
                            }
                            else if (directorySession.IsRootIdWithinScope <T>(identity))
                            {
                                rootId2 = identity;
                                if (flag)
                                {
                                    directorySession.EnforceContainerizedScoping = false;
                                }
                            }
                        }
                        try
                        {
                            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(this.PerformPrimarySearch <T>(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, identity), rootId2, directorySession, true, optionalData));

                            if (wrapper.HasElements())
                            {
                                return(wrapper);
                            }
                        }
                        finally
                        {
                            if (flag)
                            {
                                directorySession.EnforceContainerizedScoping = enforceContainerizedScoping;
                            }
                        }
                    }
                    catch (LocalizedException exception)
                    {
                        if (!TaskHelper.IsTaskKnownException(exception))
                        {
                            throw;
                        }
                    }
IL_15F:
                    if (identity.ObjectGuid != Guid.Empty)
                    {
                        return(this.PerformPrimarySearch <T>(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Guid, identity.ObjectGuid), rootId, directorySession, true, optionalData));
                    }
                }
            }
            return(EnumerableWrapper <T> .Empty);
        }
Ejemplo n.º 30
0
        internal override IEnumerable <T> GetObjectsInOrganization <T>(string identityString, ADObjectId rootId, IDirectorySession session, OptionalIdentityData optionalData)
        {
            if (Globals.IsConsumerOrganization(session.SessionSettings.CurrentOrganizationId) && ADSessionFactory.UseAggregateSession(session.SessionSettings))
            {
                LocalizedString?localizedString;
                return(ConsumerMailboxIdParameter.Parse(base.RawIdentity).GetObjects <T>(rootId, session, session, optionalData, out localizedString));
            }
            List <QueryFilter> list = new List <QueryFilter>();
            QueryFilter        item = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.ExternalDirectoryObjectId, identityString);

            list.Add(item);
            SmtpAddress smtpAddress = new SmtpAddress(identityString);

            if (smtpAddress.IsValidAddress)
            {
                QueryFilter item2 = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.EmailAddresses, "SMTP:" + smtpAddress.ToString());
                list.Add(item2);
                QueryFilter item3 = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.ExternalEmailAddress, "SMTP:" + smtpAddress.ToString());
                list.Add(item3);
                QueryFilter item4 = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.WindowsLiveID, smtpAddress.ToString());
                list.Add(item4);
            }
            QueryFilter item5 = base.CreateWildcardOrEqualFilter(ADUserSchema.UserPrincipalName, identityString);

            list.Add(item5);
            QueryFilter item6 = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.LegacyExchangeDN, identityString);

            list.Add(item6);
            QueryFilter item7 = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.EmailAddresses, "X500:" + identityString);

            list.Add(item7);
            QueryFilter queryFilter = base.CreateWildcardOrEqualFilter(ADRecipientSchema.Alias, identityString);

            if (queryFilter != null)
            {
                list.Add(queryFilter);
            }
            if (this.SearchWithDisplayName)
            {
                QueryFilter queryFilter2 = base.CreateWildcardOrEqualFilter(ADRecipientSchema.DisplayName, identityString);
                if (queryFilter2 != null)
                {
                    list.Add(queryFilter2);
                }
            }
            NetID propertyValue;

            if (NetID.TryParse(identityString, out propertyValue))
            {
                QueryFilter item8 = new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.NetID, propertyValue);
                list.Add(item8);
            }
            Guid guid = Guid.Empty;

            if (base.InternalADObjectId != null)
            {
                guid = base.InternalADObjectId.ObjectGuid;
            }
            if (Guid.Empty != guid || GuidHelper.TryParseGuid(identityString, out guid))
            {
                list.Add(new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.ExchangeGuid, guid));
                list.Add(new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.ArchiveGuid, guid));
                list.Add(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ExchangeObjectId, guid));
                list.Add(new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.MailboxGuidsRaw, guid.ToString()));
                this.rawMailboxGuidInvolvedInSearch = guid;
            }
            QueryFilter queryFilter3        = QueryFilter.OrTogether(list.ToArray());
            QueryFilter recipientTypeFilter = RecipientIdParameter.GetRecipientTypeFilter(this.RecipientTypes);

            queryFilter3 = QueryFilter.AndTogether(new QueryFilter[]
            {
                queryFilter3,
                recipientTypeFilter
            });
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.PerformPrimarySearch <T>(queryFilter3, rootId, session, true, optionalData));

            if (!enumerableWrapper.HasElements())
            {
                this.rawMailboxGuidInvolvedInSearch = Guid.Empty;
                OptionalIdentityData optionalIdentityData;
                if (optionalData == null)
                {
                    optionalIdentityData = new OptionalIdentityData();
                    optionalIdentityData.AdditionalFilter = recipientTypeFilter;
                }
                else
                {
                    optionalIdentityData = optionalData.Clone();
                    optionalIdentityData.AdditionalFilter = QueryFilter.AndTogether(new QueryFilter[]
                    {
                        optionalIdentityData.AdditionalFilter,
                        recipientTypeFilter
                    });
                }
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, base.GetObjectsInOrganization <T>(identityString, rootId, session, optionalIdentityData));
            }
            return(enumerableWrapper);
        }