ContextUtil.IsSecurityEnabled Property

Definition

Gets a value that indicates whether role-based security is active in the current context.

C#
public static bool IsSecurityEnabled { get; }

Property Value

true if the current context has security enabled; otherwise, false.

Exceptions

There is no COM+ context available.

Examples

The following code example gets the value of a IsSecurityEnabled property.

C#
[SecurityRole("Role1")]
public class ContextUtil_IsSecurityEnabled : ServicedComponent
{
    public void Example()
    {
        // Display whether role-based security is active for the current COM+
        // context.
        Console.WriteLine("Role-based security active in current context: {0}",
            ContextUtil.IsSecurityEnabled);
    }
}

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1