ContextUtil.IsSecurityEnabled 属性

定义

获取一个值,该值指示基于角色的安全性在当前上下文中是否处于活动状态。

public:
 static property bool IsSecurityEnabled { bool get(); };
public static bool IsSecurityEnabled { get; }
static member IsSecurityEnabled : bool
Public Shared ReadOnly Property IsSecurityEnabled As Boolean

属性值

如果当前上下文启用了安全性,则为 true;否则为 false

例外

没有可用的 COM+ 上下文。

示例

下面的代码示例获取 属性的值 IsSecurityEnabled

[SecurityRole("Role1")]
public ref class ContextUtil_IsSecurityEnabled: public 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 );
   }
};
[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);
    }
}
<SecurityRole("Role1")>  _
Public Class ContextUtil_IsSecurityEnabled
    Inherits ServicedComponent
    
    Public Sub Example() 
        ' Display whether role-based security is active for the current COM+
        ' context.
        MsgBox("Role-based security active in current context: " & ContextUtil.IsSecurityEnabled)

    End Sub
End Class

适用于