X509CertificateRecipientClientCredential.SetScopedCertificate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets a certificate from a store and stores it in a collection indexed by the URL that sets the scope.
Overloads
SetScopedCertificate(String, StoreLocation, StoreName, Uri) |
Sets a certificate by subject name, certificate store location, and certificate store name, and stores it in a collection to be used for the URL that sets the scope. |
SetScopedCertificate(StoreLocation, StoreName, X509FindType, Object, Uri) |
Sets a certificate by certificate store location, certificate store name, type of X.509 search, and value to search for, and stores it in a collection to be used for the URL that sets the scope. |
SetScopedCertificate(String, StoreLocation, StoreName, Uri)
Sets a certificate by subject name, certificate store location, and certificate store name, and stores it in a collection to be used for the URL that sets the scope.
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)
Parameters
- subjectName
- String
The fully qualified subject name.
- storeLocation
- StoreLocation
The location of the certificate store that the service uses to obtain the service certificate.
- storeName
- StoreName
The name of the X.509 certificate store to open.
- targetService
- Uri
The URL that sets the scope.
Exceptions
subjectName
or targetService
is null
.
Attempted to set when the credential is read-only.
Examples
This code shows how to call this method.
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"));
}
Remarks
Values for storeLocation
are included in the StoreLocation enumeration:
LocalMachine: the certificate store assigned to the local machine.
CurrentUser: the certificate store used by the current user (default).
If the application is running under a system account, then the certificate is typically in LocalMachine. If the application is running under a user account, then the certificate is typically in CurrentUser.
Values for storeName
are included in the StoreName enumeration.
Applies to
SetScopedCertificate(StoreLocation, StoreName, X509FindType, Object, Uri)
Sets a certificate by certificate store location, certificate store name, type of X.509 search, and value to search for, and stores it in a collection to be used for the URL that sets the scope.
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)
Parameters
- storeLocation
- StoreLocation
The location of the certificate store that the service uses to obtain the service certificate.
- storeName
- StoreName
The name of the X.509 certificate store to open.
- findType
- X509FindType
The type of X.509 search to be executed.
- findValue
- Object
The value to search for in the X.509 certificate store.
- targetService
- Uri
The URL that sets the scope.
Exceptions
findValue
or targetService
is null
.
Attempted to set when the credential is read-only.
Examples
This code shows how to call this method.
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"))
Remarks
Values for storeLocation
are included in the StoreLocation enumeration:
LocalMachine: the certificate store assigned to the local machine.
CurrentUser: the certificate store used by the current user (default).
If the application is running under a system account, then the certificate is typically in LocalMachine. If the application is running under a user account, then the certificate is typically in CurrentUser.
Values for storeName
are included in the StoreName enumeration.
Values for findType
are included in the X509FindType enumeration.
The most commonly used enumeration is FindBySubjectName, which does a case-insensitive search on the subject name of certificates in the specified store. This can be an imprecise search. If no certificates or multiple certificates that match the criteria are found, an InvalidOperationException will be thrown.
Applies to
.NET