예제 #1
0
        private static void SetContext(DataPortalContext context)
        {
            DistributionContext.SetLogicalExecutionLocation(DistributionContext.LogicalExecutionLocations.Server);
            if (!context.IsRemotePortal)
            {
                return;
            }
            DistributionContext.SetExecutionLocation(DistributionContext.ExecutionLocations.Server);
            DistributionContext.SetContext(context.ClientContext, context.GlobalContext);

            System.Threading.Thread.CurrentThread.CurrentCulture =
                new System.Globalization.CultureInfo(context.ClientCulture);
            System.Threading.Thread.CurrentThread.CurrentUICulture =
                new System.Globalization.CultureInfo(context.ClientUICulture);

            if (DistributionContext.AuthenticationType == "Windows")
            {
                if (context.Principal != null)
                {
                    System.Security.SecurityException ex =
                        new System.Security.SecurityException("Resources.NoPrincipalAllowedException");
                    ex.Action = System.Security.Permissions.SecurityAction.Demand;
                    throw ex;
                }
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            }
            else
            {
                if (context.Principal == null)
                {
                    System.Security.SecurityException ex =
                        new System.Security.SecurityException(
                            "Resources.BusinessPrincipalException" + " Nothing");
                    ex.Action = System.Security.Permissions.SecurityAction.Demand;
                    throw ex;
                }
                DistributionContext.User = context.Principal;
                LEnvironment.Principal   = context.Principal;
            }
        }