using System.Security; using System.Web; namespace Umbraco.Core { /// /// Static helper methods for returning information about the current System /// public static class SystemUtilities { /// /// Get the current trust level of the hosted application /// /// public static AspNetHostingPermissionLevel GetCurrentTrustLevel() { foreach (var trustLevel in new[] { AspNetHostingPermissionLevel.Unrestricted, AspNetHostingPermissionLevel.High, AspNetHostingPermissionLevel.Medium, AspNetHostingPermissionLevel.Low, AspNetHostingPermissionLevel.Minimal }) { try { new AspNetHostingPermission(trustLevel).Demand(); } catch (SecurityException) { continue; } return trustLevel; } return AspNetHostingPermissionLevel.None; } } }