示例#1
0
 // Token: 0x06001675 RID: 5749 RVA: 0x00055040 File Offset: 0x00053240
 private void PersistNewServerSettings(ADServerSettings newServerSettings)
 {
     if (newServerSettings != null)
     {
         ADSessionSettings.ClearThreadADContext();
         LocalizedString adserverSettings;
         if (CmdletLogHelper.NeedConvertLogMessageToUS)
         {
             adserverSettings = TaskVerboseStringHelper.GetADServerSettings(this.context.InvocationInfo.CommandName, newServerSettings, CmdletLogHelper.DefaultLoggingCulture);
         }
         else
         {
             adserverSettings = TaskVerboseStringHelper.GetADServerSettings(this.context.InvocationInfo.CommandName, newServerSettings);
         }
         if (this.context.SessionState != null)
         {
             CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-FailOver", adserverSettings);
             ExchangePropertyContainer.SetServerSettings(this.context.SessionState, newServerSettings);
         }
         else
         {
             CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-NOTFailOver-SessionStateNull", adserverSettings);
         }
         ADSessionSettings.SetThreadADContext(new ADDriverContext(newServerSettings, ContextMode.Cmdlet));
         this.context.ServerSettingsAfterFailOver = newServerSettings;
         this.context.CommandShell.WriteWarning(DirectoryStrings.RunspaceServerSettingsChanged);
         return;
     }
     CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "ADServerSettings-NOTFailOver-ServerSettingsNull", "NULL");
 }
示例#2
0
        private static void BuildDictionary(StringBuilder builder, IDictionary dictionary)
        {
            builder.Append("@{");
            bool flag = false;

            foreach (object obj in dictionary)
            {
                DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                if (flag)
                {
                    builder.Append(';');
                }
                builder.Append(dictionaryEntry.Key);
                builder.Append('=');
                ICollection collection = dictionaryEntry.Value as ICollection;
                if (collection != null)
                {
                    TaskVerboseStringHelper.BuildCollection(builder, collection);
                }
                else
                {
                    TaskVerboseStringHelper.BuildSingleValue(builder, dictionaryEntry.Value);
                }
                flag = true;
            }
            builder.Append('}');
        }
示例#3
0
 private void SetScopeSet(object sender, EventArgs e)
 {
     if (!this.context.CanBypassRBACScope)
     {
         string   exchangeCmdletName = "";
         string[] array = null;
         if (this.context.InvocationInfo != null)
         {
             exchangeCmdletName = this.context.InvocationInfo.CommandName;
             array = this.FilterVerboseDebugParameter(this.context.InvocationInfo.UserSpecifiedParameters.Keys);
         }
         if (this.context.ExchangeRunspaceConfig != null && this.context.ExchangeRunspaceConfig.ConfigurationSettings.IsProxy)
         {
             array = (from val in array
                      where !ClientRoleEntries.ParametersForProxy.Contains(val)
                      select val).ToArray <string>();
         }
         if (this.context.ExchangeRunspaceConfig != null && this.context.UserInfo != null && this.context.CommandShell != null)
         {
             this.context.ScopeSet = this.context.ExchangeRunspaceConfig.CalculateScopeSetForExchangeCmdlet(exchangeCmdletName, array, this.context.UserInfo.CurrentOrganizationId, new Task.ErrorLoggerDelegate(this.context.CommandShell.WriteError));
         }
         if (this.context.InvocationInfo != null && this.context.InvocationInfo.IsVerboseOn && !TaskLogger.IsSetupLogging)
         {
             this.context.CommandShell.WriteVerbose(TaskVerboseStringHelper.GetScopeSetVerboseString(this.context.ScopeSet));
         }
     }
     this.CheckForExpiredSession();
 }
示例#4
0
        protected virtual IEnumerable <TDataObject> GetPagedData()
        {
            QueryFilter internalFilter = this.InternalFilter;

            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), internalFilter, this.RootId, this.DeepSearch));
            return(base.DataSession.FindPaged <TDataObject>(internalFilter, this.RootId, this.DeepSearch, this.InternalSortBy, this.PageSize));
        }
 // Token: 0x06000560 RID: 1376 RVA: 0x00014AD4 File Offset: 0x00012CD4
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.Identity,
         this.DataObject
     });
     base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.dataObject.Identity, base.DataSession, typeof(TDataObject)));
     try
     {
         if (this.ShouldSoftDeleteObject())
         {
             this.SaveSoftDeletedObject();
         }
         else
         {
             base.DataSession.Delete(this.dataObject);
         }
     }
     catch (DataSourceTransientException exception)
     {
         base.WriteError(exception, (ErrorCategory)1002, null);
     }
     finally
     {
         base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
     }
     TaskLogger.LogExit();
 }
示例#6
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            IEnumerable <TDataObject> enumerable = null;

            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), this.InternalFilter, this.RootId, this.DeepSearch));
            try
            {
                enumerable = base.DataSession.FindPaged <TDataObject>(this.InternalFilter, this.RootId, this.DeepSearch, null, 0);
            }
            catch (DataSourceTransientException exception)
            {
                base.WriteError(exception, (ErrorCategory)1002, null);
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            if (enumerable == null)
            {
                base.WriteError(new ManagementObjectNotFoundException(Strings.ExceptionObjectNotFound(typeof(TDataObject).ToString())), (ErrorCategory)1003, null);
            }
            IConfigurable configurable = null;

            using (IEnumerator <TDataObject> enumerator = enumerable.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    configurable = enumerator.Current;
                    if (enumerator.MoveNext())
                    {
                        base.WriteError(new ManagementObjectAmbiguousException(Strings.ExceptionObjectAmbiguous(typeof(TDataObject).ToString())), (ErrorCategory)1003, null);
                    }
                }
                else
                {
                    base.WriteError(new ManagementObjectNotFoundException(Strings.ExceptionObjectNotFound(typeof(TDataObject).ToString())), (ErrorCategory)1003, null);
                }
            }
            ADObject adobject = configurable as ADObject;

            if (adobject != null)
            {
                base.CurrentOrganizationId = adobject.OrganizationId;
            }
            if (base.CurrentObjectIndex == 0)
            {
                this.ResolveLocalSecondaryIdentities();
                if (base.HasErrors)
                {
                    return(null);
                }
            }
            TaskLogger.LogExit();
            return(configurable);
        }
 // 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()));
     }
 }
示例#8
0
 private static void BuildSingleValue(StringBuilder builder, object singleValue)
 {
     if (singleValue == null)
     {
         builder.Append("$null");
         return;
     }
     builder.Append("\"");
     builder.Append(TaskVerboseStringHelper.TruncateString(singleValue.ToString(), 200));
     builder.Append("\"");
 }
示例#9
0
        protected virtual void WriteResult <T>(IEnumerable <T> dataObjects) where T : IConfigurable
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObjects
            });
            if (dataObjects != null)
            {
                using (IEnumerator <T> enumerator = dataObjects.GetEnumerator())
                {
                    bool flag = false;
                    if (!base.Stopping)
                    {
                        if (!this.InternalResultSize.IsUnlimited)
                        {
                            if (this.InternalResultSize.Value < this.matchCount)
                            {
                                goto IL_163;
                            }
                        }
                        try
                        {
                            flag = enumerator.MoveNext();
                        }
                        finally
                        {
                            base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
                        }
                        base.WriteVerbose(Strings.VerboseWriteResultSize(this.InternalResultSize.ToString()));
                    }
IL_163:
                    while (!base.Stopping && (this.InternalResultSize.IsUnlimited || this.InternalResultSize.Value >= this.matchCount) && flag)
                    {
                        if (!this.InternalResultSize.IsUnlimited && this.InternalResultSize.Value == this.matchCount + 1U && this.pageInfo != null && this.pageInfo.MorePagesAvailable != null && this.pageInfo.MorePagesAvailable.Value)
                        {
                            this.WriteResult(enumerator.Current);
                        }
                        IConfigurable dataObject = enumerator.Current;
                        this.WriteResult(dataObject);
                        if (!base.Stopping && (this.InternalResultSize.IsUnlimited || this.InternalResultSize.Value >= this.matchCount))
                        {
                            if (this.pageInfo != null)
                            {
                                this.AdjustPageSize(this.pageInfo);
                            }
                            flag = enumerator.MoveNext();
                        }
                    }
                }
            }
            TaskLogger.LogExit();
        }
示例#10
0
        // Token: 0x060003DF RID: 991 RVA: 0x0000E768 File Offset: 0x0000C968
        protected override void WriteResult(IConfigurable dataObject)
        {
            TaskLogger.LogEnter();
            IDirectorySession directorySession = base.DataSession as IDirectorySession;
            IConfigurable     configurable     = dataObject;

            if (this.ReadFromDomainController.IsPresent && directorySession != null && directorySession.UseGlobalCatalog)
            {
                try
                {
                    directorySession.UseGlobalCatalog = false;
                    base.WriteVerbose(Strings.VerboseRereadADObject(dataObject.Identity.ToString(), typeof(TDataObject).Name, ((ADObjectId)dataObject.Identity).ToDNString()));
                    configurable = base.DataSession.Read <TDataObject>(dataObject.Identity);
                    base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
                }
                finally
                {
                    directorySession.UseGlobalCatalog = true;
                }
            }
            ADRecipient adrecipient = configurable as ADRecipient;

            if (adrecipient != null)
            {
                adrecipient.PopulateAcceptMessagesOnlyFromSendersOrMembers();
                adrecipient.PopulateBypassModerationFromSendersOrMembers();
                adrecipient.PopulateRejectMessagesFromSendersOrMembers();
                GetRecipientObjectTask <TIdentity, TDataObject> .SanitizeMailTips(adrecipient);
            }
            if (configurable == null)
            {
                base.WriteVerbose(Strings.VerboseFailedToReadFromDC(dataObject.Identity.ToString(), base.DataSession.Source));
            }
            else if (this.ShouldSkipObject(configurable))
            {
                base.WriteVerbose(Strings.VerboseSkipObject(configurable.Identity.ToString()));
            }
            else
            {
                IConfigurable configurable2 = this.ConvertDataObjectToPresentationObject(configurable);
                if (this.ShouldSkipPresentationObject(configurable2))
                {
                    base.WriteVerbose(Strings.VerboseSkipObject(configurable.Identity.ToString()));
                }
                else
                {
                    base.WriteResult(configurable2);
                }
            }
            TaskLogger.LogExit();
        }
 // Token: 0x060005AE RID: 1454 RVA: 0x000157D0 File Offset: 0x000139D0
 protected override void InternalProcessRecord()
 {
     if (base.IsVerboseOn)
     {
         if (this.IsObjectStateChanged())
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(this.DataObject));
         }
         else
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectNonChangedProperties(this.DataObject));
         }
     }
     base.InternalProcessRecord();
 }
示例#12
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            TDataObject       dataObject        = this.DataObject;
            ADObjectId        parent            = dataObject.Id.Parent;
            ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(parent);

            if (!parent.Equals(ADSession.GetRootDomainNamingContext(adsessionSettings.GetAccountOrResourceForestFqdn())))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 264, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                ADRawEntry adrawEntry = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion,
                    ADObjectSchema.ObjectClass
                });
                if (adrawEntry == null)
                {
                    if (string.IsNullOrEmpty(base.DomainController))
                    {
                        TDataObject dataObject2 = this.DataObject;
                        base.WriteError(new TaskException(Strings.ErrorParentNotFound(dataObject2.Name, parent.ToString())), (ErrorCategory)1003, null);
                    }
                    else
                    {
                        TDataObject dataObject3 = this.DataObject;
                        base.WriteError(new TaskException(Strings.ErrorParentNotFoundOnDomainController(dataObject3.Name, base.DomainController, parent.ToString(), parent.DomainId.ToString())), (ErrorCategory)1003, null);
                    }
                }
                ExchangeObjectVersion        exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                MultiValuedProperty <string> multiValuedProperty   = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass];
                TDataObject dataObject4 = this.DataObject;
                if (dataObject4.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass) && this.EnforceExchangeObjectVersion)
                {
                    TDataObject dataObject5 = this.DataObject;
                    string      name        = dataObject5.Name;
                    TDataObject dataObject6 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject6.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(this.DataObject));
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
示例#13
0
        protected IEnumerable <TObject> GetDataObjects <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where TObject : IConfigurable, new()
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            notFoundReason = null;
            base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(id, session ?? this.DataSession, typeof(TObject), rootID));
            IEnumerable <TObject> objects;

            try
            {
                objects = id.GetObjects <TObject>(rootID, session ?? this.DataSession, optionalData, out notFoundReason);
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(session ?? this.DataSession));
            }
            return(objects);
        }
示例#14
0
        protected virtual void WriteResult()
        {
            object[]    array      = new object[1];
            object[]    array2     = array;
            int         num        = 0;
            TDataObject dataObject = this.DataObject;

            array2[num] = dataObject.Identity;
            TaskLogger.LogEnter(array);
            TDataObject dataObject2 = this.DataObject;

            base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(dataObject2.Identity, base.DataSession, typeof(TDataObject)));
            IConfigurable configurable = null;

            try
            {
                using (TaskPerformanceData.ReadResult.StartRequestTimer())
                {
                    IConfigDataProvider dataSession = base.DataSession;
                    TDataObject         dataObject3 = this.DataObject;
                    configurable = dataSession.Read <TDataObject>(dataObject3.Identity);
                }
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            if (configurable == null)
            {
                TDataObject   dataObject4 = this.DataObject;
                Exception     exception   = new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(dataObject4.Identity), typeof(TDataObject).ToString(), (base.DataSession != null) ? base.DataSession.Source : null));
                ErrorCategory category    = (ErrorCategory)1003;
                TDataObject   dataObject5 = this.DataObject;
                base.WriteError(exception, category, dataObject5.Identity);
            }
            using (TaskPerformanceData.WriteResult.StartRequestTimer())
            {
                this.WriteResult(configurable);
            }
            TaskLogger.LogExit();
        }
示例#15
0
 private void SetScopeSet(object sender, EventArgs e)
 {
     if (this.CurrentTaskContext.CanBypassRBACScope)
     {
         if (this.CurrentTaskContext.UserInfo != null)
         {
             if (this.CurrentTaskContext.UserInfo.CurrentOrganizationId != null)
             {
                 this.CurrentTaskContext.ScopeSet = ScopeSet.GetOrgWideDefaultScopeSet(this.CurrentTaskContext.UserInfo.CurrentOrganizationId);
             }
             else
             {
                 this.CurrentTaskContext.ScopeSet = ScopeSet.GetOrgWideDefaultScopeSet(this.CurrentTaskContext.UserInfo.ExecutingUserOrganizationId);
             }
         }
         if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn && !TaskLogger.IsSetupLogging)
         {
             this.CurrentTaskContext.CommandShell.WriteVerbose(TaskVerboseStringHelper.GetScopeSetVerboseString(this.CurrentTaskContext.ScopeSet));
         }
     }
 }
        // Token: 0x060005D8 RID: 1496 RVA: 0x000163E4 File Offset: 0x000145E4
        protected override IConfigurable ResolveDataObject()
        {
            TaskLogger.LogEnter();
            IConfigurable[] array = null;
            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), this.InternalFilter, this.RootId, this.DeepSearch));
            try
            {
                array = base.DataSession.Find <TDataObject>(this.InternalFilter, this.RootId, this.DeepSearch, null);
            }
            catch (DataSourceTransientException exception)
            {
                base.WriteError(exception, (ErrorCategory)1002, null);
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            if (array == null)
            {
                array = new IConfigurable[0];
            }
            IConfigurable result = null;

            switch (array.Length)
            {
            case 0:
                base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(null, typeof(TDataObject).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, null);
                break;

            case 1:
                result = array[0];
                break;

            default:
                base.WriteError(new ManagementObjectAmbiguousException(Strings.ExceptionObjectAmbiguous(typeof(TDataObject).ToString())), (ErrorCategory)1003, null);
                break;
            }
            TaskLogger.LogExit();
            return(result);
        }
示例#17
0
        public static string FormatUserSpecifiedParameters(PropertyBag parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            StringBuilder stringBuilder = new StringBuilder(parameters.Count * 32);
            bool          flag          = false;

            foreach (object obj in parameters.Keys)
            {
                if (flag)
                {
                    stringBuilder.Append(' ');
                }
                stringBuilder.Append('-');
                stringBuilder.Append(obj);
                stringBuilder.Append(' ');
                object      obj2       = parameters[obj];
                IDictionary dictionary = obj2 as IDictionary;
                if (dictionary != null)
                {
                    TaskVerboseStringHelper.BuildDictionary(stringBuilder, dictionary);
                }
                else
                {
                    ICollection collection = obj2 as ICollection;
                    if (collection != null)
                    {
                        TaskVerboseStringHelper.BuildCollection(stringBuilder, collection);
                    }
                    else
                    {
                        TaskVerboseStringHelper.BuildSingleValue(stringBuilder, obj2);
                    }
                }
                flag = true;
            }
            return(stringBuilder.ToString());
        }
示例#18
0
        private static void BuildCollection(StringBuilder builder, ICollection collection)
        {
            byte[] array = collection as byte[];
            if (array != null)
            {
                builder.Append(TaskVerboseStringHelper.TruncateAndConvertByteArray(array, 20));
                return;
            }
            builder.Append('(');
            bool flag = false;

            foreach (object singleValue in collection)
            {
                if (flag)
                {
                    builder.Append(',');
                }
                TaskVerboseStringHelper.BuildSingleValue(builder, singleValue);
                flag = true;
            }
            builder.Append(')');
        }
示例#19
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     try
     {
         base.Validate(this.DataObject);
         if (base.HasErrors)
         {
             return;
         }
         TDataObject dataObject = this.DataObject;
         if (dataObject.Identity != null)
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.DataObject, base.DataSession, typeof(TDataObject)));
         }
         using (TaskPerformanceData.SaveResult.StartRequestTimer())
         {
             base.DataSession.Save(this.DataObject);
         }
     }
     catch (DataSourceTransientException exception)
     {
         base.WriteError(exception, (ErrorCategory)1002, null);
     }
     finally
     {
         TDataObject dataObject2 = this.DataObject;
         if (dataObject2.Identity != null)
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
         }
     }
     TaskLogger.LogExit();
 }
        // 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);
                }
            }
        }
示例#21
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);
            }
        }
示例#22
0
        public static LocalizedString GetConfigurableObjectChangedProperties(ConfigurableObject dataObject)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("dataObject");
            }
            StringBuilder stringBuilder = new StringBuilder("{ ");
            IList <PropertyDefinition> changedPropertyDefinitions = dataObject.GetChangedPropertyDefinitions();

            for (int i = 0; i < changedPropertyDefinitions.Count; i++)
            {
                if (changedPropertyDefinitions[i] != ADObjectSchema.ObjectState)
                {
                    PropertyDefinition propertyDefinition = changedPropertyDefinitions[i];
                    if (propertyDefinition != ActiveDirectoryServerSchema.AssistantMaintenanceScheduleInternal)
                    {
                        stringBuilder.Append(propertyDefinition.Name);
                        ADPropertyDefinition adpropertyDefinition = propertyDefinition as ADPropertyDefinition;
                        if (adpropertyDefinition != null)
                        {
                            stringBuilder.Append('[');
                            stringBuilder.Append(TaskVerboseStringHelper.RetrieveLDAPPropertyNames(adpropertyDefinition));
                            stringBuilder.Append(']');
                        }
                        stringBuilder.Append('=');
                        if (dataObject[propertyDefinition] is IList)
                        {
                            IList list = (IList)dataObject[propertyDefinition];
                            stringBuilder.Append("{ ");
                            for (int j = 0; j < list.Count; j++)
                            {
                                stringBuilder.Append(TaskVerboseStringHelper.FormatParameterValue(list[j]));
                                if (j + 1 < list.Count)
                                {
                                    stringBuilder.Append(", ");
                                }
                            }
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(TaskVerboseStringHelper.FormatParameterValue(dataObject[propertyDefinition]));
                        }
                        stringBuilder.Append(", ");
                    }
                }
            }
            if (stringBuilder.Length > 2)
            {
                stringBuilder.Remove(stringBuilder.Length - 2, 2);
            }
            stringBuilder.Append(" }");
            LocalizedString result = LocalizedString.Empty;

            if (dataObject.Identity != null)
            {
                ADObject adobject = dataObject as ADObject;
                if (adobject != null)
                {
                    result = Strings.VerboseADObjectChangedPropertiesWithDn(adobject.Name, adobject.Id.ToDNString(), stringBuilder.ToString());
                }
                else
                {
                    result = Strings.VerboseADObjectChangedPropertiesWithId(dataObject.Identity.ToString(), stringBuilder.ToString());
                }
            }
            else
            {
                result = Strings.VerboseADObjectChangedProperties(stringBuilder.ToString());
            }
            return(result);
        }
示例#23
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()));
                }
            }
        }
示例#24
0
 public static LocalizedString GetADServerSettings(string cmdletName, ADServerSettings serverSettings)
 {
     return(TaskVerboseStringHelper.GetADServerSettings(cmdletName, serverSettings, null));
 }
示例#25
0
 public static LocalizedString GetADServerSettings(ADServerSettings serverSettings)
 {
     return(TaskVerboseStringHelper.GetADServerSettings(null, serverSettings));
 }