示例#1
0
        public IEnumerable <T> GetObjects <T>(ObjectId rootId, IConfigDataProvider session, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IDirectorySession))
            {
                throw new ArgumentException("Session should be an IDirectorySession", "session");
            }
            if (rootId != null && !(rootId is ADObjectId))
            {
                throw new ArgumentException("RootId must be an ADObjectId", "rootId");
            }
            IDirectorySession directorySession  = (IDirectorySession)session;
            IDirectorySession directorySession2 = null;

            if (!(this is OrganizationIdParameter) && VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && rootId == null && ADSessionSettings.GetProcessServerSettings() == null && directorySession is IConfigurationSession)
            {
                IConfigurationSession configurationSession   = directorySession as IConfigurationSession;
                ADObjectId            configurationUnitsRoot = directorySession.GetConfigurationUnitsRoot();
                bool flag = !string.IsNullOrEmpty(this.rawIdentity) && this.rawIdentity.IndexOf("\\") != -1;
                if (this.InternalADObjectId != null)
                {
                    flag = !string.IsNullOrEmpty(this.InternalADObjectId.DistinguishedName);
                }
                if (!flag && configurationSession.UseConfigNC && !configurationUnitsRoot.IsDescendantOf(directorySession.GetConfigurationNamingContext()) && typeof(ADConfigurationObject).IsAssignableFrom(typeof(T)) && !typeof(ADNonExchangeObject).IsAssignableFrom(typeof(T)))
                {
                    T                    t        = (default(T) == null) ? Activator.CreateInstance <T>() : default(T);
                    ADObject             adobject = t as ADObject;
                    ObjectScopeAttribute objectScopeAttribute;
                    bool                 flag2 = adobject.IsApplicableToTenant(out objectScopeAttribute);
                    if (directorySession.SessionSettings.ExecutingUserOrganizationId.Equals(OrganizationId.ForestWideOrgId) && directorySession.SessionSettings.CurrentOrganizationId.Equals(directorySession.SessionSettings.ExecutingUserOrganizationId) && flag2)
                    {
                        directorySession2 = directorySession;
                    }
                }
            }
            if (directorySession2 == null)
            {
                directorySession2 = ADSession.RescopeSessionToTenantSubTree(directorySession);
            }
            return(this.GetObjects <T>((ADObjectId)rootId, directorySession, directorySession2, optionalData, out notFoundReason));
        }