Example #1
0
        // Token: 0x06001672 RID: 5746 RVA: 0x00054E80 File Offset: 0x00053080
        private void PreRelease(object sender, EventArgs e)
        {
            ADDriverContext  threadADContext = ADSessionSettings.GetThreadADContext();
            ADServerSettings serverSettings  = (threadADContext != null) ? threadADContext.ServerSettings : null;

            CmdletLogHelper.LogADServerSettingsAfterCmdExecuted(this.context.UniqueId, serverSettings);
        }
Example #2
0
        // Token: 0x06001673 RID: 5747 RVA: 0x00054EB4 File Offset: 0x000530B4
        private void MarkDcDownIfNecessary(GenericEventArg <TaskErrorEventArg> e)
        {
            if (e.Data.ExceptionHandled)
            {
                return;
            }
            ADDriverContext  threadADContext  = ADSessionSettings.GetThreadADContext();
            ADServerSettings adserverSettings = (threadADContext != null) ? threadADContext.ServerSettings : null;

            if (this.context == null || adserverSettings == null)
            {
                return;
            }
            string text = null;

            for (Exception ex = e.Data.Exception; ex != null; ex = ex.InnerException)
            {
                if (ex is SuitabilityDirectoryException)
                {
                    text = ((SuitabilityDirectoryException)ex).Fqdn;
                    break;
                }
                if (ex is ServerInMMException)
                {
                    text = ((ServerInMMException)ex).Fqdn;
                    break;
                }
                if (ex is ADServerSettingsChangedException)
                {
                    ADServerSettings serverSettings = ((ADServerSettingsChangedException)ex).ServerSettings;
                    this.PersistNewServerSettings(serverSettings);
                    break;
                }
                if (ex == ex.InnerException)
                {
                    break;
                }
            }
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }
            Fqdn fqdn;

            if (Fqdn.TryParse(text, out fqdn))
            {
                try
                {
                    adserverSettings.MarkDcDown(fqdn);
                    CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "MarkDcDown", fqdn);
                    return;
                }
                catch (NotSupportedException)
                {
                    CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "MarkDcDown-NotSupportedException", fqdn);
                    return;
                }
            }
            CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "MarkDcDown-InvalidFqdn", fqdn);
        }
Example #3
0
        // Token: 0x06001674 RID: 5748 RVA: 0x00054FE0 File Offset: 0x000531E0
        private void TryFailOver()
        {
            ADDriverContext  threadADContext  = ADSessionSettings.GetThreadADContext();
            ADServerSettings adserverSettings = (threadADContext != null) ? threadADContext.ServerSettings : null;

            if (adserverSettings != null && adserverSettings.IsFailoverRequired())
            {
                ADServerSettings newServerSettings;
                string           str;
                if (adserverSettings.TryFailover(out newServerSettings, out str, false))
                {
                    this.PersistNewServerSettings(newServerSettings);
                    return;
                }
                CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-TryFailOver", "Failed - " + str);
            }
        }
Example #4
0
        // Token: 0x060008E1 RID: 2273 RVA: 0x00027BE0 File Offset: 0x00025DE0
        private CacheMode GetCacheMode()
        {
            bool            flag            = false;
            ADDriverContext addriverContext = ADSessionSettings.GetProcessADContext() ?? ADSessionSettings.GetThreadADContext();

            if (addriverContext != null)
            {
                if (ContextMode.Setup == addriverContext.Mode || ContextMode.TopologyService == addriverContext.Mode)
                {
                    return(CacheMode.Disabled);
                }
                flag = (ContextMode.Cmdlet == addriverContext.Mode);
            }
            if (!flag)
            {
                return(CacheMode.Read | CacheMode.SyncWrite);
            }
            return(CacheMode.AsyncWrite);
        }
Example #5
0
        // Token: 0x060015C1 RID: 5569 RVA: 0x00050C28 File Offset: 0x0004EE28
        private void LogCmdletIterationEvent()
        {
            bool flag  = this.context.ExchangeRunspaceConfig == null;
            bool flag2 = VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.WriteEventLogInEnglish.Enabled && (CultureInfo.CurrentUICulture != CmdletLogHelper.DefaultLoggingCulture || CultureInfo.CurrentCulture != CmdletLogHelper.DefaultLoggingCulture);

            object[] array = new object[27];
            array[0] = ((this.context.InvocationInfo != null) ? this.context.InvocationInfo.DisplayName : string.Empty);
            array[1] = ((this.context.InvocationInfo == null) ? null : TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag()));
            array[2] = (flag ? ((this.context.UserInfo != null && this.context.UserInfo.ExecutingUserId != null) ? this.context.UserInfo.ExecutingUserId.ToString() : string.Empty) : this.context.ExchangeRunspaceConfig.IdentityName);
            array[3] = (flag ? null : this.context.ExchangeRunspaceConfig.LogonUserSid);
            array[4] = null;
            if (!flag)
            {
                SecurityIdentifier securityIdentifier = null;
                this.context.ExchangeRunspaceConfig.TryGetExecutingUserSid(out securityIdentifier);
                array[4] = securityIdentifier;
            }
            array[5] = this.GenerateApplicationString();
            array[6] = CmdletIterationEventModule.processIdAndName;
            array[7] = (flag ? ((this.context.UserInfo != null) ? this.context.UserInfo.CurrentOrganizationId : null) : this.context.ExchangeRunspaceConfig.OrganizationId);
            array[8] = Environment.CurrentManagedThreadId;
            DateTime utcNow = DateTime.UtcNow;

            array[9] = utcNow.Subtract(this.lastDateTimeValue);
            this.lastDateTimeValue = utcNow;
            ADDriverContext threadADContext = ADSessionSettings.GetThreadADContext();

            if (threadADContext == null)
            {
                array[10] = null;
            }
            else
            {
                array[10] = (flag2 ? TaskVerboseStringHelper.GetADServerSettings(null, threadADContext.ServerSettings, CmdletLogHelper.DefaultLoggingCulture) : TaskVerboseStringHelper.GetADServerSettings(null, threadADContext.ServerSettings, null));
            }
            if (this.context.ErrorInfo.HasErrors)
            {
                if (this.context.ErrorInfo.Exception != null)
                {
                    Exception exception = this.context.ErrorInfo.Exception;
                    array[11] = exception;
                    array[12] = this.context.ErrorInfo.ExchangeErrorCategory.Value;
                    if (exception != null && exception.InnerException != null)
                    {
                        array[13] = exception.InnerException;
                    }
                    if (exception is LocalizedException)
                    {
                        array[14] = ((LocalizedException)exception).LocalizedString.StringId;
                        if (!flag2)
                        {
                            goto IL_2DE;
                        }
                        LocalizedException ex             = (LocalizedException)exception;
                        IFormatProvider    formatProvider = ex.FormatProvider;
                        try
                        {
                            ex.FormatProvider = CmdletLogHelper.DefaultLoggingCulture;
                            array[11]         = ex.ToString();
                            goto IL_2DE;
                        }
                        finally
                        {
                            ex.FormatProvider = formatProvider;
                        }
                    }
                    array[14] = "NonLocalizedException";
                }
                else
                {
                    array[11] = "null";
                }
            }
IL_2DE:
            object obj;

            this.context.Items.TryGetValue("Log_AdditionalLogData", out obj);
            array[15] = obj;
            LocalizedString delayedInfo = ThrottlingModule <ResourceThrottlingCallback> .GetDelayedInfo(this.context);

            if (!string.IsNullOrEmpty(delayedInfo))
            {
                array[16] = (flag2 ? delayedInfo.ToString(CmdletLogHelper.DefaultLoggingCulture) : delayedInfo) + ThrottlingModule <ResourceThrottlingCallback> .GetThrottlingInfo(this.context);
            }
            array[17] = SuppressingPiiContext.NeedPiiSuppression;
            this.context.Items.TryGetValue("Log_CmdletProxyInfo", out obj);
            array[18] = obj;
            if (this.context.Items.TryGetValue("Log_ProxiedObjectCount", out obj))
            {
                obj = string.Format("{0} objects execution has been proxied to remote server.", obj);
            }
            array[19] = obj;
            if (this.context.Items.TryGetValue("Log_RequestQueryFilterInGetTasks", out obj))
            {
                array[20] = string.Format("Request Filter used is: {0}", obj);
            }
            if (this.context.Items.TryGetValue("Log_InternalQueryFilterInGetTasks", out obj))
            {
                array[21] = string.Format("Cmdlet Filter used is: {0}", obj);
            }
            array[22] = this.outputObjectCount;
            array[23] = "ActivityId: " + ((ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value.ToString() : string.Empty);
            if (!flag && this.context.ExchangeRunspaceConfig != null)
            {
                array[24] = this.context.ExchangeRunspaceConfig.GetRBACInformationSummary();
            }
            if (Constants.IsPowerShellWebService && HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Headers != null)
            {
                array[25] = HttpContext.Current.Request.Headers["client-request-id"];
            }
            array[26] = CultureInfo.CurrentUICulture.Name;
            ExEventLog.EventTuple eventInfo;
            if (this.context.ErrorInfo.HasErrors)
            {
                eventInfo = TaskEventLogConstants.Tuple_LogCmdletError;
            }
            else if (this.context.WasCancelled)
            {
                eventInfo = TaskEventLogConstants.Tuple_LogCmdletCancelled;
            }
            else if (this.wasStopped)
            {
                eventInfo = TaskEventLogConstants.Tuple_LogCmdletStopped;
            }
            else
            {
                eventInfo = this.CmdletSuccessEventTuple;
            }
            try
            {
                TaskLogger.LogEvent("All", eventInfo, array);
            }
            catch (ArgumentException ex2)
            {
                if (this.context.CommandShell != null)
                {
                    this.context.CommandShell.WriteWarning(Strings.WarningCannotWriteToEventLog(ex2.ToString()));
                }
            }
        }