Exemplo n.º 1
0
 // Token: 0x06001642 RID: 5698 RVA: 0x000539C4 File Offset: 0x00051BC4
 private bool ProxyCmdlet(CmdletProxyInfo cmdletProxyInfo)
 {
     this.proxiedObjectCount++;
     CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ProxiedObjectCount, this.proxiedObjectCount);
     this.context.Items["Log_ProxiedObjectCount"] = this.proxiedObjectCount;
     if (cmdletProxyInfo.ConfirmationMessage != LocalizedString.Empty)
     {
         if (!this.shouldProcessHasBeenPrompted && this.context.CommandShell != null && !this.context.CommandShell.ShouldProcess(cmdletProxyInfo.ConfirmationMessage))
         {
             CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "Proxy", "CancelAfterConfirm");
             CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ExecutionResult, "Cancelled");
             this.context.WasCancelled = true;
             return(false);
         }
         SwitchParameter switchParameter = new SwitchParameter(false);
         if (this.ShouldRemoveConfirmParam() && this.context.InvocationInfo != null)
         {
             this.context.InvocationInfo.UserSpecifiedParameters.Remove("Confirm");
         }
         if (this.context.InvocationInfo != null)
         {
             this.context.InvocationInfo.UserSpecifiedParameters.Add("Confirm", switchParameter);
         }
     }
     using (new CmdletMonitoredScope(this.context.UniqueId, "CmdletProxyLatency", "CmdletProxyLatency", LoggerHelper.CmdletPerfMonitors))
     {
         this.ProxyCmdletExecution(cmdletProxyInfo);
     }
     this.context.Items["Log_CmdletProxyInfo"] = string.Format("Cmdlet proxied to remote server {0}, version {1}.", cmdletProxyInfo.RemoteServerFqdn, ProxyHelper.GetFriendlyVersionInformation(cmdletProxyInfo.RemoteServerVersion));
     return(true);
 }
Exemplo n.º 2
0
 // Token: 0x060015BC RID: 5564 RVA: 0x00050BCF File Offset: 0x0004EDCF
 public override bool WriteObject(object input, out object output)
 {
     output = input;
     this.outputObjectCount++;
     CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.OutputObjectCount, this.outputObjectCount);
     return(true);
 }
Exemplo n.º 3
0
 // Token: 0x06001640 RID: 5696 RVA: 0x00053918 File Offset: 0x00051B18
 private void OnPreIterate(object sender, EventArgs eventArgs)
 {
     this.shouldProcessHasBeenPrompted = false;
     this.proxiedObjectCount           = 0;
     CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ProxiedObjectCount, 0);
     this.context.Items["Log_ProxiedObjectCount"] = 0;
 }
 internal static void Execute(this ICriticalFeature feature, Action action, TaskContext taskContext, string methodNameInLog)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         Guid      uniqueId = taskContext.UniqueId;
         bool      flag     = false;
         Exception ex2;
         bool      needReportException = !TaskHelper.IsTaskKnownException(ex2) && TaskHelper.ShouldReportException(ex2, out flag);
         if (!needReportException)
         {
             CmdletLogger.SafeAppendGenericError(uniqueId, methodNameInLog, ex2.ToString(), false);
         }
         else
         {
             CmdletLogger.SafeAppendGenericError(uniqueId, methodNameInLog, ex2.ToString(), true);
             CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.ErrorType, "UnHandled");
         }
         if (feature == null || feature.IsCriticalException(ex2))
         {
             throw;
         }
         if (!flag)
         {
             taskContext.CommandShell.WriteWarning(Strings.WarningTaskModuleSkipped(methodNameInLog, ex2.Message));
         }
         Diagnostics.ReportException(ex2, Constants.CoreEventLogger, TaskEventLogConstants.Tuple_UnhandledException, (object ex) => needReportException, null, ExTraceGlobals.InstrumentationTracer, "Exception from  " + methodNameInLog + ": {0}");
     }
 }
Exemplo n.º 5
0
        protected void EnforceDelay()
        {
            if (this.context.ErrorInfo.TerminatePipeline)
            {
                return;
            }
            IPowerShellBudget psbudget = this.PSBudget;

            if (psbudget != null)
            {
                T t = (default(T) == null) ? Activator.CreateInstance <T>() : default(T);
                DelayEnforcementResults delayEnforcementResults = t.EnforceDelay(this, ThrottlingModule <T> .costTypesInEnforceDelay, ThrottlingModule <T> .CmdletMaxPreferredDelay);
                LocalizedString         localizedString         = this.GenerateDelayInfoLogString(this.PSBudget, delayEnforcementResults);
                if (!string.IsNullOrEmpty(localizedString))
                {
                    string          text           = string.Format("; PolicyDN: {0}; Snapshot: {1}", psbudget.ThrottlingPolicy.GetIdentityString(), psbudget);
                    LocalizedString warningMessage = new LocalizedString(localizedString + text);
                    this.context.Items["ThrottlingInfo"] = text;
                    this.context.Items["DelayedInfo"]    = localizedString;
                    Guid uniqueId = this.context.UniqueId;
                    CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.ThrottlingInfo, text);
                    CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.DelayInfo, CmdletLogHelper.NeedConvertLogMessageToUS ? localizedString.ToString(CmdletLogHelper.DefaultLoggingCulture) : localizedString);
                    this.WriteCmdletMicroDelayMessage(warningMessage, delayEnforcementResults.DelayInfo.Delay.TotalSeconds);
                }
                PowerShellBudgetWrapper powerShellBudgetWrapper = psbudget as PowerShellBudgetWrapper;
                WorkloadManagementLogger.SetBudgetBalance(powerShellBudgetWrapper.GetInnerBudget().CasTokenBucket.GetBalance().ToString(), null);
            }
        }
 // Token: 0x06001603 RID: 5635 RVA: 0x00052250 File Offset: 0x00050450
 private void OnIterateCompleted(object sender, EventArgs eventArgs)
 {
     if (this.context.InvocationInfo != null)
     {
         Guid uniqueId = this.context.UniqueId;
         this.parametersSetInLog = true;
         CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.Cmdlet, this.context.InvocationInfo.CommandName);
         CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.Parameters, TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag()));
     }
 }
        // Token: 0x06001607 RID: 5639 RVA: 0x00052434 File Offset: 0x00050634
        private void StartLogging()
        {
            this.logPendingCommit   = true;
            this.parametersSetInLog = false;
            Guid uniqueId = this.context.UniqueId;

            CmdletThreadStaticData.RegisterCmdletUniqueId(uniqueId);
            CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.StartTime, DateTime.UtcNow);
            CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.ExecutionResult, "Success");
            CmdletLatencyTracker.StartLatencyTracker(uniqueId);
            CmdletLatencyTracker.StartInternalTracking(uniqueId, "Cmd", true);
        }
Exemplo n.º 8
0
        internal static void SetCmdletErrorType(Guid cmdletUniqueId, string errorType)
        {
            string a = CmdletStaticDataWithUniqueId <string> .Get(cmdletUniqueId);

            if (a == "UnHandled")
            {
                return;
            }
            CmdletStaticDataWithUniqueId <string> .Set(cmdletUniqueId, errorType);

            CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ErrorType, errorType);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        private LocalizedString GenerateDelayInfoLogString(IBudget budget, DelayEnforcementResults info)
        {
            LocalizedString result = LocalizedString.Empty;

            if (!string.Equals(info.NotEnforcedReason, "No Delay Necessary", StringComparison.OrdinalIgnoreCase))
            {
                CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "DelayInfo.Type", info.DelayInfo.GetType().Name);
                if (info.NotEnforcedReason != null)
                {
                    CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "NotEnforcedReason", info.NotEnforcedReason);
                }
                if (string.Equals(info.NotEnforcedReason, "Max Delayed Threads Exceeded", StringComparison.OrdinalIgnoreCase))
                {
                    BudgetTypeSetting budgetTypeSetting = BudgetTypeSettings.Get(budget.Owner.BudgetType);
                    if (info.DelayInfo is UserQuotaDelayInfo)
                    {
                        UserQuotaDelayInfo userQuotaDelayInfo = info.DelayInfo as UserQuotaDelayInfo;
                        result = Strings.UserQuotaDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, userQuotaDelayInfo.OverBudgetException.PolicyPart, budgetTypeSetting.MaxDelayedThreads);
                    }
                    else if (info.DelayInfo is ResourceLoadDelayInfo)
                    {
                        ResourceLoadDelayInfo resourceLoadDelayInfo = info.DelayInfo as ResourceLoadDelayInfo;
                        result = Strings.ResourceLoadDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, resourceLoadDelayInfo.ResourceKey.ToString(), resourceLoadDelayInfo.ResourceLoad.ToString(), budgetTypeSetting.MaxDelayedThreads);
                    }
                    else
                    {
                        result = Strings.MicroDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, budgetTypeSetting.MaxDelayedThreads);
                    }
                }
                else
                {
                    CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ThrottlingDelay, info.DelayedAmount.TotalMilliseconds);
                    if (info.DelayInfo is UserQuotaDelayInfo)
                    {
                        UserQuotaDelayInfo userQuotaDelayInfo2 = info.DelayInfo as UserQuotaDelayInfo;
                        result = Strings.UserQuotaDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, userQuotaDelayInfo2.OverBudgetException.PolicyPart, info.NotEnforcedReason);
                    }
                    else if (info.DelayInfo is ResourceLoadDelayInfo)
                    {
                        ResourceLoadDelayInfo resourceLoadDelayInfo2 = info.DelayInfo as ResourceLoadDelayInfo;
                        result = Strings.ResourceLoadDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, resourceLoadDelayInfo2.ResourceKey.ToString(), resourceLoadDelayInfo2.ResourceLoad.ToString(), info.NotEnforcedReason);
                    }
                    else
                    {
                        result = Strings.MicroDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, info.NotEnforcedReason);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 11
0
        private void StartBudgetProcess(object sender, EventArgs e)
        {
            string cmdLetName = null;

            if (this.context.InvocationInfo != null)
            {
                cmdLetName = this.context.InvocationInfo.CommandName;
            }
            this.DisposeCostHandle();
            this.SafeBudgetAction(delegate(BudgetInformation budgetInfo)
            {
                CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.UserBudgetOnStart, budgetInfo.Budget.GetCmdletBudgetUsage());
            });
            this.SafeBudgetAction(delegate(BudgetInformation budgetInfo)
            {
                budgetInfo.Budget.EndLocal();
            });
            this.SafeBudgetAction(delegate(BudgetInformation budgetInfo)
            {
                budgetInfo.Handle = budgetInfo.Budget.StartCmdlet(cmdLetName);
            });
            if (!this.casCostHandleDisabled)
            {
                this.SafeBudgetAction(delegate(BudgetInformation budgetInfo)
                {
                    try
                    {
                        budgetInfo.Budget.StartLocal(string.Format("Task.StartBudgetProcess.{0}", cmdLetName), default(TimeSpan));
                        budgetInfo.Budget.LocalCostHandle.MaxLiveTime = TimeSpan.FromHours(1.0);
                    }
                    catch (InvalidOperationException)
                    {
                        try
                        {
                            CmdletLogger.SafeAppendGenericError("StartLocalBudgetFailed", cmdLetName, false);
                            budgetInfo.Budget.EndLocal();
                        }
                        catch (Exception)
                        {
                        }
                    }
                });
                return;
            }
            ThrottlingModule <T> .LogInformationTrace("CasCostHandle is not enabled in cmdlet '{0}'", new object[]
            {
                cmdLetName
            });
        }
Exemplo n.º 12
0
        protected IDisposable CreatePiiSuppressionContext(IConfigurable outputObject)
        {
            ConfigurableObject configurableObject = outputObject as ConfigurableObject;

            if (configurableObject == null)
            {
                return(null);
            }
            if (configurableObject.SkipPiiRedaction || SuppressingPiiProperty.IsExcludedSchemaType(configurableObject.ObjectSchema.GetType()) || (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.SkipPiiRedactionForForestWideObject.Enabled && TaskHelper.IsForestWideADObject(outputObject as ADObject)))
            {
                return(null);
            }
            CmdletLogger.SafeSetLogger(this.CurrentTaskContext.UniqueId, RpsCmdletMetadata.IsOutputObjectRedacted, true);
            return(SuppressingPiiContext.Create(true, this.CurrentPiiMap));
        }
Exemplo n.º 13
0
        internal static void LogADServerSettings(Guid cmdletUniqueId, ADServerSettings serverSettings)
        {
            if (serverSettings == null)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "ADServerSettings", "null");
                return;
            }
            CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADViewEntireForest, serverSettings.ViewEntireForest);
            if (serverSettings.RecipientViewRoot != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADRecipientViewRoot, serverSettings.RecipientViewRoot.ToCanonicalName());
            }
            if (serverSettings.ConfigurationDomainControllers != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADConfigurationDomainControllers, string.Join <Fqdn>(",", serverSettings.ConfigurationDomainControllers.Values));
            }
            if (serverSettings.PreferredGlobalCatalogs != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADPreferredGlobalCatalogs, string.Join <Fqdn>(",", serverSettings.PreferredGlobalCatalogs.Values));
            }
            if (serverSettings.PreferredDomainControllers != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADPreferredDomainControllers, string.Join <Fqdn>(",", serverSettings.PreferredDomainControllers.ToArray()));
            }
            RunspaceServerSettings runspaceServerSettings = serverSettings as RunspaceServerSettings;

            if (runspaceServerSettings == null)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RunspaceServerSettings", "null");
                return;
            }
            if (runspaceServerSettings.UserConfigurationDomainController != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADUserConfigurationDomainController, runspaceServerSettings.UserConfigurationDomainController);
            }
            if (runspaceServerSettings.UserPreferredGlobalCatalog != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADUserPreferredGlobalCatalog, runspaceServerSettings.UserConfigurationDomainController);
            }
            if (runspaceServerSettings.UserPreferredDomainControllers != null)
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ADUserPreferredDomainControllers, string.Join <Fqdn>(",", runspaceServerSettings.UserPreferredDomainControllers.ToArray()));
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        // Token: 0x06001608 RID: 5640 RVA: 0x000524C4 File Offset: 0x000506C4
        private void CommitLog(string loggingStep)
        {
            if (!this.logPendingCommit)
            {
                return;
            }
            this.logPendingCommit = false;
            Guid cmdletUniqueId = this.context.UniqueId;

            try
            {
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.CmdletUniqueId, cmdletUniqueId);
                if (loggingStep != null)
                {
                    CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "Logging", loggingStep);
                }
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ProcessId, Constants.ProcessId);
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ProcessName, Constants.ProcessName);
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ThreadId, Environment.CurrentManagedThreadId);
                CmdletLatencyTracker.EndInternalTracking(cmdletUniqueId, "Cmd");
                CmdletLatencyTracker.PushLatencyDetailsToLog(cmdletUniqueId, CmdletLogHelper.FuncNameToLogMetaDic, delegate(Enum metadata, double latency)
                {
                    CmdletLogger.UpdateLatency(cmdletUniqueId, metadata, latency);
                }, delegate(string funcName, string totalLatency)
                {
                    CmdletLogger.SafeAppendColumn(RpsCommonMetadata.GenericLatency, funcName, totalLatency);
                });
                long num = CmdletLatencyTracker.StopLatencyTracker(cmdletUniqueId);
                CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.TotalTime, num);
                CmdletLatencyTracker.DisposeLatencyTracker(cmdletUniqueId);
                if (!this.parametersSetInLog)
                {
                    if (this.context.InvocationInfo != null)
                    {
                        CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.Cmdlet, this.context.InvocationInfo.CommandName);
                        CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.Parameters, TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag()));
                    }
                    else
                    {
                        CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "InvocationInfo", "null");
                    }
                }
                TaskUserInfo userInfo = this.context.UserInfo;
                if (userInfo != null)
                {
                    CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.TenantId, userInfo.ExecutingUserOrganizationId.GetFriendlyName());
                    CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.AuthenticatedUser, (userInfo.ExecutingWindowsLiveId != SmtpAddress.Empty) ? userInfo.ExecutingWindowsLiveId.ToString() : ((userInfo.ExecutingUserId != null && !string.IsNullOrWhiteSpace(userInfo.ExecutingUserId.Name)) ? userInfo.ExecutingUserId.Name : userInfo.ExecutingUserIdentityName));
                    CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.EffectiveOrganization, userInfo.CurrentOrganizationId.GetFriendlyName());
                }
                else
                {
                    CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "UserInfo", "null");
                }
                if (this.context.ExchangeRunspaceConfig != null)
                {
                    CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.UserServicePlan, this.context.ExchangeRunspaceConfig.ServicePlanForLogging);
                    CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.IsAdmin, this.context.ExchangeRunspaceConfig.HasAdminRoles);
                    if (this.context.ExchangeRunspaceConfig.ConfigurationSettings != null && this.context.ExchangeRunspaceConfig.ConfigurationSettings.ClientApplication != ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown)
                    {
                        CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ClientApplication, this.context.ExchangeRunspaceConfig.ConfigurationSettings.ClientApplication);
                    }
                }
                else
                {
                    CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "ExchangeRunspaceConfig", "null");
                }
                if (!CmdletLogHelper.DefaultLoggingCulture.Equals(CultureInfo.CurrentUICulture) || !CmdletLogHelper.DefaultLoggingCulture.Equals(CultureInfo.CurrentCulture))
                {
                    CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.CultureInfo, CultureInfo.CurrentUICulture + "," + CultureInfo.CurrentCulture);
                }
            }
            catch (Exception ex)
            {
                Diagnostics.LogExceptionWithTrace(Constants.CoreEventLogger, TaskEventLogConstants.Tuple_NonCrashingException, null, ExTraceGlobals.InstrumentationTracer, null, "Exception from CmdletLogger.AsyncCommit : {0}", ex);
                CmdletLogger.SafeAppendGenericError(cmdletUniqueId, "CommitLog", ex, new Func <Exception, bool>(TaskHelper.IsTaskUnhandledException));
            }
            finally
            {
                try
                {
                    CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.EndTime, DateTime.UtcNow);
                    CmdletLogger.AsyncCommit(cmdletUniqueId, true);
                    CmdletThreadStaticData.UnRegisterCmdletUniqueId(cmdletUniqueId);
                }
                catch (Exception exception)
                {
                    this.logPendingCommit = true;
                    Diagnostics.LogExceptionWithTrace(Constants.CoreEventLogger, TaskEventLogConstants.Tuple_NonCrashingException, null, ExTraceGlobals.InstrumentationTracer, null, "Exception from CmdletLogger.AsyncCommit : {0}", exception);
                }
            }
        }
Exemplo n.º 16
0
        internal static void ClearCmdletErrorType(Guid cmdletUniuqueId)
        {
            CmdletStaticDataWithUniqueId <string> .Remove(cmdletUniuqueId);

            CmdletLogger.SafeSetLogger(cmdletUniuqueId, RpsCmdletMetadata.ErrorType, string.Empty);
        }