ClientRolePrincipal クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
クライアント アプリケーション サービスのセキュリティ情報を表します。これにはロール情報が含まれます。
public ref class ClientRolePrincipal : System::Security::Principal::IPrincipal
public class ClientRolePrincipal : System.Security.Principal.IPrincipal
type ClientRolePrincipal = class
interface IPrincipal
Public Class ClientRolePrincipal
Implements IPrincipal
- 継承
-
ClientRolePrincipal
- 実装
例
次のコード例では、このクラスを使用して、ユーザーが "マネージャー" ロールの場合にのみボタンを表示する方法を示します。 この例では、 Button の初期Visibleプロパティ値を持つ という名前managerOnlyButton
がfalse
必要です。
private void DisplayButtonForManagerRole()
{
try
{
ClientRolePrincipal rolePrincipal =
System.Threading.Thread.CurrentPrincipal
as ClientRolePrincipal;
if (rolePrincipal != null && rolePrincipal.IsInRole("manager"))
{
managerOnlyButton.Visible = true;
}
}
catch (System.Net.WebException)
{
MessageBox.Show("Unable to access the roles service.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
Private Sub DisplayButtonForManagerRole()
Try
Dim rolePrincipal As ClientRolePrincipal = TryCast( _
System.Threading.Thread.CurrentPrincipal, ClientRolePrincipal)
If rolePrincipal IsNot Nothing And _
rolePrincipal.IsInRole("manager") Then
managerOnlyButton.Visible = True
End If
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the role service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
注釈
クライアント アプリケーション サービスでユーザーを検証すると、 ClientFormsAuthenticationMembershipProvider または によって ClientWindowsAuthenticationMembershipProvider プロパティがこのクラスのインスタンスに設定されます static
Thread.CurrentPrincipal 。 は ClientFormsAuthenticationMembershipProvider 、 クラスの Identity 新しいインスタンスに対して プロパティを ClientFormsIdentity 初期化します。 はClientWindowsAuthenticationMembershipProvider、 メソッドによって返される オブジェクトにWindowsIdentity対して プロパティをstatic
WindowsIdentity.GetCurrent()初期化Identityします。
通常、このクラスには直接アクセスしません。 通常、 プロパティによってstatic
CurrentPrincipal返される のメソッドをIPrincipal呼び出IsInRoleします。 ただし、「例」セクションで CurrentPrincipal 示されているように、プロパティ値を ClientRolePrincipal 参照にキャストしてメソッドを明示的に呼び出 IsInRole すことができます。
コンストラクター
ClientRolePrincipal(IIdentity) |
ClientRolePrincipal クラスの新しいインスタンスを初期化します。 |
プロパティ
Identity |
ClientRolePrincipal セキュリティ ID を取得します。 |
メソッド
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
IsInRole(String) |
ClientRolePrincipal が示すユーザーが、指定したロールに存在するかどうかを示す値を取得します。 |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示