GenericPrincipal.IsInRole 方法
确定当前 GenericPrincipal 是否属于指定的角色。
**命名空间:**System.Security.Principal
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
Public Overridable Function IsInRole ( _
role As String _
) As Boolean
用法
Dim instance As GenericPrincipal
Dim role As String
Dim returnValue As Boolean
returnValue = instance.IsInRole(role)
public virtual bool IsInRole (
string role
)
public:
virtual bool IsInRole (
String^ role
)
public boolean IsInRole (
String role
)
public function IsInRole (
role : String
) : boolean
参数
- role
要检查其成员资格的角色的名称。
返回值
如果当前 GenericPrincipal 是指定角色的成员,则为 true;否则为 false。
示例
下面的代码演示 IsInRole 方法的使用。此代码示例摘自一个为 GenericPrincipal 类提供的更大的示例。
If (genericPrincipal.IsInRole("NetworkUser")) Then
WriteLine("User belongs to the NetworkUser role.")
End If
if (genericPrincipal.IsInRole("NetworkUser"))
{
Console.WriteLine("User belongs to the NetworkUser role.");
}
if ( genericPrincipal->IsInRole( L"NetworkUser" ) )
{
Console::WriteLine( L"User belongs to the NetworkUser role." );
}
if (genericPrincipal.IsInRole("NetworkUser")) {
Console.WriteLine("User belongs to the NetworkUser role.");
}
平台
Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
GenericPrincipal 类
GenericPrincipal 成员
System.Security.Principal 命名空间