This documentation is archived and is not being maintained.

SecurityManager.PolicyHierarchy Method

Provides an enumerator to access the security policy hierarchy by levels, such as computer policy and user policy.

Namespace:  System.Security
Assembly:  mscorlib (in mscorlib.dll)

public static IEnumerator PolicyHierarchy()

Return Value

Type: System.Collections.IEnumerator
An IEnumerator for PolicyLevel objects that compose the security policy hierarchy.


The code that calls this method does not have SecurityPermissionFlag.ControlPolicy.

The returned enumerator provides successive PolicyLevel objects that represent the policy at the respective (machine, user, enterprise, application domain) level of the hierarchy. These objects are the live policy objects; altering these objects can have unpredictable results.

Minimum policy hierarchy consists of a machine level, an enterprise level, and a user level. However, the hierarchy can include additional levels.

For the complete example, see the SecurityManager class topic.

private static void DeleteCustomCodeGroups()
    // Delete the custom code groups that were created.
    IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy();
        PolicyLevel machineLevel = (PolicyLevel)policyEnumerator.Current;
        IList childCodeGroups = machineLevel.RootCodeGroup.Children;
        IEnumerator childGroups = childCodeGroups.GetEnumerator();
            CodeGroup thisCodeGroup = (CodeGroup)childGroups.Current;
            if( thisCodeGroup.Name == "MyCompanyCodeGroup")

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0