NegotiateStream.AuthenticateAsClientAsync 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.
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation.
Overloads
AuthenticateAsClientAsync() |
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. |
AuthenticateAsClientAsync(NetworkCredential, String) |
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified client credential. |
AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String) |
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified client credential and the channel binding. |
AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel) |
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified credentials and authentication options. |
AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel) |
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified credential, authentication options, and channel binding. |
AuthenticateAsClientAsync()
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation.
public:
virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync();
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync ();
abstract member AuthenticateAsClientAsync : unit -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : unit -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync () As Task
Returns
The task object representing the asynchronous operation.
Exceptions
The authentication failed. You can use this object to retry the authentication.
The authentication failed. You can use this object to retry the authentication.
This object has been closed.
Authentication has already occurred.
-or-
This stream was used previously to attempt authentication as the server. You cannot use the stream to retry authentication as the client.
Remarks
The authentication uses the client's DefaultCredentials. No Service Principal Name (SPN) is specified for the server. The impersonation level is Identification, the security level is EncryptAndSign, and mutual authentication is requested. The NegotiateStream class will construct the SPN used for mutual authentication.
When authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.
If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsClient().
Applies to
AuthenticateAsClientAsync(NetworkCredential, String)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified client credential.
public:
virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::String ^ targetName);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, string targetName);
abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * string -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * string -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, targetName As String) As Task
Parameters
- credential
- NetworkCredential
The NetworkCredential that is used to establish the identity of the client.
- targetName
- String
The Service Principal Name (SPN) that uniquely identifies the server to authenticate.
Returns
The task object representing the asynchronous operation.
Exceptions
The authentication failed. You can use this object to retry the authentication.
The authentication failed. You can use this object to retry the authentication.
This object has been closed.
Authentication has already occurred.
-or-
This stream was used previously to attempt authentication as the server. You cannot use the stream to retry authentication as the client.
targetName
is null
.
Remarks
The impersonation level is Identification, the security level is EncryptAndSign, and mutual authentication is requested. The NegotiateStream class will construct the SPN used for mutual authentication.
When authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsClient(NetworkCredential, String).
Applies to
AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified client credential and the channel binding.
public:
virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ChannelBinding ^ binding, System::String ^ targetName);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding? binding, string targetName);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding binding, string targetName);
abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, binding As ChannelBinding, targetName As String) As Task
Parameters
- credential
- NetworkCredential
The NetworkCredential that is used to establish the identity of the client.
- binding
- ChannelBinding
The ChannelBinding that is used for extended protection.
- targetName
- String
The Service Principal Name (SPN) that uniquely identifies the server to authenticate.
Returns
The task object representing the asynchronous operation.
Exceptions
The authentication failed. You can use this object to retry the authentication.
The authentication failed. You can use this object to retry the authentication.
Authentication has already occurred.
-or-
This stream was used previously to attempt authentication as the server. You cannot use the stream to retry authentication as the client.
This object has been closed.
Remarks
The impersonation level is Identification, the security level is EncryptAndSign, and mutual authentication is requested. The NegotiateStream class will construct the SPN used for mutual authentication.
The ChannelBinding used for extended protection that is passed to this method in the binding
parameter would be retrieved by an application from TransportContext property on the associated SslStream.
When authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsClient(NetworkCredential, ChannelBinding, String).
See also
Applies to
AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified credentials and authentication options.
public:
virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::String ^ targetName, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel allowedImpersonationLevel);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, string targetName, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel allowedImpersonationLevel);
abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, targetName As String, requiredProtectionLevel As ProtectionLevel, allowedImpersonationLevel As TokenImpersonationLevel) As Task
Parameters
- credential
- NetworkCredential
The NetworkCredential that is used to establish the identity of the client.
- targetName
- String
The Service Principal Name (SPN) that uniquely identifies the server to authenticate.
- requiredProtectionLevel
- ProtectionLevel
One of the ProtectionLevel values, indicating the security services for the stream.
- allowedImpersonationLevel
- TokenImpersonationLevel
One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.
Returns
The task object representing the asynchronous operation.
Exceptions
allowedImpersonationLevel
is not a valid value.
targetName
is null.
The authentication failed. You can use this object to retry the authentication.
The authentication failed. You can use this object to retry the authentication.
This object has been closed.
Authentication has already occurred.
-or-
This stream was used previously to attempt authentication as the server. You cannot use the stream to retry authentication as the client.
Remarks
Use the requiredProtectionLevel
parameter to request security services for data transmitted using the authenticated stream. For example, to have the data encrypted and signed, specify the EncryptAndSign value. Successful authentication does not guarantee that the requested ProtectionLevel has been granted. You must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream.
If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsClient(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel).
Applies to
AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Called by clients to authenticate the client, and optionally the server, in a client-server connection as an asynchronous operation. The authentication process uses the specified credential, authentication options, and channel binding.
public:
virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ChannelBinding ^ binding, System::String ^ targetName, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel allowedImpersonationLevel);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding? binding, string targetName, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel allowedImpersonationLevel);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding binding, string targetName, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel allowedImpersonationLevel);
abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, binding As ChannelBinding, targetName As String, requiredProtectionLevel As ProtectionLevel, allowedImpersonationLevel As TokenImpersonationLevel) As Task
Parameters
- credential
- NetworkCredential
The NetworkCredential that is used to establish the identity of the client.
- binding
- ChannelBinding
The ChannelBinding that is used for extended protection.
- targetName
- String
The Service Principal Name (SPN) that uniquely identifies the server to authenticate.
- requiredProtectionLevel
- ProtectionLevel
One of the ProtectionLevel values, indicating the security services for the stream.
- allowedImpersonationLevel
- TokenImpersonationLevel
One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.
Returns
The task object representing the asynchronous operation.
Exceptions
allowedImpersonationLevel
is not a valid value.
The authentication failed. You can use this object to retry the authentication.
The authentication failed. You can use this object to retry the authentication.
Authentication has already occurred.
-or-
This stream was used previously to attempt authentication as the server. You cannot use the stream to retry authentication as the client.
This object has been closed.
Remarks
Use the requiredProtectionLevel
parameter to request security services for data transmitted using the authenticated stream. For example, to have the data encrypted and signed, specify the EncryptAndSign value. Successful authentication does not guarantee that the requested ProtectionLevel has been granted. You must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream.
The ChannelBinding used for extended protection that is passed to this method in the binding
parameter would be retrieved by an application from TransportContext property on the associated SslStream.
If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsClient(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel).