// Token: 0x06000397 RID: 919 RVA: 0x0000D838 File Offset: 0x0000BA38 internal static ADServerSettings GetServerSettings(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); if (propertyContainer == null) { throw new ArgumentException("sessionState"); } return(propertyContainer.serverSettings); }
// Token: 0x06000392 RID: 914 RVA: 0x0000D744 File Offset: 0x0000B944 internal static ExchangeRunspaceConfigurationSettings.ExchangeApplication GetPropagatedClientAppId(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); if (propertyContainer == null) { return(ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown); } return(propertyContainer.propagatedClientAppId); }
// Token: 0x06000398 RID: 920 RVA: 0x0000D860 File Offset: 0x0000BA60 internal static CmdletLogEntries GetCmdletLogEntries(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); if (propertyContainer == null) { return(null); } return(propertyContainer.logEntries); }
// Token: 0x06000391 RID: 913 RVA: 0x0000D724 File Offset: 0x0000B924 internal static IPowerShellBudget GetPowerShellBudget(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); if (propertyContainer == null) { return(null); } return(propertyContainer.budget); }
internal static ADObjectId GetExecutingUserId(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); if (propertyContainer == null) { return(null); } return(propertyContainer.executingUserId); }
// Token: 0x0600038E RID: 910 RVA: 0x0000D6BC File Offset: 0x0000B8BC internal static Uri GetOriginalConnectionUri(ISessionState sessionState) { ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(sessionState); if (exchangeRunspaceConfiguration == null || exchangeRunspaceConfiguration.ConfigurationSettings == null) { return(null); } return(exchangeRunspaceConfiguration.ConfigurationSettings.OriginalConnectionUri); }
internal static string GetSiteRedirectionTemplate(ISessionState sessionState) { ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(sessionState); if (exchangeRunspaceConfiguration == null || exchangeRunspaceConfiguration.ConfigurationSettings == null) { return(null); } return(exchangeRunspaceConfiguration.ConfigurationSettings.SiteRedirectionTemplate); }
// Token: 0x0600038F RID: 911 RVA: 0x0000D6E8 File Offset: 0x0000B8E8 internal static ExchangeRunspaceConfiguration GetExchangeRunspaceConfiguration(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); if (propertyContainer == null) { return(null); } return(propertyContainer.exchangeRunspaceConfiguration); }
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(); }
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); }
private void DisableCmdletLog(object sender, EventArgs e) { if (this.context == null) { return; } if (ExchangePropertyContainer.IsCmdletLogEnabled(this.context.SessionState)) { ExchangePropertyContainer.DisableCmdletLog(this.context.SessionState); } }
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); }
internal static void InitExchangePropertyContainer(ISessionState sessionState, OrganizationId currentExecutingOrgId, ADObjectId currentExecutingUserId) { ExchangePropertyContainer exchangePropertyContainer = new ExchangePropertyContainer(); exchangePropertyContainer.executingUserOrganizationId = currentExecutingOrgId; exchangePropertyContainer.executingUserId = currentExecutingUserId; if (sessionState.Variables.ContainsName(ExchangePropertyContainer.ADServerSettingsVarName)) { exchangePropertyContainer.serverSettings = (sessionState.Variables[ExchangePropertyContainer.ADServerSettingsVarName] as ADServerSettings); } ExchangePropertyContainer.SetExchangePropertyContainer(sessionState, exchangePropertyContainer); }
public WorkloadSettings GetWorkloadSettings() { ExchangeRunspaceConfigurationSettings.ExchangeApplication exchangeApplication = ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown; if (this.context.SessionState != null) { exchangeApplication = ExchangePropertyContainer.GetPropagatedClientAppId(this.context.SessionState); } if (exchangeApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown && this.context.ExchangeRunspaceConfig != null) { exchangeApplication = this.context.ExchangeRunspaceConfig.ConfigurationSettings.ClientApplication; } return(this.GetWorkloadSettings(exchangeApplication)); }
private void ExtractRbacDataFromRunspace(object sender, EventArgs e) { ADObjectId adobjectId = null; OrganizationId organizationId = null; ExchangePropertyContainer.InitializeExchangePropertyContainerIfNeeded(this.context.SessionState, out adobjectId, out organizationId); ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = null; if (this.context.SessionState != null) { exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(this.context.SessionState); } OrganizationId organizationId2; string executingUserIdentityName; SmtpAddress executingWindowsLiveId; if (exchangeRunspaceConfiguration == null) { if (this.context.SessionState != null) { organizationId = (organizationId ?? ExchangePropertyContainer.GetExecutingUserOrganizationId(this.context.SessionState)); adobjectId = (adobjectId ?? ExchangePropertyContainer.GetExecutingUserId(this.context.SessionState)); } organizationId2 = organizationId; executingUserIdentityName = ((adobjectId == null) ? string.Empty : adobjectId.Name); } else { exchangeRunspaceConfiguration.TryGetExecutingUserId(out adobjectId); executingUserIdentityName = exchangeRunspaceConfiguration.IdentityName; exchangeRunspaceConfiguration.TryGetExecutingWindowsLiveId(out executingWindowsLiveId); organizationId = (exchangeRunspaceConfiguration.PartnerMode ? OrganizationId.ForestWideOrgId : exchangeRunspaceConfiguration.OrganizationId); organizationId2 = exchangeRunspaceConfiguration.OrganizationId; SecurityIdentifier value; exchangeRunspaceConfiguration.TryGetExecutingUserSid(out value); CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ExecutingUserSid, value); } if (this.context.InvocationInfo != null && this.context.InvocationInfo.IsVerboseOn && !TaskLogger.IsSetupLogging) { string executingUserId = (adobjectId != null) ? adobjectId.ToCanonicalName() : string.Empty; string executingUserOrganizationId = (organizationId != null) ? organizationId.ToString() : string.Empty; string currentOrganizationId = (organizationId2 != null) ? organizationId2.ToString() : string.Empty; if (this.context.CommandShell != null) { this.context.CommandShell.WriteVerbose(Strings.VerboseExecutingUserContext(executingUserId, executingUserOrganizationId, currentOrganizationId, (exchangeRunspaceConfiguration == null) ? Strings.DisabledString : Strings.EnabledString)); } } this.context.ExchangeRunspaceConfig = exchangeRunspaceConfiguration; this.context.UserInfo = new TaskUserInfo(organizationId, organizationId2, adobjectId, executingUserIdentityName, executingWindowsLiveId); }
private static ExchangePropertyContainer GetPropertyContainer(InitialSessionState initialSessionState) { IList <SessionStateVariableEntry> list = initialSessionState.Variables[ExchangePropertyContainer.ExchangePropertyContainerName]; ExchangePropertyContainer exchangePropertyContainer = null; if (list.Count > 0) { exchangePropertyContainer = (ExchangePropertyContainer)list[0].Value; } if (exchangePropertyContainer == null) { throw new ArgumentException("initialSessionState"); } return(exchangePropertyContainer); }
public void Init(ITaskEvent task) { bool?flag = (bool?)this.context.InvocationInfo.Fields["CmdletLogEntriesEnabled"]; if (flag != null && flag.Value) { ExchangePropertyContainer.EnableCmdletLog(this.context.SessionState); } if ((flag != null && flag.Value) || ExchangePropertyContainer.IsCmdletLogEnabled(this.context.SessionState)) { task.PreInit += this.Task_PreInit; task.Stop += this.DisableCmdletLog; task.Release += this.DisableCmdletLog; this.context.CommandShell.PrependTaskIOPipelineHandler(this); } }
internal static bool InitializeExchangePropertyContainerIfNeeded(ISessionState sessionState, out ADObjectId executingUserId, out OrganizationId executingUserOrganizationId) { executingUserId = null; executingUserOrganizationId = null; if (sessionState != null && !ExchangePropertyContainer.IsContainerInitialized(sessionState)) { ExTraceGlobals.LogTracer.Information(0L, "ExchangePropertyContainer is not initialized. Case of Service, Setup or Powershell with manually added snapin"); executingUserOrganizationId = TaskHelper.ResolveCurrentUserOrganization(out executingUserId); if (executingUserOrganizationId == null) { executingUserOrganizationId = OrganizationId.ForestWideOrgId; } ExchangePropertyContainer.InitExchangePropertyContainer(sessionState, executingUserOrganizationId, executingUserId); return(true); } return(false); }
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; } }
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); }
private void CheckVerboseDebugParameter() { if (this.context.SessionState != null && ExchangePropertyContainer.IsContainerInitialized(this.context.SessionState)) { ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(this.context.SessionState); if (exchangeRunspaceConfiguration != null && this.context.InvocationInfo != null) { if (!exchangeRunspaceConfiguration.IsVerboseEnabled(this.context.InvocationInfo.CommandName)) { this.verboseDisabled = true; TaskLogger.Trace("The cmdlet does not have Verbose parameter by RBAC check. WriteVerbose is disabled.", new object[0]); } if (!exchangeRunspaceConfiguration.IsDebugEnabled(this.context.InvocationInfo.CommandName)) { this.debugDisabled = true; TaskLogger.Trace("The cmdlet does not have Debug parameter by RBAC check. WriteDebug is disabled.", new object[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); }
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); }
private void InitializeRunspaceServerSettings(object sender, EventArgs e) { ISessionState sessionState = this.CurrentTaskContext.SessionState; ADServerSettings adserverSettings = null; bool flag = false; bool flag2 = false; string value = null; if (sessionState != null) { flag2 = ExchangePropertyContainer.IsContainerInitialized(sessionState); if (flag2) { adserverSettings = ExchangePropertyContainer.GetServerSettings(sessionState); if (adserverSettings != null) { value = "SessionState"; } } } if (adserverSettings == null) { adserverSettings = ADSessionSettings.GetProcessServerSettings(); if (adserverSettings != null) { value = "ProcessServerSettings"; } } if (adserverSettings == null) { if (this.CurrentTaskContext.CommandShell != null) { this.CurrentTaskContext.CommandShell.TryGetVariableValue <ADServerSettings>(ExchangePropertyContainer.ADServerSettingsVarName, out adserverSettings); } flag = (adserverSettings != null); if (adserverSettings != null) { value = "CommandShell"; } } if (TopologyProvider.CurrentTopologyMode == TopologyMode.ADTopologyService) { ADServerSettings cmdletADServerSettings = this.GetCmdletADServerSettings(); if (cmdletADServerSettings != null) { this.CurrentTaskContext.Items["CmdletServerSettings"] = cmdletADServerSettings; value = "ADTopologyService"; adserverSettings = cmdletADServerSettings; } } if (adserverSettings == null) { flag = true; if (TopologyProvider.CurrentTopologyMode == TopologyMode.Adam) { if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn) { this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsAdam); } if (Globals.InstanceType == InstanceType.NotInitialized) { Globals.InitializeSinglePerfCounterInstance(); } value = "Adam-SimpleServerSettings"; adserverSettings = new SimpleServerSettings(); } else if (TopologyProvider.CurrentTopologyMode == TopologyMode.Ldap) { if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.CommandShell != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn) { this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsLocal); } Globals.InitializeMultiPerfCounterInstance("EMS"); value = "Ldap-LocalCmdLineServerSettings"; adserverSettings = LocalCmdLineServerSettings.CreateLocalCmdLineServerSettings(); } else { if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn) { this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsRemote); } adserverSettings = this.CreateADServerSettingsForOrganization(false); if (adserverSettings == null) { value = "GCRandomly"; adserverSettings = RunspaceServerSettings.CreateRunspaceServerSettings(false); } } } if (flag) { if (flag2) { ExchangePropertyContainer.SetServerSettings(sessionState, adserverSettings); } else { sessionState.Variables[ExchangePropertyContainer.ADServerSettingsVarName] = adserverSettings; } } ADSessionSettings.SetThreadADContext(new ADDriverContext(adserverSettings, ContextMode.Cmdlet)); LocalizedString localizedString = LocalizedString.Empty; if (this.CurrentTaskContext.InvocationInfo != null) { localizedString = TaskVerboseStringHelper.GetADServerSettings(this.CurrentTaskContext.InvocationInfo.CommandName, adserverSettings); if (this.CurrentTaskContext.InvocationInfo.IsVerboseOn && !string.Equals(this.CurrentTaskContext.InvocationInfo.CommandName, "Write-ExchangeSetupLog", StringComparison.OrdinalIgnoreCase) && this.CurrentTaskContext.CommandShell != null) { this.CurrentTaskContext.CommandShell.WriteVerbose(localizedString); } } CmdletLogger.SafeSetLogger(this.CurrentTaskContext.UniqueId, RpsCmdletMetadata.RunspaceSettingsCreationHint, value); CmdletLogHelper.LogADServerSettings(this.CurrentTaskContext.UniqueId, adserverSettings); if (ExTraceGlobals.LogTracer.IsTraceEnabled(TraceType.InfoTrace)) { ExTraceGlobals.LogTracer.Information <LocalizedString>(0L, "Cmdlet ADServerSettings {0}", localizedString); } }
internal static ExchangeRunspaceConfiguration GetExchangeRunspaceConfiguration(InitialSessionState initialSessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(initialSessionState); return(propertyContainer.exchangeRunspaceConfiguration); }
private void Task_PreInit(object sender, EventArgs e) { ExchangePropertyContainer.EnableCmdletLog(this.context.SessionState); this.cmdletLogEntries = ExchangePropertyContainer.GetCmdletLogEntries(this.context.SessionState); this.context.InvocationInfo.IsVerboseOn = true; }
internal static bool IsCmdletLogEnabled(ISessionState sessionState) { ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); return(propertyContainer != null && propertyContainer.logEnabled); }
internal static void SetExchangePropertyContainer(ISessionState sessionState, ExchangePropertyContainer container) { container.logEntries = new CmdletLogEntries(); object obj; if (!sessionState.Variables.TryGetValue(ExchangePropertyContainer.ExchangePropertyContainerName, out obj) || !(obj is ExchangePropertyContainer)) { VariableScopedOptions scope = VariableScopedOptions.AllScope | VariableScopedOptions.Constant | VariableScopedOptions.Private | VariableScopedOptions.ReadOnly; sessionState.Variables.Set(ExchangePropertyContainer.ExchangePropertyContainerName, container, scope); } }
internal static void ResetPerOrganizationData(ISessionState sessionState) { ExchangePropertyContainer.SetServerSettings(sessionState, null); ExchangePropertyContainer.RefreshProvisioningBroker(sessionState); }