Example #1
0
        internal static void InitExchangePropertyContainer(InitialSessionState initialSessionState, ExchangeRunspaceConfiguration configuration)
        {
            ExchangePropertyContainer exchangePropertyContainer = new ExchangePropertyContainer();

            exchangePropertyContainer.logEntries = new CmdletLogEntries();
            exchangePropertyContainer.exchangeRunspaceConfiguration = configuration;
            exchangePropertyContainer.budget = ExchangePropertyContainer.AcquirePowerShellBudget(configuration);
            SessionStateVariableEntry item = new SessionStateVariableEntry(ExchangePropertyContainer.ExchangePropertyContainerName, exchangePropertyContainer, ExchangePropertyContainer.ExchangePropertyContainerName, ScopedItemOptions.ReadOnly | ScopedItemOptions.Constant | ScopedItemOptions.Private | ScopedItemOptions.AllScope);

            initialSessionState.Variables.Add(item);
        }
Example #2
0
        internal static void InitExchangePropertyContainer(ISessionState sessionState, ExchangeRunspaceConfiguration configuration)
        {
            ExchangePropertyContainer exchangePropertyContainer = new ExchangePropertyContainer();

            exchangePropertyContainer.exchangeRunspaceConfiguration = configuration;
            exchangePropertyContainer.budget = ExchangePropertyContainer.AcquirePowerShellBudget(configuration);
            if (sessionState.Variables.ContainsName(ExchangePropertyContainer.ADServerSettingsVarName))
            {
                exchangePropertyContainer.serverSettings = (sessionState.Variables[ExchangePropertyContainer.ADServerSettingsVarName] as ADServerSettings);
            }
            ExchangePropertyContainer.SetExchangePropertyContainer(sessionState, exchangePropertyContainer);
        }
Example #3
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);
        }
Example #4
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);
        }