internal static void DisableCmdletLog(ISessionState sessionState) { ADObjectId adobjectId = null; OrganizationId organizationId = null; ExchangePropertyContainer.InitializeExchangePropertyContainerIfNeeded(sessionState, out adobjectId, out organizationId); ExchangePropertyContainer propertyContainer = ExchangePropertyContainer.GetPropertyContainer(sessionState); propertyContainer.logEnabled = false; propertyContainer.logEntries.DecreaseIndentation(); }
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); }