次の方法で共有


RolePrincipal コンストラクター

定義

RolePrincipal クラスの新しいインスタンスを作成します。

オーバーロード

名前 説明
RolePrincipal(IIdentity)

指定したidentityRolePrincipal オブジェクトをインスタンス化します。

RolePrincipal(SerializationInfo, StreamingContext)

指定したSerializationInfo オブジェクトに含まれる情報を使用し、指定したストリーミング コンテキストを使用して、RolePrincipal クラスの新しいインスタンスを初期化します。

RolePrincipal(IIdentity, String)

指定したencryptedTicketのロール情報を使用して、指定したidentityRolePrincipal オブジェクトをインスタンス化します。

RolePrincipal(String, IIdentity)

指定したproviderNameを使用して、指定したidentityRolePrincipal オブジェクトをインスタンス化します。

RolePrincipal(String, IIdentity, String)

指定したencryptedTicketの指定したproviderNameとロール情報を使用して、指定したidentityRolePrincipal オブジェクトをインスタンス化します。

RolePrincipal(IIdentity)

指定したidentityRolePrincipal オブジェクトをインスタンス化します。

public:
 RolePrincipal(System::Security::Principal::IIdentity ^ identity);
public RolePrincipal(System.Security.Principal.IIdentity identity);
new System.Web.Security.RolePrincipal : System.Security.Principal.IIdentity -> System.Web.Security.RolePrincipal
Public Sub New (identity As IIdentity)

パラメーター

identity
IIdentity

RolePrincipalを作成するユーザー ID。

例外

identitynullです。

次のコード例では、新しい RolePrincipal オブジェクトを作成します。 CacheRolesInCookietrue場合、この例では、CookieName プロパティによって識別される Cookie からの Cookie 情報を使用してRolePrincipalを作成します。

RolePrincipal r;

if (Roles.CacheRolesInCookie)
{
  string roleCookie = "";

  HttpCookie cookie = HttpContext.Current.Request.Cookies[Roles.CookieName];
  if (cookie != null) { roleCookie = cookie.Value; }

  r = new RolePrincipal(User.Identity, roleCookie);
}
else
{
  r = new RolePrincipal(User.Identity);
}
Dim r As RolePrincipal

If Roles.CacheRolesInCookie Then
  Dim roleCookie As String = ""

  Dim cookie As HttpCookie = HttpContext.Current.Request.Cookies(Roles.CookieName)
  If Not cookie Is Nothing Then roleCookie = cookie.Value

  r = New RolePrincipal(User.Identity, roleCookie)
Else
  r = new RolePrincipal(User.Identity)
End If

注釈

RolePrincipal コンストラクターのこのオーバーロードは、新しいRolePrincipal オブジェクトを作成し、そのプロパティ値を初期化します。 キャッシュされたロール情報は、 CookieName プロパティによって識別される Cookie から読み取りません。 ProviderName プロパティは、既定のロール プロバイダーのNameに設定されます。

ロール管理を有効にする方法については、 Roles クラスを参照してください。

こちらもご覧ください

適用対象

RolePrincipal(SerializationInfo, StreamingContext)

指定したSerializationInfo オブジェクトに含まれる情報を使用し、指定したストリーミング コンテキストを使用して、RolePrincipal クラスの新しいインスタンスを初期化します。

protected:
 RolePrincipal(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected RolePrincipal(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Web.Security.RolePrincipal : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Web.Security.RolePrincipal
Protected Sub New (info As SerializationInfo, context As StreamingContext)

パラメーター

info
SerializationInfo

データを設定する SerializationInfo オブジェクト。

context
StreamingContext

このシリアル化の宛先。

適用対象

RolePrincipal(IIdentity, String)

指定したencryptedTicketのロール情報を使用して、指定したidentityRolePrincipal オブジェクトをインスタンス化します。

public:
 RolePrincipal(System::Security::Principal::IIdentity ^ identity, System::String ^ encryptedTicket);
public RolePrincipal(System.Security.Principal.IIdentity identity, string encryptedTicket);
new System.Web.Security.RolePrincipal : System.Security.Principal.IIdentity * string -> System.Web.Security.RolePrincipal
Public Sub New (identity As IIdentity, encryptedTicket As String)

パラメーター

identity
IIdentity

RolePrincipalを作成するユーザー ID。

encryptedTicket
String

暗号化されたロール情報を含む文字列。

例外

identitynullです。

-又は-

encryptedTicketnullです。

次のコード例では、新しい RolePrincipal オブジェクトを作成します。 CacheRolesInCookietrue場合、この例では、CookieName プロパティによって識別される Cookie からの Cookie 情報を使用してRolePrincipalを作成します。

RolePrincipal r;

if (Roles.CacheRolesInCookie)
{
  string roleCookie = "";

  HttpCookie cookie = HttpContext.Current.Request.Cookies[Roles.CookieName];
  if (cookie != null) { roleCookie = cookie.Value; }

  r = new RolePrincipal(User.Identity, roleCookie);
}
else
{
  r = new RolePrincipal(User.Identity);
}
Dim r As RolePrincipal

If Roles.CacheRolesInCookie Then
  Dim roleCookie As String = ""

  Dim cookie As HttpCookie = HttpContext.Current.Request.Cookies(Roles.CookieName)
  If Not cookie Is Nothing Then roleCookie = cookie.Value

  r = New RolePrincipal(User.Identity, roleCookie)
Else
  r = new RolePrincipal(User.Identity)
End If

注釈

Important

信頼されていないデータでこの型のインスタンスを使用することは、セキュリティ上のリスクです。 このオブジェクトは、信頼できるデータでのみ使用します。 詳細については、「すべての入力を検証する」を参照してください。

RolePrincipal コンストラクターのこのオーバーロードは、新しいRolePrincipal オブジェクトを作成し、そのプロパティ値を初期化します。 現在のユーザーのロール情報は、指定された encryptedTicket から読み取られ、 RolePrincipal オブジェクトと共にキャッシュされます。 ProviderName プロパティは、既定のロール プロバイダーのNameに設定されます。

ロール管理を有効にする方法については、 Roles クラスを参照してください。

こちらもご覧ください

適用対象

RolePrincipal(String, IIdentity)

指定したproviderNameを使用して、指定したidentityRolePrincipal オブジェクトをインスタンス化します。

public:
 RolePrincipal(System::String ^ providerName, System::Security::Principal::IIdentity ^ identity);
public RolePrincipal(string providerName, System.Security.Principal.IIdentity identity);
new System.Web.Security.RolePrincipal : string * System.Security.Principal.IIdentity -> System.Web.Security.RolePrincipal
Public Sub New (providerName As String, identity As IIdentity)

パラメーター

providerName
String

ユーザーのロール プロバイダーの名前。

identity
IIdentity

RolePrincipalを作成するユーザー ID。

例外

identitynullです。

providerNamenullです。

-又は-

providerName は、アプリケーションの構成に存在しないロール プロバイダーを指します。

注釈

RolePrincipal コンストラクターのこのオーバーロードは、新しいRolePrincipal オブジェクトを作成し、そのプロパティ値を初期化します。 ProviderName プロパティは、providerName パラメーターで指定された値に設定されます。

ロール管理を有効にする方法については、 Roles クラスを参照してください。

こちらもご覧ください

適用対象

RolePrincipal(String, IIdentity, String)

指定したencryptedTicketの指定したproviderNameとロール情報を使用して、指定したidentityRolePrincipal オブジェクトをインスタンス化します。

public:
 RolePrincipal(System::String ^ providerName, System::Security::Principal::IIdentity ^ identity, System::String ^ encryptedTicket);
public RolePrincipal(string providerName, System.Security.Principal.IIdentity identity, string encryptedTicket);
new System.Web.Security.RolePrincipal : string * System.Security.Principal.IIdentity * string -> System.Web.Security.RolePrincipal
Public Sub New (providerName As String, identity As IIdentity, encryptedTicket As String)

パラメーター

providerName
String

ユーザーのロール プロバイダーの名前。

identity
IIdentity

RolePrincipalを作成するユーザー ID。

encryptedTicket
String

暗号化されたロール情報を含む文字列。

例外

identitynullです。

-又は-

encryptedTicketnullです。

providerNamenullです。

-又は-

providerName は、アプリケーションの構成に存在しないロール プロバイダーを指します。

注釈

Important

信頼されていないデータでこの型のインスタンスを使用することは、セキュリティ上のリスクです。 このオブジェクトは、信頼できるデータでのみ使用します。 詳細については、「すべての入力を検証する」を参照してください。

RolePrincipal コンストラクターのこのオーバーロードは、新しいRolePrincipal オブジェクトを作成し、そのプロパティ値を初期化します。 現在のユーザーのロール情報は、指定された encryptedTicket から読み取られ、 RolePrincipal オブジェクトと共にキャッシュされます。 ProviderName プロパティは、providerName パラメーターで指定された値に設定されます。

ロール管理を有効にする方法については、 Roles クラスを参照してください。

こちらもご覧ください

適用対象