Share via


X509CertificateRecipientClientCredential.SetScopedCertificate メソッド

定義

ストアから証明書を設定し、スコープを設定する URL によってインデックスが付けられたコレクションに格納します。

オーバーロード

SetScopedCertificate(String, StoreLocation, StoreName, Uri)

サブジェクト名、証明書ストアの場所、および証明書ストアの名前を指定して証明書を設定し、スコープを設定する URL に使用するコレクションに格納します。

SetScopedCertificate(StoreLocation, StoreName, X509FindType, Object, Uri)

証明書ストアの場所、証明書ストアの名前、X.509 検索の種類、および検索する値を指定して証明書を設定し、スコープを設定する URL に使用するコレクションに格納します。

SetScopedCertificate(String, StoreLocation, StoreName, Uri)

ソース:
X509CertificateRecipientClientCredential.cs
ソース:
X509CertificateRecipientClientCredential.cs
ソース:
X509CertificateRecipientClientCredential.cs

サブジェクト名、証明書ストアの場所、および証明書ストアの名前を指定して証明書を設定し、スコープを設定する URL に使用するコレクションに格納します。

public:
 void SetScopedCertificate(System::String ^ subjectName, System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName, Uri ^ targetService);
public void SetScopedCertificate (string subjectName, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName, Uri targetService);
member this.SetScopedCertificate : string * System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName * Uri -> unit
Public Sub SetScopedCertificate (subjectName As String, storeLocation As StoreLocation, storeName As StoreName, targetService As Uri)

パラメーター

subjectName
String

完全修飾サブジェクト名。

storeLocation
StoreLocation

サービスがサービス証明書を取得するときに使用する証明書ストアの場所。

storeName
StoreName

開く X.509 証明書ストアの名前。

targetService
Uri

スコープを設定する URL。

例外

subjectName または targetServicenull です。

資格情報が読み取り専用のときに設定しようとしました。

次のコードは、このメソッドを呼び出す方法を示しています。

public void snippet25(CalculatorClient cc)
{
    X509CertificateRecipientClientCredential rcc = cc.ClientCredentials.ServiceCertificate;
    rcc.SetScopedCertificate("http://fabrikam.com/sts",
                             StoreLocation.CurrentUser,
                             StoreName.TrustedPeople,
                             new Uri("http://fabrikam.com"));
}

注釈

storeLocation の値は、StoreLocation 列挙体に格納されます。

  • LocalMachine: ローカル コンピューターに割り当てられた証明書ストア。

  • CurrentUser: 現在のユーザーによって使用される証明書ストア (既定値)。

アプリケーションがシステム アカウントで実行されている場合、証明書は通常、LocalMachine にあります。 アプリケーションがユーザー アカウントで実行されている場合、証明書は通常、CurrentUser にあります。

storeName の値は、StoreName 列挙体に格納されます。

適用対象

SetScopedCertificate(StoreLocation, StoreName, X509FindType, Object, Uri)

ソース:
X509CertificateRecipientClientCredential.cs
ソース:
X509CertificateRecipientClientCredential.cs
ソース:
X509CertificateRecipientClientCredential.cs

証明書ストアの場所、証明書ストアの名前、X.509 検索の種類、および検索する値を指定して証明書を設定し、スコープを設定する URL に使用するコレクションに格納します。

public:
 void SetScopedCertificate(System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName, System::Security::Cryptography::X509Certificates::X509FindType findType, System::Object ^ findValue, Uri ^ targetService);
public void SetScopedCertificate (System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName, System.Security.Cryptography.X509Certificates.X509FindType findType, object findValue, Uri targetService);
member this.SetScopedCertificate : System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName * System.Security.Cryptography.X509Certificates.X509FindType * obj * Uri -> unit
Public Sub SetScopedCertificate (storeLocation As StoreLocation, storeName As StoreName, findType As X509FindType, findValue As Object, targetService As Uri)

パラメーター

storeLocation
StoreLocation

サービスがサービス証明書を取得するときに使用する証明書ストアの場所。

storeName
StoreName

開く X.509 証明書ストアの名前。

findType
X509FindType

実行する X.509 検索の種類。

findValue
Object

X.509 証明書ストアで検索する値。

targetService
Uri

スコープを設定する URL。

例外

findValue または targetServicenull です。

資格情報が読み取り専用のときに設定しようとしました。

次のコードは、このメソッドを呼び出す方法を示しています。

public void snippet20(CalculatorClient client)
{
    X509CertificateRecipientClientCredential rcc = client.ClientCredentials.ServiceCertificate;
    rcc.SetScopedCertificate(StoreLocation.CurrentUser,
                             StoreName.TrustedPeople,
                             X509FindType.FindBySubjectName,
                             "FabrikamSTS",
                             new Uri("http://fabrikam.com/sts"));
}
rcc.SetScopedCertificate(StoreLocation.CurrentUser, _
            StoreName.TrustedPeople, _
            X509FindType.FindBySubjectName, _
            "FabrikamSTS", _
            New Uri("http://fabrikam.com/sts"))

注釈

storeLocation の値は、StoreLocation 列挙体に格納されます。

  • LocalMachine: ローカル コンピューターに割り当てられた証明書ストア。

  • CurrentUser: 現在のユーザーによって使用される証明書ストア (既定値)。

アプリケーションがシステム アカウントで実行されている場合、証明書は通常、LocalMachine にあります。 アプリケーションがユーザー アカウントで実行されている場合、証明書は通常、CurrentUser にあります。

storeName の値は、StoreName 列挙体に格納されます。

findType の値は、X509FindType 列挙体に格納されます。

最もよく使用される列挙体は FindBySubjectName です。これは、指定されたストア内の証明書のサブジェクト名を検索 (大文字小文字の違いは無視) します。 この検索結果は厳密ではない可能性があります。 条件に一致する証明書が見つからないか、複数見つかった場合は、InvalidOperationException がスローされます。

適用対象