Exemple #1
0
        internal static CmdletLogEntries GetCmdletLogEntries(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                return(null);
            }
            return(propertyContainer.logEntries);
        }
Exemple #2
0
        internal static OrganizationId GetExecutingUserOrganizationId(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                return(null);
            }
            return(propertyContainer.executingUserOrganizationId);
        }
Exemple #3
0
        internal static ADServerSettings GetServerSettings(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                throw new ArgumentException("sessionState");
            }
            return(propertyContainer.serverSettings);
        }
Exemple #4
0
        internal static ExchangeRunspaceConfigurationSettings.ExchangeApplication GetPropagatedClientAppId(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                return(ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown);
            }
            return(propertyContainer.propagatedClientAppId);
        }
Exemple #5
0
        internal static IPowerShellBudget GetPowerShellBudget(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                return(null);
            }
            return(propertyContainer.budget);
        }
Exemple #6
0
        internal static ExchangeRunspaceConfiguration GetExchangeRunspaceConfiguration(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                return(null);
            }
            return(propertyContainer.exchangeRunspaceConfiguration);
        }
Exemple #7
0
        internal static void DisableCmdletLog(ISessionState sessionState)
        {
            ADObjectId     adobjectId     = null;
            OrganizationId organizationId = null;

            ExchangePropertyContainer.InitializeExchangePropertyContainerIfNeeded(sessionState, out adobjectId, out organizationId);
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            propertyContainer.logEnabled = false;
            propertyContainer.logEntries.DecreaseIndentation();
        }
Exemple #8
0
        internal static void RefreshProvisioningBroker(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                throw new ArgumentException("sessionState");
            }
            ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = propertyContainer.exchangeRunspaceConfiguration;

            if (exchangeRunspaceConfiguration != null)
            {
                exchangeRunspaceConfiguration.RefreshProvisioningBroker();
            }
            if (propertyContainer.provisioningBroker != null)
            {
                propertyContainer.provisioningBroker = null;
            }
        }
Exemple #9
0
        internal static ProvisioningBroker GetProvisioningBroker(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            if (propertyContainer == null)
            {
                throw new ArgumentException("sessionState");
            }
            ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = propertyContainer.exchangeRunspaceConfiguration;

            if (exchangeRunspaceConfiguration != null)
            {
                return(exchangeRunspaceConfiguration.GetProvisioningBroker());
            }
            if (propertyContainer.provisioningBroker == null)
            {
                propertyContainer.provisioningBroker = new ProvisioningBroker();
            }
            return(propertyContainer.provisioningBroker);
        }
Exemple #10
0
        internal static ExchangeRunspaceConfiguration UpdateExchangeRunspaceConfiguration(ISessionState sessionState)
        {
            WindowsIdentity current = WindowsIdentity.GetCurrent();
            ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = new ExchangeRunspaceConfiguration(current);

            if (!ExchangePropertyContainer.IsContainerInitialized(sessionState))
            {
                ExchangePropertyContainer.InitExchangePropertyContainer(sessionState, exchangeRunspaceConfiguration);
            }
            else
            {
                ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);
                propertyContainer.exchangeRunspaceConfiguration = exchangeRunspaceConfiguration;
                if (propertyContainer.budget != null)
                {
                    propertyContainer.budget.Dispose();
                }
                propertyContainer.budget = ExchangePropertyContainer.AcquirePowerShellBudget(exchangeRunspaceConfiguration);
            }
            return(exchangeRunspaceConfiguration);
        }
Exemple #11
0
        internal static void PropagateExchangePropertyContainer(ISessionState sessionState, RunspaceProxy runspace, bool propagateRBAC, bool propagateBudget, ADServerSettings adServerSettingsOverride, ExchangeRunspaceConfigurationSettings.ExchangeApplication application)
        {
            ExchangePropertyContainer propertyContainer         = ExchangePropertyContainer.GetPropertyContainer(sessionState);
            ExchangePropertyContainer exchangePropertyContainer = new ExchangePropertyContainer();

            if (propertyContainer.exchangeRunspaceConfiguration != null)
            {
                propertyContainer.exchangeRunspaceConfiguration.TryGetExecutingUserId(out exchangePropertyContainer.executingUserId);
                exchangePropertyContainer.executingUserOrganizationId = propertyContainer.exchangeRunspaceConfiguration.OrganizationId;
                if (propagateRBAC)
                {
                    exchangePropertyContainer.exchangeRunspaceConfiguration = propertyContainer.exchangeRunspaceConfiguration;
                }
                exchangePropertyContainer.propagatedClientAppId = application;
                if (propertyContainer.budget != null && propagateBudget)
                {
                    exchangePropertyContainer.budget = ExchangePropertyContainer.AcquirePowerShellBudget(propertyContainer.exchangeRunspaceConfiguration);
                }
            }
            else
            {
                exchangePropertyContainer.executingUserId             = propertyContainer.executingUserId;
                exchangePropertyContainer.executingUserOrganizationId = propertyContainer.executingUserOrganizationId;
            }
            exchangePropertyContainer.logEntries = propertyContainer.logEntries;
            exchangePropertyContainer.logEnabled = propertyContainer.logEnabled;
            if (adServerSettingsOverride == null)
            {
                exchangePropertyContainer.serverSettings = propertyContainer.serverSettings;
            }
            else
            {
                exchangePropertyContainer.serverSettings = adServerSettingsOverride;
            }
            runspace.SetVariable(ExchangePropertyContainer.ExchangePropertyContainerName, exchangePropertyContainer);
        }
Exemple #12
0
        internal static bool IsCmdletLogEnabled(ISessionState sessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState);

            return(propertyContainer != null && propertyContainer.logEnabled);
        }
Exemple #13
0
        internal static ExchangeRunspaceConfiguration GetExchangeRunspaceConfiguration(InitialSessionState initialSessionState)
        {
            ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(initialSessionState);

            return(propertyContainer.exchangeRunspaceConfiguration);
        }