// Token: 0x06000E72 RID: 3698 RVA: 0x00056DA0 File Offset: 0x00054FA0
        public static AssistantRunspaceProxy CreateRunspaceForTenantAdmin(ADObjectId ownerId, ADUser tenantAdmin)
        {
            ArgumentValidator.ThrowIfNull("tenantAdmin", tenantAdmin);
            ArgumentValidator.ThrowIfNull("ownerId", ownerId);
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown, null, ExchangeRunspaceConfigurationSettings.SerializationLevel.None);

            return(new AssistantRunspaceProxy(AssistantRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(tenantAdmin.OrganizationId, new GenericSidIdentity(tenantAdmin.Name, string.Empty, tenantAdmin.Sid), configSettings)));
        }
        // Token: 0x06000E73 RID: 3699 RVA: 0x00056DF4 File Offset: 0x00054FF4
        public static AssistantRunspaceProxy CreateRunspaceForPartner(ADObjectId ownerId, ADUser tenantAdmin, string tenantOrganization, IPublicFolderMailboxLoggerBase logger)
        {
            ArgumentValidator.ThrowIfNull("ownerId", ownerId);
            ArgumentValidator.ThrowIfNull("tenantAdmin", tenantAdmin);
            ArgumentValidator.ThrowIfNullOrEmpty("tenantOrganization", tenantOrganization);
            logger.LogEvent(LogEventType.Verbose, string.Format("AssistantRunspaceProxy. Creating partner runspace proxy for user {0}", tenantAdmin.Name));
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, tenantOrganization, ExchangeRunspaceConfigurationSettings.GetDefaultInstance().CurrentSerializationLevel);

            return(new AssistantRunspaceProxy(AssistantRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(tenantAdmin.OrganizationId, new GenericSidIdentity(tenantAdmin.Name, string.Empty, tenantAdmin.Sid), configSettings)));
        }
Exemplo n.º 3
0
        public static AnchorRunspaceProxy CreateRunspaceForDelegatedTenantAdmin(AnchorContext context, DelegatedPrincipal delegatedTenantAdmin)
        {
            AnchorUtil.ThrowOnNullArgument(delegatedTenantAdmin, "delegatedTenantAdmin");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating delegated runspace proxy for user {0}", new object[]
            {
                delegatedTenantAdmin
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, null, ExchangeRunspaceConfigurationSettings.SerializationLevel.None);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, delegatedTenantAdmin.ToString(), delegatedTenantAdmin.Identity, configSettings)));
        }
Exemplo n.º 4
0
        public static AnchorRunspaceProxy CreateRunspaceForDelegatedPartner(AnchorContext context, DelegatedPrincipal delegatedPartnerAdmin, string tenantOrganization)
        {
            AnchorUtil.ThrowOnNullArgument(delegatedPartnerAdmin, "delegatedTenantAdmin");
            AnchorUtil.ThrowOnNullOrEmptyArgument(tenantOrganization, "tenantOrganization");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating delegated partner runspace proxy for user {0}", new object[]
            {
                delegatedPartnerAdmin
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, tenantOrganization, ExchangeRunspaceConfigurationSettings.GetDefaultInstance().CurrentSerializationLevel);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, delegatedPartnerAdmin.ToString(), delegatedPartnerAdmin.Identity, configSettings)));
        }
Exemplo n.º 5
0
        public static AnchorRunspaceProxy CreateRunspaceForTenantAdmin(AnchorContext context, ADObjectId ownerId, ADUser tenantAdmin)
        {
            AnchorUtil.ThrowOnNullArgument(tenantAdmin, "tenantAdmin");
            AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating runspace proxy for user {0}", new object[]
            {
                tenantAdmin.Name
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, null, ExchangeRunspaceConfigurationSettings.SerializationLevel.None);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, ownerId.ToString(), new GenericSidIdentity(tenantAdmin.Name, string.Empty, tenantAdmin.Sid), configSettings)));
        }
Exemplo n.º 6
0
        internal static Uri BuildCmdletProxyUri(string targetFqdn, ExchangeRunspaceConfiguration runspaceConfig, int targetVersion)
        {
            if (string.IsNullOrWhiteSpace(targetFqdn))
            {
                throw new ArgumentNullException("targetFqdn");
            }
            if (runspaceConfig == null)
            {
                throw new ArgumentNullException("runspaceConfig");
            }
            ExchangeRunspaceConfigurationSettings configurationSettings = runspaceConfig.ConfigurationSettings;

            ExAssert.RetailAssert(configurationSettings != null, "runspaceConfig.ConfigurationSettings should not be null.");
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("https://");
            stringBuilder.Append(targetFqdn);
            if (targetVersion >= Server.E15MinVersion)
            {
                stringBuilder.Append(":444/powershell/Powershell-proxy?");
            }
            else
            {
                stringBuilder.Append("/Powershell-proxy?");
            }
            stringBuilder.AppendFormat("{0}={1}", "X-Rps-CAT", Uri.EscapeDataString(configurationSettings.UserToken.CommonAccessTokenForCmdletProxy().Serialize()));
            stringBuilder.AppendFormat(";{0}={1}", "serializationLevel", configurationSettings.CurrentSerializationLevel.ToString());
            stringBuilder.AppendFormat(";{0}={1}", "clientApplication", configurationSettings.ClientApplication.ToString());
            if (configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.ECP || configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.EMC || configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.OSP)
            {
                stringBuilder.AppendFormat(";{0}={1}", "proxyFullSerialization", "true");
            }
            string managedOrganization = ProxyHelper.GetManagedOrganization(runspaceConfig);

            if (!string.IsNullOrEmpty(managedOrganization))
            {
                stringBuilder.AppendFormat(";{0}", ProxyHelper.GetOrganizationAppendQueryIfNeeded(managedOrganization));
            }
            stringBuilder.AppendFormat(";{0}={1}", WellKnownHeader.CmdletProxyIsOn, "99C6ECEE-5A4F-47B9-AE69-49EAFB58F368");
            IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope();

            if (currentActivityScope != null && currentActivityScope.ActivityId != Guid.Empty)
            {
                stringBuilder.AppendFormat(";{0}={1}", "RequestId48CD6591-0506-4D6E-9131-797489A3260F", currentActivityScope.ActivityId);
            }
            return(new Uri(stringBuilder.ToString()));
        }
Exemplo n.º 7
0
        internal static NameValueCollection GetPSWSProxyRequestHeaders(ExchangeRunspaceConfiguration runspaceConfig)
        {
            ExchangeRunspaceConfigurationSettings configurationSettings = runspaceConfig.ConfigurationSettings;

            ExAssert.RetailAssert(configurationSettings != null, "runspaceConfig.ConfigurationSettings should not be null.");
            NameValueCollection nameValueCollection = new NameValueCollection();

            nameValueCollection["X-CommonAccessToken"]           = configurationSettings.UserToken.CommonAccessTokenForCmdletProxy().Serialize();
            nameValueCollection["serializationLevel"]            = configurationSettings.CurrentSerializationLevel.ToString();
            nameValueCollection["clientApplication"]             = configurationSettings.ClientApplication.ToString();
            nameValueCollection["X-EncodeDecode-Key"]            = "false";
            nameValueCollection[WellKnownHeader.CmdletProxyIsOn] = "99C6ECEE-5A4F-47B9-AE69-49EAFB58F368";
            if (configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.ECP || configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.EMC || configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.OSP)
            {
                nameValueCollection["proxyFullSerialization"] = "true";
            }
            string managedOrganization = ProxyHelper.GetManagedOrganization(runspaceConfig);

            if (!string.IsNullOrEmpty(managedOrganization))
            {
                nameValueCollection["organization"] = managedOrganization;
            }
            return(nameValueCollection);
        }
Exemplo n.º 8
0
            public static AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity CreateRbacFactory(AnchorContext context, string affinityToken, IIdentity tenantIdentity, ExchangeRunspaceConfigurationSettings configSettings)
            {
                InitialSessionState initialSessionState;

                try
                {
                    initialSessionState = new ExchangeExpiringRunspaceConfiguration(tenantIdentity, configSettings).CreateInitialSessionState();
                    initialSessionState.LanguageMode = PSLanguageMode.FullLanguage;
                }
                catch (CmdletAccessDeniedException ex)
                {
                    context.Logger.Log(MigrationEventType.Warning, ex, "AnchorRunspaceProxy. error creating session for user {0}", new object[]
                    {
                        tenantIdentity
                    });
                    throw new UserDoesNotHaveRBACException(tenantIdentity.ToString(), ex);
                }
                catch (AuthzException ex2)
                {
                    context.Logger.Log(MigrationEventType.Error, ex2, "AnchorRunspaceProxy. authorization error creating session for user {0}", new object[]
                    {
                        tenantIdentity
                    });
                    throw new UserDoesNotHaveRBACException(tenantIdentity.ToString(), ex2);
                }
                return(new AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity(affinityToken, new BasicInitialSessionStateFactory(initialSessionState), new BasicPSHostFactory(typeof(RunspaceHost), true)));
            }
            // Token: 0x06000E80 RID: 3712 RVA: 0x000572B8 File Offset: 0x000554B8
            public static AssistantRunspaceProxy.RunspaceFactoryWithDCAffinity CreateRbacFactory(OrganizationId organizationId, IIdentity tenantIdentity, ExchangeRunspaceConfigurationSettings configSettings)
            {
                InitialSessionState initialSessionState;

                try
                {
                    initialSessionState = new ExchangeExpiringRunspaceConfiguration(tenantIdentity, configSettings).CreateInitialSessionState();
                    initialSessionState.LanguageMode = PSLanguageMode.FullLanguage;
                }
                catch (CmdletAccessDeniedException innerException)
                {
                    throw new UserDoesNotHaveRBACException(tenantIdentity.ToString(), innerException);
                }
                catch (AuthzException innerException2)
                {
                    throw new UserDoesNotHaveRBACException(tenantIdentity.ToString(), innerException2);
                }
                return(new AssistantRunspaceProxy.RunspaceFactoryWithDCAffinity(organizationId, new BasicInitialSessionStateFactory(initialSessionState), new BasicPSHostFactory(typeof(RunspaceHost), true)));
            }
Exemplo n.º 10
0
        private RbacPrincipal CreateRbacPrincipal(IIdentity identity, string tenantDomain, string cacheKey, HttpContext httpContext)
        {
            ExTraceGlobals.ReportingWebServiceTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] Create RbacPrincipal. Identity: {0}; tenantDomain: {1}; cacheKey: '{2}'", identity.GetSafeName(true), tenantDomain ?? string.Empty, cacheKey);
            ExchangeRunspaceConfigurationSettings rbacSettings = null;

            ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.NewExchangeRunspaceConfigurationSettingsLatency, delegate
            {
                rbacSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.ReportingWebService, tenantDomain, ExchangeRunspaceConfigurationSettings.SerializationLevel.None);
            });
            ReportingSchema schema = ReportingSchema.GetCurrentReportingSchema(httpContext);

            try
            {
                RequestStatistics requestStatistics = HttpContext.Current.Items[RequestStatistics.RequestStatsKey] as RequestStatistics;
                if (requestStatistics != null)
                {
                    requestStatistics.AddExtendedStatisticsDataPoint("AuthType", identity.AuthenticationType);
                }
                using (new AverageTimePerfCounter(RwsPerfCounters.AverageRbacPrincipalCreation, RwsPerfCounters.AverageRbacPrincipalCreationBase, true))
                {
                    RwsExchangeRunspaceConfiguration rbacConfiguration = null;
                    ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.NewRwsExchangeRunspaceConfigurationLatency, delegate
                    {
                        rbacConfiguration = RwsExchangeRunspaceConfiguration.NewInstance(identity, rbacSettings, schema.CmdletFilter, this.GetSnapinSet());
                    });
                    RbacPrincipal rbacPrincipal = null;
                    ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.NewRbacPrincipalLatency, delegate
                    {
                        rbacPrincipal = new RbacPrincipal(rbacConfiguration, cacheKey);
                    });
                    return(rbacPrincipal);
                }
            }
            catch (CmdletAccessDeniedException ex)
            {
                HttpRuntime.Cache.Remove(cacheKey);
                ExTraceGlobals.ReportingWebServiceTracer.TraceError <CmdletAccessDeniedException>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] CmdletAccessDeniedException: {0}", ex);
                ServiceDiagnostics.ThrowError(ReportingErrorCode.ErrorTenantNotInOrgScope, Strings.ErrorTenantNotInOrgScope(tenantDomain), ex);
            }
            catch (CannotResolveTenantNameException ex2)
            {
                HttpRuntime.Cache.Remove(cacheKey);
                ExTraceGlobals.ReportingWebServiceTracer.TraceError <CannotResolveTenantNameException>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] CannotResolveTenantNameException: {0}", ex2);
                ServiceDiagnostics.ThrowError(ReportingErrorCode.ErrorTenantNotResolved, Strings.ErrorTenantNotResolved(tenantDomain), ex2);
            }
            catch (ADTransientException ex3)
            {
                HttpRuntime.Cache.Remove(cacheKey);
                ExTraceGlobals.ReportingWebServiceTracer.TraceError <ADTransientException>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] ADTransientException: {0}", ex3);
                ServiceDiagnostics.ThrowError(ReportingErrorCode.ADTransientError, Strings.ADTransientError, ex3);
            }
            catch (DataSourceOperationException ex4)
            {
                HttpRuntime.Cache.Remove(cacheKey);
                ExTraceGlobals.ReportingWebServiceTracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] DataSourceOperationException: {0}", ex4);
                ServiceDiagnostics.ThrowError(ReportingErrorCode.ADOperationError, Strings.ADOperationError, ex4);
            }
            catch (TimeoutException ex5)
            {
                HttpRuntime.Cache.Remove(cacheKey);
                ExTraceGlobals.ReportingWebServiceTracer.TraceError <TimeoutException>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] TimeoutException: {0}", ex5);
                ServiceDiagnostics.ThrowError(ReportingErrorCode.CreateRunspaceConfigTimeoutError, Strings.CreateRunspaceConfigTimeoutError, ex5);
            }
            catch (Exception ex6)
            {
                HttpRuntime.Cache.Remove(cacheKey);
                ExTraceGlobals.ReportingWebServiceTracer.TraceError <Exception>((long)this.GetHashCode(), "[RbacPrincipalManager::CreateRbacPrincipal] Exception: {0}", ex6);
                ServiceDiagnostics.ThrowError(ReportingErrorCode.UnknownError, Strings.UnknownError, ex6);
            }
            return(null);
        }