예제 #1
0
 protected override void InternalBeginProcessing()
 {
     base.InternalBeginProcessing();
     this.ResolveCurrentOrgIdBasedOnIdentity(this.Identity);
     TaskLogger.LogExit();
 }
예제 #2
0
        // Token: 0x060005C3 RID: 1475 RVA: 0x00015CAC File Offset: 0x00013EAC
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            OrganizationId currentOrganizationId = base.CurrentOrganizationId;
            TDataObject    dataObject            = this.DataObject;

            if (!currentOrganizationId.Equals(dataObject.OrganizationId))
            {
                this.CurrentOrgState = new LazilyInitialized <SharedTenantConfigurationState>(delegate()
                {
                    TDataObject dataObject17 = this.DataObject;
                    return(SharedConfiguration.GetSharedConfigurationState(dataObject17.OrganizationId));
                });
            }
            ADRecipient adrecipient = this.DataObject;
            bool        flag        = adrecipient != null && adrecipient.RecipientSoftDeletedStatus > 0;

            if (RecipientTaskHelper.IsMailEnabledRecipientType(this.DesiredRecipientType) && !flag)
            {
                if (!base.IsProvisioningLayerAvailable)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), (ErrorCategory)1001, null);
                }
                TDataObject dataObject2 = this.DataObject;
                if (dataObject2.IsModified(ADRecipientSchema.EmailAddresses))
                {
                    TDataObject dataObject3 = this.DataObject;
                    if (dataObject3.EmailAddresses.Count > 0)
                    {
                        if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && this.ShouldCheckAcceptedDomains())
                        {
                            IDirectorySession     configurationSession  = this.ConfigurationSession;
                            TDataObject           dataObject4           = this.DataObject;
                            IConfigurationSession configurationSession2 = (IConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(configurationSession, dataObject4.OrganizationId, true);
                            IConfigurationSession cfgSession            = configurationSession2;
                            TDataObject           dataObject5           = this.DataObject;
                            RecipientTaskHelper.ValidateSmtpAddress(cfgSession, dataObject5.EmailAddresses, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache);
                        }
                        ADObjectId        rootOrgContainerId = base.RootOrgContainerId;
                        TDataObject       dataObject6        = this.DataObject;
                        ADSessionSettings sessionSettings    = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(rootOrgContainerId, dataObject6.OrganizationId, base.ExecutingUserOrganizationId, false);
                        IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, string.IsNullOrEmpty(base.DomainController) ? null : base.NetCredential, sessionSettings, 557, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\SetAdObjectTask.cs");
                        IRecipientSession tenantCatalogSession            = tenantOrRootOrgRecipientSession;
                        TDataObject       dataObject7 = this.DataObject;
                        RecipientTaskHelper.ValidateEmailAddressErrorOut(tenantCatalogSession, dataObject7.EmailAddresses, this.DataObject, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerReThrowDelegate(this.WriteError));
                    }
                }
            }
            TDataObject dataObject8 = this.DataObject;

            if (dataObject8.IsChanged(ADObjectSchema.Id))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, base.OrgWideSessionSettings, ConfigScopes.TenantSubTree, 579, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\SetAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                TDataObject dataObject9 = this.DataObject;
                ADObjectId  parent      = dataObject9.Id.Parent;
                ADRawEntry  adrawEntry  = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion
                });
                ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                TDataObject           dataObject10          = this.DataObject;
                if (dataObject10.ExchangeVersion.IsOlderThan(exchangeObjectVersion))
                {
                    TDataObject dataObject11 = this.DataObject;
                    string      name         = dataObject11.Name;
                    TDataObject dataObject12 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject12.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            TDataObject dataObject13 = this.DataObject;

            if (dataObject13.RecipientType != this.DesiredRecipientType && this.DesiredRecipientType != RecipientType.Invalid)
            {
                TDataObject   dataObject14 = this.DataObject;
                string        id           = dataObject14.Identity.ToString();
                string        oldType      = this.DesiredRecipientType.ToString();
                TDataObject   dataObject15 = this.DataObject;
                Exception     exception    = new InvalidOperationException(Strings.ErrorSetTaskChangeRecipientType(id, oldType, dataObject15.RecipientType.ToString()));
                ErrorCategory category     = (ErrorCategory)1000;
                TDataObject   dataObject16 = this.DataObject;
                base.WriteError(exception, category, dataObject16.Identity);
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
예제 #3
0
        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()));
                }
            }
        }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IConfigurationSession))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(session.GetType().Name), "session");
            }
            if (((typeof(T) == typeof(ADOrganizationalUnit) && session.UseConfigNC) || (typeof(T) == typeof(ExchangeConfigurationUnit) && !session.UseConfigNC)) && !Environment.StackTrace.Contains("Microsoft.Exchange.Management.Deployment.OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId"))
            {
                throw new ArgumentException("Session is using the wrong Naming Context for the desired search");
            }
            notFoundReason = null;
            EnumerableWrapper <T> result = EnumerableWrapper <T> .Empty;

            if (base.IsMultitenancyEnabled())
            {
                if (this.IsWildcardDefined(base.RawIdentity))
                {
                    if (null == this.AccountPartition)
                    {
                        notFoundReason = new LocalizedString?(Strings.ErrorOrganizationWildcard);
                        return(result);
                    }
                    IEnumerable <ExchangeConfigurationUnit> configurationUnits = this.GetConfigurationUnits((IConfigurationSession)session, base.RawIdentity);
                    return(EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) configurationUnits, this.GetEnumerableFilter <T>()));
                }
                else
                {
                    OrganizationId organizationId = this.ResolveOrganizationId(session.SessionSettings.CurrentOrganizationId);
                    if (!OrganizationId.ForestWideOrgId.Equals(organizationId))
                    {
                        ADSessionSettings adsessionSettings = ADSessionSettings.FromCustomScopeSet(ScopeSet.ResolveUnderScope(organizationId, session.SessionSettings.ScopeSet), session.SessionSettings.RootOrgId, organizationId, session.SessionSettings.ExecutingUserOrganizationId, true);
                        adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                        bool flag = TaskHelper.ShouldPassDomainControllerToSession(session.DomainController, adsessionSettings);
                        ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(flag ? session.DomainController : null, session.ReadOnly, session.ConsistencyMode, flag ? session.NetworkCredential : null, adsessionSettings, 314, "GetObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\organizationidparameter.cs");
                        tenantConfigurationSession.UseConfigNC      = session.UseConfigNC;
                        tenantConfigurationSession.UseGlobalCatalog = session.UseGlobalCatalog;
                        if (typeof(ExchangeConfigurationUnit) == typeof(T) && organizationId.ConfigurationUnit != null)
                        {
                            List <ExchangeConfigurationUnit> list = new List <ExchangeConfigurationUnit>();
                            ExchangeConfigurationUnit        exchangeConfigurationUnit = tenantConfigurationSession.Read <ExchangeConfigurationUnit>(organizationId.ConfigurationUnit);
                            if (exchangeConfigurationUnit != null)
                            {
                                list.Add(exchangeConfigurationUnit);
                                result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list, this.GetEnumerableFilter <T>());
                            }
                        }
                        else if (organizationId.OrganizationalUnit != null)
                        {
                            List <ADOrganizationalUnit> list2 = new List <ADOrganizationalUnit>();
                            ADOrganizationalUnit        adorganizationalUnit = tenantConfigurationSession.Read <ADOrganizationalUnit>(organizationId.OrganizationalUnit);
                            if (adorganizationalUnit != null)
                            {
                                list2.Add(adorganizationalUnit);
                                result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list2, this.GetEnumerableFilter <T>());
                            }
                        }
                    }
                }
            }
            TaskLogger.LogExit();
            return(result);
        }
예제 #5
0
 // Token: 0x0600004B RID: 75 RVA: 0x0000365C File Offset: 0x0000185C
 public static void LogEvent(string hostName, ExEventLog.EventTuple eventInfo, string periodicKey, params object[] messageArguments)
 {
     TaskLogger.LogEvent(TaskLogger.GetEventLogger(hostName), eventInfo, periodicKey, messageArguments);
 }
예제 #6
0
 // Token: 0x06000038 RID: 56 RVA: 0x000030DA File Offset: 0x000012DA
 public static void UnmanagedLog(string s)
 {
     TaskLogger.Log(new LocalizedString(s));
 }
예제 #7
0
 // Token: 0x0600004A RID: 74 RVA: 0x00003651 File Offset: 0x00001851
 public static void LogEvent(string hostName, ExEventLog.EventTuple eventInfo, params object[] messageArguments)
 {
     TaskLogger.LogEvent(hostName, eventInfo, null, messageArguments);
 }
예제 #8
0
 // Token: 0x06000046 RID: 70 RVA: 0x000035B2 File Offset: 0x000017B2
 public static void IncreaseIndentation()
 {
     TaskLogger.IncreaseIndentation(LocalizedString.Empty);
 }
예제 #9
0
 // Token: 0x06000041 RID: 65 RVA: 0x000034FC File Offset: 0x000016FC
 public static void Trace(LocalizedString localizedString)
 {
     ExTraceGlobals.TraceTracer.Information(0L, TaskLogger.FormatLocalizedString(localizedString));
 }
예제 #10
0
        // Token: 0x0600003D RID: 61 RVA: 0x000031DC File Offset: 0x000013DC
        public static void SendWatsonReport(Exception e, string taskName, PropertyBag boundParameters)
        {
            TaskLogger.StopFileLogging();
            bool flag = true;

            try
            {
                string sourceFileName = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, ConfigurationContext.Setup.SetupLogFileName);
                string text           = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, ConfigurationContext.Setup.SetupLogFileNameForWatson);
                File.Copy(sourceFileName, text, true);
                int num = 0;
                while (!ExWatson.TryAddExtraFile(text) && num < 10)
                {
                    Thread.Sleep(100);
                    num++;
                }
            }
            catch (FileNotFoundException)
            {
            }
            catch (DirectoryNotFoundException)
            {
            }
            catch (IOException)
            {
                flag = false;
                if (TaskLogger.IsFileLoggingEnabled)
                {
                    TaskLogger.LogErrorString(Strings.ExchangeSetupCannotCopyWatson(ConfigurationContext.Setup.SetupLogFileName, ConfigurationContext.Setup.SetupLogFileNameForWatson));
                }
            }
            if (flag)
            {
                if (!string.IsNullOrEmpty(taskName))
                {
                    ExWatson.AddExtraData("Task Name: " + taskName);
                }
                if (boundParameters != null)
                {
                    StringBuilder stringBuilder = new StringBuilder("Parameters:\n");
                    foreach (object obj in boundParameters)
                    {
                        DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                        if (dictionaryEntry.Value is IList)
                        {
                            stringBuilder.AppendLine(string.Format("{0}:{1}", dictionaryEntry.Key, MultiValuedPropertyBase.FormatMultiValuedProperty(dictionaryEntry.Value as IList)));
                        }
                        else
                        {
                            stringBuilder.AppendLine(string.Format("{0}:'{1}'", dictionaryEntry.Key, (dictionaryEntry.Value == null) ? "<null>" : dictionaryEntry.Value.ToString()));
                        }
                    }
                    ExWatson.AddExtraData(stringBuilder.ToString());
                }
                ExWatson.SendReport(e, ReportOptions.DoNotFreezeThreads, null);
            }
            try
            {
                TaskLogger.ResumeFileLogging();
            }
            catch (IOException)
            {
                if (TaskLogger.IsFileLoggingEnabled)
                {
                    TaskLogger.LogErrorString(Strings.ExchangeSetupCannotResumeLog(ConfigurationContext.Setup.SetupLogFileName));
                }
                throw;
            }
        }
예제 #11
0
 // Token: 0x0600003C RID: 60 RVA: 0x000031D0 File Offset: 0x000013D0
 public static void SendWatsonReport(Exception e)
 {
     TaskLogger.SendWatsonReport(e, null, null);
 }