コード例 #1
0
 protected void SetCurrentOrganizationWithScopeSet(OrganizationId orgId)
 {
     if (orgId != null && !orgId.Equals(OrganizationId.ForestWideOrgId))
     {
         base.CurrentTaskContext.ScopeSet = ScopeSet.ResolveUnderScope(orgId, base.CurrentTaskContext.ScopeSet);
     }
     base.CurrentOrganizationId = orgId;
 }
コード例 #2
0
        internal static void VerifyIsInScopes(ADObject adObject, ScopeSet scopeSet, Task.TaskErrorLoggingDelegate writeErrorDelegate)
        {
            ADScopeException ex;

            if (!ADSession.TryVerifyIsWithinScopes(adObject, scopeSet.RecipientReadScope, scopeSet.RecipientWriteScopes, scopeSet.ExclusiveRecipientScopes, false, out ex))
            {
                writeErrorDelegate(new TaskException(Strings.ErrorCannotChangeObjectOutOfWriteScope(adObject.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.PermissionDenied, null);
            }
        }
        // Token: 0x060013A5 RID: 5029 RVA: 0x000456C8 File Offset: 0x000438C8
        private void CheckCmdlet(string cmdletName, string[] parameters)
        {
            ScopeSet scopeSet = new ScopeSet(new ADScope(null, null), new ADScopeCollection[0], null, null);

            if (!this.IsCmdletAllowedInScope("Microsoft.Exchange.Management.PowerShell.E2010\\" + cmdletName, parameters, scopeSet))
            {
                throw new CommandNotFoundException(Strings.CommandNotFoundError(cmdletName));
            }
        }
コード例 #4
0
 public bool IsCmdletAllowedInScope(string cmdletName, string[] paramNames)
 {
     if (this.erc != null)
     {
         ScopeSet scopeSet = new ScopeSet(new ADScope(null, null), new ADScopeCollection[0], null, null);
         return(this.erc.IsCmdletAllowedInScope("Microsoft.Exchange.Management.PowerShell.E2010\\" + cmdletName.Trim(), EMCRunspaceConfigurationSingleton.TrimArray(paramNames), scopeSet));
     }
     return(true);
 }
コード例 #5
0
        internal override ADSessionSettings FromExternalDirectoryOrganizationId(Guid externalDirectoryOrganizationId)
        {
            ADObjectId    adobjectId    = new ADObjectId(DalHelper.GetTenantDistinguishedName(externalDirectoryOrganizationId.ToString()), externalDirectoryOrganizationId);
            ADPropertyBag adpropertyBag = new ADPropertyBag();

            adpropertyBag[ADObjectSchema.ConfigurationUnit]      = adobjectId;
            adpropertyBag[ADObjectSchema.OrganizationalUnitRoot] = adobjectId;
            OrganizationId organizationId = (OrganizationId)ADObject.OrganizationIdGetter(adpropertyBag);

            return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ScopeSet.GetOrgWideDefaultScopeSet(organizationId), adobjectId, organizationId, null, ConfigScopes.TenantLocal, PartitionId.LocalForest));
        }
コード例 #6
0
 internal static void VerifyIsInScopes(ADObject adObject, ScopeSet scopeSet, Task.TaskErrorLoggingDelegate writeErrorDelegate)
 {
     try
     {
         ADSession.VerifyIsWithinScopes(adObject, scopeSet.RecipientReadScope, scopeSet.RecipientWriteScopes, scopeSet.ExclusiveRecipientScopes, false);
     }
     catch (ADScopeException)
     {
         writeErrorDelegate(new MailboxSearchScopeException(adObject.Id.ToString()), ErrorCategory.PermissionDenied, null);
     }
 }
コード例 #7
0
 internal bool AllPresentScopesMatch(ScopeSet rbacScopeSet)
 {
     if (rbacScopeSet.RecipientReadScope is RbacScope)
     {
         RbacScope rbacScope = rbacScopeSet.RecipientReadScope as RbacScope;
         if (!rbacScope.IsScopeTypeSmallerOrEqualThan(this.RecipientReadScope))
         {
             return(false);
         }
     }
     else if (!rbacScopeSet.RecipientReadScope.IsEmpty)
     {
         throw new ArgumentException("rbacScopeSet");
     }
     if (rbacScopeSet.ConfigReadScope is RbacScope)
     {
         RbacScope rbacScope2 = rbacScopeSet.ConfigReadScope as RbacScope;
         if (!rbacScope2.IsScopeTypeSmallerOrEqualThan(this.ConfigReadScope))
         {
             return(false);
         }
     }
     else if (!rbacScopeSet.ConfigReadScope.IsEmpty)
     {
         throw new ArgumentException("rbacScopeSet");
     }
     if (rbacScopeSet.RecipientWriteScopes != null && rbacScopeSet.RecipientWriteScopes.Count != 0 && rbacScopeSet.RecipientWriteScopes[0].Count != 0)
     {
         bool flag = false;
         foreach (ADScope adscope in rbacScopeSet.RecipientWriteScopes[0])
         {
             RbacScope rbacScope3 = adscope as RbacScope;
             if (rbacScope3 == null)
             {
                 throw new ArgumentException("rbacScopeSet");
             }
             ScopeType recipientWriteScope = (ScopeType)this.RecipientWriteScope;
             if (rbacScope3.IsScopeTypeSmallerOrEqualThan(recipientWriteScope))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #8
0
        internal override ADSessionSettings FromTenantCUName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            GlobalConfigSession globalConfigSession = new GlobalConfigSession();
            FfoTenant           tenantByName        = globalConfigSession.GetTenantByName(name);

            if (tenantByName == null)
            {
                throw new CannotResolveTenantNameException(DirectoryStrings.CannotResolveTenantName(name));
            }
            ExchangeConfigurationUnit exchangeConfigurationUnit = FfoConfigurationSession.GetExchangeConfigurationUnit(tenantByName);

            return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ScopeSet.GetOrgWideDefaultScopeSet(OrganizationId.ForestWideOrgId), null, exchangeConfigurationUnit.OrganizationId, null, ConfigScopes.TenantLocal, PartitionId.LocalForest));
        }
コード例 #9
0
 private void SetScopeSet(object sender, EventArgs e)
 {
     if (this.CurrentTaskContext.CanBypassRBACScope)
     {
         if (this.CurrentTaskContext.UserInfo != null)
         {
             if (this.CurrentTaskContext.UserInfo.CurrentOrganizationId != null)
             {
                 this.CurrentTaskContext.ScopeSet = ScopeSet.GetOrgWideDefaultScopeSet(this.CurrentTaskContext.UserInfo.CurrentOrganizationId);
             }
             else
             {
                 this.CurrentTaskContext.ScopeSet = ScopeSet.GetOrgWideDefaultScopeSet(this.CurrentTaskContext.UserInfo.ExecutingUserOrganizationId);
             }
         }
         if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn && !TaskLogger.IsSetupLogging)
         {
             this.CurrentTaskContext.CommandShell.WriteVerbose(TaskVerboseStringHelper.GetScopeSetVerboseString(this.CurrentTaskContext.ScopeSet));
         }
     }
 }
コード例 #10
0
        protected override IConfigurable PrepareDataObject()
        {
            MailboxDiscoverySearch mailboxDiscoverySearch = (MailboxDiscoverySearch)base.PrepareDataObject();

            string[] paramNames = new string[]
            {
                "AllSourceMailboxes",
                "AllPublicFolderSources",
                "PublicFolderSources"
            };
            ScopeSet scopeSet = base.ScopeSet;
            bool     flag     = false;

            if (scopeSet == null)
            {
                scopeSet = ScopeSet.GetOrgWideDefaultScopeSet(base.CurrentOrganizationId);
            }
            if (scopeSet != null)
            {
                ADRawEntry executingUser = base.ExchangeRunspaceConfig.ExecutingUser;
                if (executingUser != null)
                {
                    flag = base.ExchangeRunspaceConfig.IsCmdletAllowedInScope("Set-MailboxSearch", paramNames, executingUser, ScopeLocation.RecipientWrite);
                }
                else
                {
                    flag = base.ExchangeRunspaceConfig.IsCmdletAllowedInScope("Set-MailboxSearch", paramNames, scopeSet);
                }
            }
            if (flag && mailboxDiscoverySearch.Version == SearchObjectVersion.Original && (mailboxDiscoverySearch.Sources == null || mailboxDiscoverySearch.Sources.Count == 0) && (mailboxDiscoverySearch.PublicFolderSources == null || mailboxDiscoverySearch.PublicFolderSources.Count == 0) && !mailboxDiscoverySearch.AllSourceMailboxes && !mailboxDiscoverySearch.AllPublicFolderSources)
            {
                this.AllSourceMailboxes = true;
            }
            if (flag)
            {
                mailboxDiscoverySearch.Version = SearchObjectVersion.SecondVersion;
            }
            if (base.Fields.IsModified(SearchObjectSchema.TargetMailbox.Name))
            {
                if (this.TargetMailbox != null)
                {
                    try
                    {
                        this.recipientSession.SessionSettings.IncludeInactiveMailbox = false;
                        ADUser aduser = (ADUser)base.GetDataObject <ADUser>(this.TargetMailbox, this.recipientSession, null, new LocalizedString?(Strings.ExceptionUserObjectNotFound(this.TargetMailbox.ToString())), new LocalizedString?(Strings.ExceptionUserObjectAmbiguous));
                        if (aduser.RecipientType != RecipientType.UserMailbox)
                        {
                            base.ThrowTerminatingError(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientType(aduser.ToString(), aduser.RecipientType.ToString())), ErrorCategory.InvalidArgument, SearchObjectSchema.TargetMailbox.Name);
                        }
                        mailboxDiscoverySearch.Target = aduser.LegacyExchangeDN;
                        if (base.ScopeSet != null)
                        {
                            Utils.VerifyIsInScopes(aduser, base.ScopeSet, new Task.TaskErrorLoggingDelegate(base.WriteError));
                        }
                        Utils.VerifyMailboxVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError));
                        goto IL_20B;
                    }
                    finally
                    {
                        if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
                        {
                            this.recipientSession.SessionSettings.IncludeInactiveMailbox = true;
                        }
                    }
                }
                mailboxDiscoverySearch.Target = null;
            }
IL_20B:
            if (flag)
            {
                if (base.Fields.IsModified(MailboxDiscoverySearchSchema.AllSourceMailboxes.Name))
                {
                    mailboxDiscoverySearch.AllSourceMailboxes = this.AllSourceMailboxes;
                }
                if (this.AllSourceMailboxes)
                {
                    if (this.SourceMailboxes != null || mailboxDiscoverySearch.Sources != null)
                    {
                        this.WriteWarning(Strings.AllSourceMailboxesParameterOverride("AllSourceMailboxes", "SourceMailboxes"));
                    }
                    this.SourceMailboxes           = null;
                    mailboxDiscoverySearch.Sources = null;
                }
            }
            bool flag2 = base.Fields.IsModified(SearchObjectSchema.SourceMailboxes.Name);

            if (!flag2)
            {
                if (!mailboxDiscoverySearch.IsChanged(MailboxDiscoverySearchSchema.InPlaceHoldEnabled) || !mailboxDiscoverySearch.InPlaceHoldEnabled)
                {
                    goto IL_442;
                }
            }
            try
            {
                if (mailboxDiscoverySearch.InPlaceHoldEnabled)
                {
                    this.recipientSession.SessionSettings.IncludeSoftDeletedObjects = true;
                }
                IEnumerable <RecipientIdParameter> enumerable;
                if (!flag2)
                {
                    if (mailboxDiscoverySearch.Sources != null)
                    {
                        enumerable = from legacyDn in mailboxDiscoverySearch.Sources
                                     select new RecipientIdParameter(legacyDn);
                    }
                    else
                    {
                        enumerable = null;
                    }
                }
                else
                {
                    enumerable = this.SourceMailboxes;
                }
                IEnumerable <RecipientIdParameter> recipientIds        = enumerable;
                MultiValuedProperty <string>       multiValuedProperty = Utils.ConvertSourceMailboxesCollection(recipientIds, mailboxDiscoverySearch.InPlaceHoldEnabled, (RecipientIdParameter recipientId) => base.GetDataObject <ADRecipient>(recipientId, this.recipientSession, null, new LocalizedString?(Strings.ExceptionUserObjectNotFound(recipientId.ToString())), new LocalizedString?(Strings.ExceptionUserObjectAmbiguous)) as ADRecipient, this.recipientSession, new Task.TaskErrorLoggingDelegate(base.WriteError), new Action <LocalizedString>(this.WriteWarning), (LocalizedString locString) => this.Force || base.ShouldContinue(locString)) ?? new MultiValuedProperty <string>();
                mailboxDiscoverySearch.Sources.CopyChangesFrom(multiValuedProperty);
                if (mailboxDiscoverySearch.Sources.Count != multiValuedProperty.Count)
                {
                    mailboxDiscoverySearch.Sources = multiValuedProperty;
                }
                if (base.ScopeSet != null)
                {
                    foreach (string legacyExchangeDN in mailboxDiscoverySearch.Sources)
                    {
                        ADRecipient adrecipient = this.recipientSession.FindByLegacyExchangeDN(legacyExchangeDN);
                        if (adrecipient == null)
                        {
                            base.WriteError(new ObjectNotFoundException(Strings.ExceptionSourceMailboxNotFound(mailboxDiscoverySearch.Target, mailboxDiscoverySearch.Name)), ErrorCategory.InvalidOperation, null);
                        }
                        Utils.VerifyIsInHoldScopes(mailboxDiscoverySearch.InPlaceHoldEnabled, base.ExchangeRunspaceConfig, adrecipient, "Set-MailboxSearch", new Task.TaskErrorLoggingDelegate(base.WriteError));
                        Utils.VerifyIsInScopes(adrecipient, base.ScopeSet, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    }
                }
            }
            finally
            {
                this.recipientSession.SessionSettings.IncludeSoftDeletedObjects = false;
            }
IL_442:
            if (flag)
            {
                if (base.Fields.IsModified(MailboxDiscoverySearchSchema.AllPublicFolderSources.Name))
                {
                    mailboxDiscoverySearch.AllPublicFolderSources = this.AllPublicFolderSources;
                }
                if (this.AllPublicFolderSources)
                {
                    if (this.PublicFolderSources != null)
                    {
                        this.WriteWarning(Strings.AllSourceMailboxesParameterOverride("AllPublicFolderSources", "PublicFolderSources"));
                    }
                    this.PublicFolderSources = null;
                }
                if (base.Fields.IsModified(MailboxDiscoverySearchSchema.PublicFolderSources.Name))
                {
                    string[] array = null;
                    if (this.PublicFolderSources != null && this.PublicFolderSources.Length != 0)
                    {
                        array = new string[this.PublicFolderSources.Length];
                        string action = "Get-PublicFolder";
                        try
                        {
                            using (PublicFolderDataProvider publicFolderDataProvider = new PublicFolderDataProvider(this.ConfigurationSession, action, Guid.Empty))
                            {
                                for (int i = 0; i < this.PublicFolderSources.Length; i++)
                                {
                                    PublicFolder publicFolder = null;
                                    array[i] = this.PublicFolderSources[i].ToString();
                                    try
                                    {
                                        publicFolder = (PublicFolder)publicFolderDataProvider.Read <PublicFolder>(this.PublicFolderSources[i].PublicFolderId);
                                    }
                                    catch (FormatException exception)
                                    {
                                        base.WriteError(exception, ErrorCategory.WriteError, null);
                                    }
                                    if (publicFolder == null)
                                    {
                                        base.WriteError(new MailboxSearchTaskException(Strings.PublicFolderSourcesFolderDoesnotExist(array[i])), ErrorCategory.InvalidArgument, null);
                                    }
                                }
                            }
                        }
                        catch (AccessDeniedException exception2)
                        {
                            base.WriteError(exception2, ErrorCategory.PermissionDenied, mailboxDiscoverySearch.Name);
                        }
                    }
                    mailboxDiscoverySearch.PublicFolderSources = Utils.ConvertCollectionToMultiValedProperty <string, string>(array, (string value, object param) => value, null, new MultiValuedProperty <string>(), new Task.TaskErrorLoggingDelegate(base.WriteError), MailboxDiscoverySearchSchema.PublicFolderSources.Name);
                }
            }
            if (base.Fields.IsModified(SearchObjectSchema.Senders.Name))
            {
                MultiValuedProperty <string> senders = Utils.ConvertCollectionToMultiValedProperty <string, string>(this.Senders, (string value, object param) => value, null, new MultiValuedProperty <string>(), new Task.TaskErrorLoggingDelegate(base.WriteError), SearchObjectSchema.Senders.Name);
                mailboxDiscoverySearch.Senders = senders;
            }
            if (base.Fields.IsModified(SearchObjectSchema.Recipients.Name))
            {
                MultiValuedProperty <string> recipients = Utils.ConvertCollectionToMultiValedProperty <string, string>(this.Recipients, (string value, object param) => value, null, new MultiValuedProperty <string>(), new Task.TaskErrorLoggingDelegate(base.WriteError), SearchObjectSchema.Recipients.Name);
                mailboxDiscoverySearch.Recipients = recipients;
            }
            if (base.Fields.IsModified(SearchObjectSchema.StartDate.Name))
            {
                mailboxDiscoverySearch.StartDate = this.StartDate;
            }
            if (base.Fields.IsModified(SearchObjectSchema.EndDate.Name))
            {
                mailboxDiscoverySearch.EndDate = this.EndDate;
            }
            if (base.Fields.IsModified(SearchObjectSchema.MessageTypes.Name))
            {
                MultiValuedProperty <KindKeyword> messageTypes = Utils.ConvertCollectionToMultiValedProperty <KindKeyword, KindKeyword>(this.MessageTypes, (KindKeyword kind, object param) => kind, null, new MultiValuedProperty <KindKeyword>(), new Task.TaskErrorLoggingDelegate(base.WriteError), SearchObjectSchema.MessageTypes.Name);
                mailboxDiscoverySearch.MessageTypes = messageTypes;
            }
            if (base.Fields.IsModified(SearchObjectSchema.StatusMailRecipients.Name))
            {
                MultiValuedProperty <ADObjectId> multiValuedProperty2 = Utils.ConvertCollectionToMultiValedProperty <RecipientIdParameter, ADObjectId>(this.StatusMailRecipients, new Utils.IdentityToRawIdDelegate <RecipientIdParameter, ADObjectId>(this.ADObjectIdFromRecipientIdParameter), null, new MultiValuedProperty <ADObjectId>(), new Task.TaskErrorLoggingDelegate(base.WriteError), SearchObjectSchema.StatusMailRecipients.Name);
                mailboxDiscoverySearch.StatusMailRecipients.CopyChangesFrom(multiValuedProperty2);
                if (mailboxDiscoverySearch.StatusMailRecipients.Count != multiValuedProperty2.Count)
                {
                    mailboxDiscoverySearch.StatusMailRecipients = multiValuedProperty2;
                }
            }
            if (base.Fields.IsModified(SearchObjectSchema.ManagedBy.Name))
            {
                MultiValuedProperty <ADObjectId> multiValuedProperty3 = Utils.ConvertCollectionToMultiValedProperty <RecipientIdParameter, ADObjectId>(this.ManagedBy, new Utils.IdentityToRawIdDelegate <RecipientIdParameter, ADObjectId>(this.ADObjectIdFromRecipientIdParameter), null, new MultiValuedProperty <ADObjectId>(), new Task.TaskErrorLoggingDelegate(base.WriteError), SearchObjectSchema.ManagedBy.Name);
                mailboxDiscoverySearch.ManagedBy.CopyChangesFrom(multiValuedProperty3);
                if (mailboxDiscoverySearch.ManagedBy.Count != multiValuedProperty3.Count)
                {
                    mailboxDiscoverySearch.ManagedBy = multiValuedProperty3;
                }
            }
            if (base.Fields.IsModified("SearchQuery"))
            {
                mailboxDiscoverySearch.Query = this.SearchQuery;
            }
            if (base.Fields.IsModified(SearchObjectSchema.EstimateOnly.Name))
            {
                mailboxDiscoverySearch.StatisticsOnly = this.EstimateOnly;
                if (this.EstimateOnly)
                {
                    mailboxDiscoverySearch.LogLevel = LoggingLevel.Suppress;
                }
                else
                {
                    mailboxDiscoverySearch.IncludeKeywordStatistics = false;
                }
            }
            if (base.Fields.IsModified(SearchObjectSchema.IncludeKeywordStatistics.Name))
            {
                mailboxDiscoverySearch.IncludeKeywordStatistics = this.IncludeKeywordStatistics.ToBool();
            }
            if (base.Fields.IsModified(MailboxDiscoverySearchSchema.StatisticsStartIndex.Name))
            {
                mailboxDiscoverySearch.StatisticsStartIndex = this.StatisticsStartIndex;
            }
            if (flag && (mailboxDiscoverySearch.Sources == null || mailboxDiscoverySearch.Sources.Count == 0) && (mailboxDiscoverySearch.PublicFolderSources == null || mailboxDiscoverySearch.PublicFolderSources.Count == 0) && !mailboxDiscoverySearch.AllSourceMailboxes && !mailboxDiscoverySearch.AllPublicFolderSources)
            {
                base.WriteError(new MailboxSearchTaskException(Strings.NoSourceMailboxesAndNoPublicFolderSourcesSet), ErrorCategory.InvalidArgument, null);
            }
            bool flag3 = mailboxDiscoverySearch.InPlaceHoldEnabled && (mailboxDiscoverySearch.Sources == null || mailboxDiscoverySearch.Sources.Count == 0);
            bool flag4 = false;

            if (flag)
            {
                flag3 = (mailboxDiscoverySearch.InPlaceHoldEnabled && mailboxDiscoverySearch.AllSourceMailboxes);
                flag4 = (mailboxDiscoverySearch.InPlaceHoldEnabled && (mailboxDiscoverySearch.AllPublicFolderSources || (mailboxDiscoverySearch.PublicFolderSources != null && mailboxDiscoverySearch.PublicFolderSources.Count != 0)));
            }
            if (flag3)
            {
                base.WriteError(new MailboxSearchTaskException(Strings.InPlaceHoldNotAllowedForAllSourceMailboxes), ErrorCategory.InvalidArgument, null);
            }
            if (flag4)
            {
                base.WriteError(new MailboxSearchTaskException(Strings.InPlaceHoldNotAllowedForPublicFolders), ErrorCategory.InvalidArgument, null);
            }
            return(mailboxDiscoverySearch);
        }
        // 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);
        }
コード例 #12
0
 public static LocalizedString GetScopeSetVerboseString(ScopeSet scopeSet)
 {
     return(new LocalizedString(Strings.VerbosePopulateScopeSet + "{ " + scopeSet.ToLocalizedString() + " }"));
 }
コード例 #13
0
 internal override ADSessionSettings FromAllTenantsPartitionId(PartitionId partitionId)
 {
     return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ScopeSet.GetOrgWideDefaultScopeSet(OrganizationId.ForestWideOrgId), null, OrganizationId.ForestWideOrgId, null, ConfigScopes.AllTenants, PartitionId.LocalForest));
 }
コード例 #14
0
        // Token: 0x0600120B RID: 4619 RVA: 0x000384FC File Offset: 0x000366FC
        private static MailboxDatabaseWithLocationInfo VerifyStatusAndSelectDB(List <MailboxDatabaseWithLocationInfo> databases, string domainController, LogMessageDelegate logger, ScopeSet scopeSet)
        {
            Guid[]      array  = new Guid[1];
            MdbStatus[] array2 = new MdbStatus[1];
            Dictionary <string, ExRpcAdmin> dictionary  = new Dictionary <string, ExRpcAdmin>(100);
            Dictionary <string, string>     dictionary2 = new Dictionary <string, string>(100);
            ITopologyConfigurationSession   topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            IConfigurationSession           configurationSession         = null;

            if (scopeSet != null && !PhysicalResourceLoadBalancing.IsDatacenter)
            {
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromCustomScopeSet(scopeSet, topologyConfigurationSession.SessionSettings.RootOrgId, topologyConfigurationSession.SessionSettings.CurrentOrganizationId, topologyConfigurationSession.SessionSettings.ExecutingUserOrganizationId, true), 801, "VerifyStatusAndSelectDB", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\Provisioning\\LoadBalancing\\PhysicalResourceLoadBalancing.cs");
            }
            try
            {
                Random random = new Random();
                for (int i = databases.Count - 1; i >= 0; i--)
                {
                    if (i != 0)
                    {
                        int index = random.Next(i + 1);
                        MailboxDatabaseWithLocationInfo value = databases[index];
                        databases[index] = databases[i];
                        databases[i]     = value;
                    }
                    MailboxDatabase mailboxDatabase = databases[i].MailboxDatabase;
                    string          text            = string.Empty;
                    try
                    {
                        if (configurationSession != null)
                        {
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbCheckingDatabaseIsAllowedOnScope(mailboxDatabase.Id.ToDNString()), logger);
                            ADScopeException ex;
                            if (!configurationSession.TryVerifyIsWithinScopes(mailboxDatabase, false, out ex))
                            {
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseNotInUserScope(mailboxDatabase.Id.ToDNString(), ex.ToString()), logger);
                                goto IL_2C6;
                            }
                        }
                        DatabaseLocationInfo databaseLocationInfo = databases[i].DatabaseLocationInfo;
                        text = databaseLocationInfo.ServerFqdn;
                        ADObjectId serverSite = databaseLocationInfo.ServerSite;
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseAndServerTry(mailboxDatabase.Id.ToDNString(), text ?? "null"), logger);
                        if (!string.IsNullOrEmpty(text) && !dictionary2.ContainsKey(text))
                        {
                            ExRpcAdmin exRpcAdmin;
                            if (dictionary.ContainsKey(text))
                            {
                                exRpcAdmin = dictionary[text];
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbExRpcAdminExists, logger);
                            }
                            else
                            {
                                exRpcAdmin = ExRpcAdmin.Create("Client=Management", text, null, null, null);
                                dictionary.Add(text, exRpcAdmin);
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbCreateNewExRpcAdmin, logger);
                            }
                            array[0] = mailboxDatabase.Id.ObjectGuid;
                            array2   = exRpcAdmin.ListMdbStatus(array);
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbTryRetrieveDatabaseStatus, logger);
                            if ((array2[0].Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline)
                            {
                                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseFound, logger);
                                return(new MailboxDatabaseWithLocationInfo(mailboxDatabase, databaseLocationInfo));
                            }
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseIsNotOnline((int)array2[0].Status), logger);
                        }
                        else
                        {
                            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbServerDownSoMarkDatabaseDown, logger);
                        }
                    }
                    catch (DatabaseNotFoundException ex2)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseNotFoundException(ex2.Message), logger);
                    }
                    catch (ObjectNotFoundException ex3)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoServerForDatabaseException(ex3.Message), logger);
                    }
                    catch (MapiExceptionNetworkError mapiExceptionNetworkError)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNetworkError(mapiExceptionNetworkError.Message), logger);
                        dictionary2.Add(text, text);
                    }
                    catch (MapiPermanentException ex4)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbPermanentException(ex4.Message), logger);
                        dictionary2.Add(text, text);
                    }
                    catch (MapiRetryableException ex5)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRetryableException(ex5.Message), logger);
                    }
                    IL_2C6 :;
                }
            }
            finally
            {
                foreach (string text2 in dictionary.Keys)
                {
                    PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDisposeExRpcAdmin(text2), logger);
                    dictionary[text2].Dispose();
                }
            }
            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger);
            return(null);
        }
コード例 #15
0
        // Token: 0x06001208 RID: 4616 RVA: 0x00037FB4 File Offset: 0x000361B4
        internal static MailboxDatabaseWithLocationInfo FindDatabaseAndLocationForEnterpriseSiteMailbox(string domainController, LogMessageDelegate logger, ScopeSet scopeSet)
        {
            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbEnterSiteMailboxEnterprise, logger);
            ITopologyConfigurationSession configSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            List <MailboxDatabase>        databasesForProvisioningCached = PhysicalResourceLoadBalancing.GetDatabasesForProvisioningCached(configSession, false, logger);

            if (databasesForProvisioningCached.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger);
                return(null);
            }
            List <MailboxDatabase> list = new List <MailboxDatabase>();

            foreach (MailboxDatabase mailboxDatabase in databasesForProvisioningCached)
            {
                if (mailboxDatabase.AdminDisplayVersion == null)
                {
                    mailboxDatabase.AdminDisplayVersion = Server.GetServerVersion(mailboxDatabase.ServerName);
                }
                if (mailboxDatabase.AdminDisplayVersion.Major >= PhysicalResourceLoadBalancing.MajorVersionE15)
                {
                    list.Add(mailboxDatabase);
                }
            }
            if (list.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableE15Database(databasesForProvisioningCached.Count), logger);
                return(null);
            }
            ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance();
            Random        random = new Random();

            while (list.Count != 0)
            {
                int             index            = random.Next(list.Count);
                MailboxDatabase mailboxDatabase2 = list[index];
                list.RemoveAt(index);
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGetServerForActiveDatabaseCopy(mailboxDatabase2.Name), logger);
                DatabaseLocationInfo serverForActiveDatabaseCopy = PhysicalResourceLoadBalancing.GetServerForActiveDatabaseCopy(mailboxDatabase2, cachingActiveManagerInstance, logger);
                if (serverForActiveDatabaseCopy != null)
                {
                    MailboxDatabaseWithLocationInfo mailboxDatabaseWithLocationInfo = new MailboxDatabaseWithLocationInfo(mailboxDatabase2, serverForActiveDatabaseCopy);
                    if (mailboxDatabase2.MasterType == MasterType.DatabaseAvailabilityGroup)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRemoteSiteDatabaseReturned(mailboxDatabaseWithLocationInfo.MailboxDatabase.Name, mailboxDatabaseWithLocationInfo.DatabaseLocationInfo.ServerFqdn), logger);
                        return(mailboxDatabaseWithLocationInfo);
                    }
                    mailboxDatabaseWithLocationInfo = PhysicalResourceLoadBalancing.VerifyStatusAndSelectDB(new List <MailboxDatabaseWithLocationInfo>
                    {
                        mailboxDatabaseWithLocationInfo
                    }, domainController, logger, scopeSet);
                    if (mailboxDatabaseWithLocationInfo != null)
                    {
                        return(mailboxDatabaseWithLocationInfo);
                    }
                }
            }
            return(null);
        }
コード例 #16
0
        private void DrawDependencyReport()
        {
            ScopeSet      scopes = new ScopeSet();
            List <string> unscopedDependencies = new List <string>();

            foreach (MethodInfo method in target.GetType().GetMethods(BindingFlags.Public |
                                                                      BindingFlags.NonPublic |
                                                                      BindingFlags.Instance))
            {
                if (method.Name.ToLower().StartsWith("inject") && method.Name != "InjectDependencies")
                {
                    foreach (ParameterInfo parameter in method.GetParameters())
                    {
                        Scope scope = GetScopeName(parameter);

                        if (scope != null)
                        {
                            bool isResolved;
                            try
                            {
                                isResolved = scope.GetDependencies(script, parameter.ParameterType).Count > 0;
                            }
                            catch (Exception)
                            {
                                isResolved = false;
                            }
                            scopes[scope.GetType().Name].Add(parameter.ParameterType.Name, isResolved);
                        }
                        else
                        {
                            unscopedDependencies.Add(parameter.ParameterType.Name);
                        }
                    }
                }
            }

            if (unscopedDependencies.Count > 0)
            {
                string unscopedDependenciesText = "Unscoped Dependencies : \n";
                foreach (string dependency in unscopedDependencies)
                {
                    unscopedDependenciesText += "\n ● " + dependency;
                }
                DrawErrorBox(unscopedDependenciesText);
            }

            if (!scopes.IsEmpty())
            {
                BeginTable();
                foreach (DependencySet scope in scopes)
                {
                    BeginTableRow();
                    DrawTableHeader(scope.Name);
                    foreach (Dependency dependency in scope)
                    {
                        if (dependency.IsResolved)
                        {
                            DrawTableCell("✓" + dependency.Name, new Color(0.05f, 0.5F, 0.05f));
                        }
                        else
                        {
                            DrawTableCell("✗" + dependency.Name, Color.red);
                        }
                    }
                    EndTableRow();
                }
                EndTable();
            }
        }
コード例 #17
0
 // Token: 0x06001205 RID: 4613 RVA: 0x00037DA0 File Offset: 0x00035FA0
 internal static MailboxDatabaseWithLocationInfo FindDatabaseAndLocation(string domainController, LogMessageDelegate logger, ScopeSet scopeSet, bool isInitialProvisioning, bool localSiteDatabasesOnly, IMailboxProvisioningConstraint mailboxProvisioningConstraint, ref LoadBalancingReport loadBalancingReport)
 {
     return(PhysicalResourceLoadBalancing.FindDatabaseAndLocation(domainController, logger, scopeSet, isInitialProvisioning, localSiteDatabasesOnly, null, mailboxProvisioningConstraint, null, ref loadBalancingReport));
 }
コード例 #18
0
        public static MailboxDatabase ChooseTargetMDB(IEnumerable <ADObjectId> excludedDatabaseIds, bool checkInitialProvisioningSetting, ADUser adUser, Fqdn domainController, ScopeSet scopeSet, Action <LocalizedString> writeVerbose, Action <LocalizedException, ExchangeErrorCategory, object> writeExchangeError, Action <Exception, ErrorCategory, object> writeError, object identity)
        {
            MailboxProvisioningConstraint   mailboxProvisioningConstraint   = (adUser == null) ? new MailboxProvisioningConstraint() : adUser.MailboxProvisioningConstraint;
            LoadBalancingReport             loadBalancingReport             = new LoadBalancingReport();
            MailboxDatabaseWithLocationInfo mailboxDatabaseWithLocationInfo = PhysicalResourceLoadBalancing.FindDatabaseAndLocation(domainController, delegate(string msg)
            {
                writeVerbose(new LocalizedString(msg));
            }, scopeSet, checkInitialProvisioningSetting, false, new int?(Server.E15MinVersion), mailboxProvisioningConstraint, excludedDatabaseIds, ref loadBalancingReport);

            if (mailboxDatabaseWithLocationInfo == null)
            {
                ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_LoadBalancingFailedToFindDatabase, new string[]
                {
                    domainController,
                    loadBalancingReport.ToString()
                });
                writeExchangeError(new RecipientTaskException(Strings.ErrorAutomaticProvisioningFailedToFindDatabase("TargetDatabase")), ExchangeErrorCategory.ServerOperation, null);
            }
            return(mailboxDatabaseWithLocationInfo.MailboxDatabase);
        }
コード例 #19
0
 /// <inheritdoc/>
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     return(ScopeSet.ConvertToScopeArray(value as string));
 }
コード例 #20
0
 internal override ADSessionSettings FromAllTenantsOrRootOrgAutoDetect(OrganizationId orgId)
 {
     if (!OrganizationId.ForestWideOrgId.Equals(orgId))
     {
         return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ScopeSet.GetOrgWideDefaultScopeSet(OrganizationId.ForestWideOrgId), null, orgId, null, ConfigScopes.AllTenants, PartitionId.LocalForest));
     }
     return(ADSessionSettings.FromRootOrgScopeSet());
 }
コード例 #21
0
 // Token: 0x060011F1 RID: 4593 RVA: 0x00037864 File Offset: 0x00035A64
 internal UserScope(string userId, OrganizationId executingUserOrganizationId, OrganizationId currentOrganizationId, UserScopeFlags flags, ScopeSet currentScopeSet)
 {
     this.userId = userId;
     this.executingUserOrganizationId = executingUserOrganizationId;
     this.currentOrganizationId       = currentOrganizationId;
     this.CurrentScopeSet             = currentScopeSet;
     this.flags = flags;
 }
コード例 #22
0
        internal static IConfigDataProvider CreateConfigSession(OrganizationId currentOrganizationId, OrganizationId executingUserOrganizationId)
        {
            ADSessionSettings sessionSettings = ADSessionSettings.FromCustomScopeSet(ScopeSet.GetOrgWideDefaultScopeSet(currentOrganizationId), ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), currentOrganizationId, executingUserOrganizationId, true);

            return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, false, ConsistencyMode.PartiallyConsistent, sessionSettings, 102, "CreateConfigSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\FfoReporting\\Common\\ADHelper.cs"));
        }
コード例 #23
0
        // Token: 0x06001206 RID: 4614 RVA: 0x00037DC8 File Offset: 0x00035FC8
        internal static MailboxDatabaseWithLocationInfo FindDatabaseAndLocation(string domainController, LogMessageDelegate logger, ScopeSet scopeSet, bool isInitialProvisioning, bool localSiteDatabasesOnly, int?qualifiedMinServerVersion, IMailboxProvisioningConstraint mailboxProvisioningConstraint, IEnumerable <ADObjectId> excludedDatabaseIds, ref LoadBalancingReport loadBalancingReport)
        {
            ITopologyConfigurationSession configSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            List <MailboxDatabase>        databasesForProvisioningCached = PhysicalResourceLoadBalancing.GetDatabasesForProvisioningCached(configSession, localSiteDatabasesOnly, logger);
            List <MailboxDatabase>        list;

            if (mailboxProvisioningConstraint != null || excludedDatabaseIds != null)
            {
                list = PhysicalResourceLoadBalancing.FilterEligibleDatabase(logger, databasesForProvisioningCached.GetRange(0, databasesForProvisioningCached.Count), mailboxProvisioningConstraint, excludedDatabaseIds);
            }
            else
            {
                list = databasesForProvisioningCached.GetRange(0, databasesForProvisioningCached.Count);
            }
            if (list.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger);
                return(null);
            }
            LoadBalancingReport loadBalancingReport2 = loadBalancingReport ?? new LoadBalancingReport();

            loadBalancingReport2.enabledDatabasesWithLocalCopyCount = list.Count;
            ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance();

            if (PhysicalResourceLoadBalancing.IsDatacenter)
            {
                return(PhysicalResourceLoadBalancing.FindDatabaseAndLocation(list, cachingActiveManagerInstance, isInitialProvisioning, localSiteDatabasesOnly, logger, ref loadBalancingReport2));
            }
            List <MailboxDatabaseWithLocationInfo> list2 = new List <MailboxDatabaseWithLocationInfo>(list.Count);

            foreach (MailboxDatabase mailboxDatabase in list)
            {
                DatabaseLocationInfo serverForActiveDatabaseCopy = PhysicalResourceLoadBalancing.GetServerForActiveDatabaseCopy(mailboxDatabase, cachingActiveManagerInstance, logger);
                if (serverForActiveDatabaseCopy != null && PhysicalResourceLoadBalancing.IsDatabaseInLocalSite(serverForActiveDatabaseCopy, logger) && (qualifiedMinServerVersion == null || serverForActiveDatabaseCopy.ServerVersion >= qualifiedMinServerVersion.Value))
                {
                    list2.Add(new MailboxDatabaseWithLocationInfo(mailboxDatabase, serverForActiveDatabaseCopy));
                }
            }
            return(PhysicalResourceLoadBalancing.VerifyStatusAndSelectDB(list2, domainController, logger, scopeSet));
        }
コード例 #24
0
        // 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);
        }
コード例 #25
0
        protected override void OnDraw()
        {
            DrawDefaultInspector();
            //In play mode, inspector is refreshed every frame. To prevent performance drop, only do this
            //while not in play mode.
            if (!EditorApplication.isPlaying)
            {
                ScopeSet      scopes = new ScopeSet();
                List <string> unscopedDependencies = new List <string>();

                foreach (MethodInfo method in target.GetType().GetMethods(BindingFlags.Public |
                                                                          BindingFlags.NonPublic |
                                                                          BindingFlags.Instance))
                {
                    if (method.Name.ToLower().StartsWith("inject") && method.Name != "InjectDependencies")
                    {
                        foreach (ParameterInfo parameter in method.GetParameters())
                        {
                            Scope scope = GetScopeName(parameter);

                            if (scope != null)
                            {
                                bool isResolved;
                                try
                                {
                                    isResolved = scope.GetDependencies(gameScript, parameter.ParameterType).Count > 0;
                                }
                                catch (Exception)
                                {
                                    isResolved = false;
                                }
                                scopes[scope.GetType().Name].Add(parameter.ParameterType.Name, isResolved);
                            }
                            else
                            {
                                unscopedDependencies.Add(parameter.ParameterType.Name);
                            }
                        }
                    }
                }

                if (unscopedDependencies.Count > 0)
                {
                    string unscopedDependenciesText = "Unscoped Dependencies : \n";
                    foreach (string dependency in unscopedDependencies)
                    {
                        unscopedDependenciesText += "\n ● " + dependency;
                    }
                    DrawErrorBox(unscopedDependenciesText);
                }

                if (!scopes.IsEmpty())
                {
                    BeginTable("Dependencies");
                    foreach (DependencySet scope in scopes)
                    {
                        BeginTableRow();
                        DrawTableHeader(scope.Name);
                        foreach (Dependency dependency in scope)
                        {
                            if (dependency.IsResolved)
                            {
                                DrawTableCell("✓" + dependency.Name, new Color(0.05f, 0.5F, 0.05f));
                            }
                            else
                            {
                                DrawTableCell("✗" + dependency.Name, Color.red);
                            }
                        }
                        EndTableRow();
                    }
                    EndTable();
                }
            }
        }