Example #1
0
        protected ADServerSettings CreateADServerSettingsForOrganization(bool useDCInAnySite = false)
        {
            ISessionState sessionState = this.CurrentTaskContext.SessionState;
            bool          flag         = false;

            if (sessionState != null)
            {
                flag = ExchangePropertyContainer.IsContainerInitialized(sessionState);
            }
            OrganizationId orgId = null;

            if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsCmdletInvokedWithoutPSFramework && this.CurrentTaskContext.UserInfo != null)
            {
                orgId = this.CurrentTaskContext.UserInfo.CurrentOrganizationId;
            }
            else if (flag)
            {
                ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(sessionState);
                if (exchangeRunspaceConfiguration != null)
                {
                    orgId = exchangeRunspaceConfiguration.OrganizationId;
                }
            }
            return(this.CreateServerSettings(orgId, useDCInAnySite));
        }
Example #2
0
        internal static Uri GetOriginalConnectionUri(ISessionState sessionState)
        {
            ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(sessionState);

            if (exchangeRunspaceConfiguration == null || exchangeRunspaceConfiguration.ConfigurationSettings == null)
            {
                return(null);
            }
            return(exchangeRunspaceConfiguration.ConfigurationSettings.OriginalConnectionUri);
        }
Example #3
0
        internal static string GetPodRedirectionTemplate(ISessionState sessionState)
        {
            ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(sessionState);

            if (exchangeRunspaceConfiguration == null || exchangeRunspaceConfiguration.ConfigurationSettings == null)
            {
                return(null);
            }
            return(exchangeRunspaceConfiguration.ConfigurationSettings.PodRedirectionTemplate);
        }
Example #4
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);
        }
Example #5
0
 private void CheckVerboseDebugParameter()
 {
     if (this.context.SessionState != null && ExchangePropertyContainer.IsContainerInitialized(this.context.SessionState))
     {
         ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(this.context.SessionState);
         if (exchangeRunspaceConfiguration != null && this.context.InvocationInfo != null)
         {
             if (!exchangeRunspaceConfiguration.IsVerboseEnabled(this.context.InvocationInfo.CommandName))
             {
                 this.verboseDisabled = true;
                 TaskLogger.Trace("The cmdlet does not have Verbose parameter by RBAC check. WriteVerbose is disabled.", new object[0]);
             }
             if (!exchangeRunspaceConfiguration.IsDebugEnabled(this.context.InvocationInfo.CommandName))
             {
                 this.debugDisabled = true;
                 TaskLogger.Trace("The cmdlet does not have Debug parameter by RBAC check. WriteDebug is disabled.", new object[0]);
             }
         }
     }
 }