Ejemplo n.º 1
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.º 2
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);
        }
        // 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.º 4
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));
        }
        // Token: 0x06000DC0 RID: 3520 RVA: 0x00029194 File Offset: 0x00027394
        private EnumerableWrapper <T> SearchByObjectId <T>(ADObjectId objectId, IDirectorySession session, OptionalIdentityData optionalData, QueryFilter basicFilter) where T : IConfigurable, new()
        {
            EnumerableWrapper <T> result = EnumerableWrapper <T> .Empty;

            try
            {
                IEnumerable <T> enumerable = base.PerformPrimarySearch <T>(QueryFilter.AndTogether(new QueryFilter[]
                {
                    basicFilter,
                    new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, objectId)
                }), null, session, false, optionalData);
                result = EnumerableWrapper <T> .GetWrapper(enumerable);
            }
            catch (ADReferralException)
            {
            }
            return(result);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
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);
        }
        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());
        }
        // 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);
        }
        // Token: 0x06000C7A RID: 3194 RVA: 0x00027404 File Offset: 0x00025604
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IConfigurationSession))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(session.GetType().Name), "type");
            }
            notFoundReason = null;
            EnumerableWrapper <T> result = EnumerableWrapper <T> .Empty;

            if (this.IsWildcardDefined(base.RawIdentity))
            {
                notFoundReason = new LocalizedString?(Strings.ErrorOrganizationWildcard);
                return(result);
            }
            OrganizationId organizationId = this.ResolveOrganizationId();

            if (!OrganizationId.ForestWideOrgId.Equals(organizationId))
            {
                ADSessionSettings adsessionSettings = ADSessionSettings.FromCustomScopeSet(ScopeSet.ResolveUnderScope(organizationId, session.SessionSettings.ScopeSet), session.SessionSettings.RootOrgId, organizationId, session.SessionSettings.ExecutingUserOrganizationId, false);
                adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(session.DomainController, session.ReadOnly, session.ConsistencyMode, session.NetworkCredential, adsessionSettings, 257, "GetObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\TenantRelocationRequestIdParameter.cs");
                tenantConfigurationSession.UseConfigNC      = session.UseConfigNC;
                tenantConfigurationSession.UseGlobalCatalog = session.UseGlobalCatalog;
                if (typeof(TenantRelocationRequest).Equals(typeof(T)) && organizationId.ConfigurationUnit != null)
                {
                    List <TenantRelocationRequest> list  = new List <TenantRelocationRequest>();
                    TenantRelocationRequest[]      array = tenantConfigurationSession.Find <TenantRelocationRequest>(organizationId.ConfigurationUnit, QueryScope.SubTree, TenantRelocationRequest.TenantRelocationRequestFilter, null, 1);
                    if (array != null && array.Length > 0)
                    {
                        list.Add(array[0]);
                        result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list, this.GetEnumerableFilter <T>());
                    }
                }
            }
            TaskLogger.LogExit();
            return(result);
        }
Ejemplo n.º 11
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (typeof(T) != typeof(AddressBookBase))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            IConfigurationSession scSession = session as IConfigurationSession;

            if ("\\" == base.RawIdentity)
            {
                notFoundReason = null;
                ADObjectId rootContainerId = AddressListIdParameter.GetRootContainerId(scSession);
                return(EnumerableWrapper <T> .GetWrapper(base.GetADObjectIdObjects <T>(rootContainerId, rootId, subTreeSession, optionalData), this.GetEnumerableFilter <T>()));
            }
            return(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
        }
Ejemplo n.º 12
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.º 15
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);
        }
        // Token: 0x06000E70 RID: 3696 RVA: 0x0002ADC4 File Offset: 0x00028FC4
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (typeof(T) != typeof(MailboxTransportServer) && typeof(T) != typeof(FrontendTransportServer))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            List <T> list = new List <T>();

            foreach (T item in wrapper)
            {
                if (this.MatchServer((ADObjectId)item.Identity))
                {
                    list.Add(item);
                }
            }
            if (list.Count == 0 && this.identityPassedIn != null)
            {
                notFoundReason = new LocalizedString?(Strings.ErrorManagementObjectNotFound(this.identityPassedIn.RawIdentity));
            }
            return(list);
        }
        // Token: 0x06000DC1 RID: 3521 RVA: 0x000291F0 File Offset: 0x000273F0
        private EnumerableWrapper <T> SearchByObjectAttributes <T>(IDirectorySession session, OptionalIdentityData optionalData, string queryFilter, QueryFilter basicFilter) where T : IConfigurable, new()
        {
            List <QueryFilter> list         = new List <QueryFilter>();
            QueryFilter        queryFilter2 = base.CreateWildcardOrEqualFilter(RemovedMailboxSchema.Name, queryFilter);

            if (queryFilter2 != null)
            {
                list.Add(queryFilter2);
            }
            SmtpAddress smtpAddress = new SmtpAddress(queryFilter);

            if (smtpAddress.IsValidAddress)
            {
                QueryFilter item = new ComparisonFilter(ComparisonOperator.Equal, RemovedMailboxSchema.EmailAddresses, "SMTP:" + smtpAddress);
                list.Add(item);
            }
            QueryFilter queryFilter3 = base.CreateWildcardOrEqualFilter(RemovedMailboxSchema.WindowsLiveID, queryFilter);

            if (queryFilter3 != null)
            {
                list.Add(queryFilter3);
            }
            QueryFilter queryFilter4 = base.CreateWildcardOrEqualFilter(RemovedMailboxSchema.SamAccountName, queryFilter);

            if (queryFilter4 != null)
            {
                list.Add(queryFilter4);
            }
            QueryFilter filter = QueryFilter.AndTogether(new QueryFilter[]
            {
                basicFilter,
                QueryFilter.OrTogether(list.ToArray())
            });
            IEnumerable <T> enumerable = base.PerformPrimarySearch <T>(filter, null, session, false, optionalData);

            return(EnumerableWrapper <T> .GetWrapper(enumerable));
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
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: 0x06000AFC RID: 2812 RVA: 0x00023724 File Offset: 0x00021924
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IConfigurationSession))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(session.GetType().Name), "session");
            }
            if (((typeof(T) == typeof(ADOrganizationalUnit) && session.UseConfigNC) || (typeof(T) == typeof(ExchangeConfigurationUnit) && !session.UseConfigNC)) && !Environment.StackTrace.Contains("Microsoft.Exchange.Management.Deployment.OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId"))
            {
                throw new ArgumentException("Session is using the wrong Naming Context for the desired search");
            }
            notFoundReason = null;
            EnumerableWrapper <T> result = EnumerableWrapper <T> .Empty;

            if (base.IsMultitenancyEnabled())
            {
                if (this.IsWildcardDefined(base.RawIdentity))
                {
                    if (null == this.AccountPartition)
                    {
                        notFoundReason = new LocalizedString?(Strings.ErrorOrganizationWildcard);
                        return(result);
                    }
                    IEnumerable <ExchangeConfigurationUnit> configurationUnits = this.GetConfigurationUnits((IConfigurationSession)session, base.RawIdentity);
                    return(EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) configurationUnits, this.GetEnumerableFilter <T>()));
                }
                else
                {
                    OrganizationId organizationId = this.ResolveOrganizationId(session.SessionSettings.CurrentOrganizationId);
                    if (!OrganizationId.ForestWideOrgId.Equals(organizationId))
                    {
                        ADSessionSettings adsessionSettings = ADSessionSettings.FromCustomScopeSet(ScopeSet.ResolveUnderScope(organizationId, session.SessionSettings.ScopeSet), session.SessionSettings.RootOrgId, organizationId, session.SessionSettings.ExecutingUserOrganizationId, true);
                        adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                        bool flag = TaskHelper.ShouldPassDomainControllerToSession(session.DomainController, adsessionSettings);
                        ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(flag ? session.DomainController : null, session.ReadOnly, session.ConsistencyMode, flag ? session.NetworkCredential : null, adsessionSettings, 314, "GetObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\organizationidparameter.cs");
                        tenantConfigurationSession.UseConfigNC      = session.UseConfigNC;
                        tenantConfigurationSession.UseGlobalCatalog = session.UseGlobalCatalog;
                        if (typeof(ExchangeConfigurationUnit) == typeof(T) && organizationId.ConfigurationUnit != null)
                        {
                            List <ExchangeConfigurationUnit> list = new List <ExchangeConfigurationUnit>();
                            ExchangeConfigurationUnit        exchangeConfigurationUnit = tenantConfigurationSession.Read <ExchangeConfigurationUnit>(organizationId.ConfigurationUnit);
                            if (exchangeConfigurationUnit != null)
                            {
                                list.Add(exchangeConfigurationUnit);
                                result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list, this.GetEnumerableFilter <T>());
                            }
                        }
                        else if (organizationId.OrganizationalUnit != null)
                        {
                            List <ADOrganizationalUnit> list2 = new List <ADOrganizationalUnit>();
                            ADOrganizationalUnit        adorganizationalUnit = tenantConfigurationSession.Read <ADOrganizationalUnit>(organizationId.OrganizationalUnit);
                            if (adorganizationalUnit != null)
                            {
                                list2.Add(adorganizationalUnit);
                                result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list2, this.GetEnumerableFilter <T>());
                            }
                        }
                    }
                }
            }
            TaskLogger.LogExit();
            return(result);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
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.º 23
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);
        }