private void SetContext(DataPortalContext context) { _oldLocation = ApplicationContext.LogicalExecutionLocation; ApplicationContext.SetLogicalExecutionLocation(ApplicationContext.LogicalExecutionLocations.Server); if (!context.IsRemotePortal && ApplicationContext.ClientContext != null) { // local data portal and if context already exists, // then use existing context (from AsyncLocal or TLS) ApplicationContext.SetContext(context.ClientContext); } // if the dataportal is not remote then // do nothing if (!context.IsRemotePortal) { return; } // set the context value so everyone knows the // code is running on the server ApplicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); // set the app context to the value we got from the // client ApplicationContext.SetContext(context.ClientContext); // set the thread's culture to match the client System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(context.ClientCulture); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(context.ClientUICulture); if (ApplicationContext.AuthenticationType == "Windows") { // When using integrated security, Principal must be null if (context.Principal != null) { Csla.Security.SecurityException ex = new Csla.Security.SecurityException(Resources.NoPrincipalAllowedException); //ex.Action = System.Security.Permissions.SecurityAction.Deny; throw ex; } // Set .NET to use integrated security AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); } else { // We expect the some Principal object if (context.Principal == null) { Csla.Security.SecurityException ex = new Csla.Security.SecurityException( Resources.BusinessPrincipalException + " Nothing"); //ex.Action = System.Security.Permissions.SecurityAction.Deny; throw ex; } ApplicationContext.User = context.Principal; } }
private void SetContext(DataPortalContext context) { _oldLocation = ApplicationContext.LogicalExecutionLocation; ApplicationContext.SetLogicalExecutionLocation(ApplicationContext.LogicalExecutionLocations.Server); if (context.IsRemotePortal) { // indicate that the code is physically running on the server ApplicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); } // set the app context to the value we got from the caller ApplicationContext.SetContext(context.ClientContext); // set the thread's culture to match the caller SetCulture(context); // set current user principal SetPrincipal(context); }
private void SetContext(DataPortalContext context) { _oldLocation = Csla.ApplicationContext.LogicalExecutionLocation; ApplicationContext.SetLogicalExecutionLocation(ApplicationContext.LogicalExecutionLocations.Server); // if the dataportal is not remote then // do nothing if (!context.IsRemotePortal) { return; } // set the context value so everyone knows the // code is running on the server ApplicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); // set the app context to the value we got from the // client ApplicationContext.SetContext(context.ClientContext, context.GlobalContext); // set the thread's culture to match the client #if !PCL46 // rely on NuGet bait-and-switch for actual implementation #if NETCORE System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo(context.ClientCulture); System.Globalization.CultureInfo.CurrentUICulture = new System.Globalization.CultureInfo(context.ClientUICulture); #elif NETFX_CORE var list = new System.Collections.ObjectModel.ReadOnlyCollection <string>(new List <string> { context.ClientUICulture }); Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Languages = list; list = new System.Collections.ObjectModel.ReadOnlyCollection <string>(new List <string> { context.ClientCulture }); Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Languages = list; #else System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(context.ClientCulture); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(context.ClientUICulture); #endif #endif if (ApplicationContext.AuthenticationType == "Windows") { // When using integrated security, Principal must be null if (context.Principal != null) { Csla.Security.SecurityException ex = new Csla.Security.SecurityException(Resources.NoPrincipalAllowedException); //ex.Action = System.Security.Permissions.SecurityAction.Deny; throw ex; } #if !(ANDROID || IOS) && !NETFX_CORE // Set .NET to use integrated security AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); #endif } else { // We expect the some Principal object if (context.Principal == null) { Csla.Security.SecurityException ex = new Csla.Security.SecurityException( Resources.BusinessPrincipalException + " Nothing"); //ex.Action = System.Security.Permissions.SecurityAction.Deny; throw ex; } ApplicationContext.User = context.Principal; } }
private void SetContext(DataPortalContext context) { _oldLocation = Csla.ApplicationContext.LogicalExecutionLocation; ApplicationContext.SetLogicalExecutionLocation(ApplicationContext.LogicalExecutionLocations.Server); // if the dataportal is not remote then // do nothing if (!context.IsRemotePortal) return; // set the context value so everyone knows the // code is running on the server ApplicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); // set the app context to the value we got from the // client ApplicationContext.SetContext(context.ClientContext, context.GlobalContext); // set the thread's culture to match the client #if NETFX_CORE var list = new System.Collections.ObjectModel.ReadOnlyCollection<string>(new List<string> { context.ClientUICulture }); Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Languages = list; list = new System.Collections.ObjectModel.ReadOnlyCollection<string>(new List<string> { context.ClientCulture }); Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Languages = list; #else System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(context.ClientCulture); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(context.ClientUICulture); #endif if (ApplicationContext.AuthenticationType == "Windows") { // When using integrated security, Principal must be null if (context.Principal != null) { Csla.Security.SecurityException ex = new Csla.Security.SecurityException(Resources.NoPrincipalAllowedException); //ex.Action = System.Security.Permissions.SecurityAction.Deny; throw ex; } #if !SILVERLIGHT && !NETFX_CORE // Set .NET to use integrated security AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); #endif } else { // We expect the some Principal object if (context.Principal == null) { Csla.Security.SecurityException ex = new Csla.Security.SecurityException( Resources.BusinessPrincipalException + " Nothing"); //ex.Action = System.Security.Permissions.SecurityAction.Deny; throw ex; } ApplicationContext.User = context.Principal; } }