Επεξεργασία

Κοινή χρήση μέσω


NegotiateStream.BeginAuthenticateAsServer Method

Definition

Begins an asynchronous operation to handle the server side of authenticating a client-server connection.

Overloads

BeginAuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified server credentials, authentication options, and extended protection policy. This method does not block.

BeginAuthenticateAsServer(AsyncCallback, Object)

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. This method does not block.

BeginAuthenticateAsServer(ExtendedProtectionPolicy, AsyncCallback, Object)

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified extended protection policy. This method does not block.

BeginAuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified server credentials and authentication options. This method does not block.

Remarks

The overloads of this method do not block while the authentication is in progress. To block while waiting for the authentication to complete, use the AuthenticateAsServer method.

BeginAuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified server credentials, authentication options, and extended protection policy. This method does not block.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (credential As NetworkCredential, policy As ExtendedProtectionPolicy, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

credential
NetworkCredential

The NetworkCredential that is used to establish the identity of the client.

policy
ExtendedProtectionPolicy

The ExtendedProtectionPolicy that is used for extended protection.

requiredProtectionLevel
ProtectionLevel

One of the ProtectionLevel values, indicating the security services for the stream.

requiredImpersonationLevel
TokenImpersonationLevel

One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object containing information about the write operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object indicating the status of the asynchronous operation.

Exceptions

The CustomChannelBinding and CustomServiceNames on the extended protection policy passed in the policy parameter are both null.

credential is null.

requiredImpersonationLevel must be Identification, Impersonation, or Delegation,

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 client. You cannot use the stream to retry authentication as the server.

This object has been closed.

The policy parameter was set to Always on a platform that does not support extended protection.

Windows 95 and Windows 98 are not supported.

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 policy parameter is null, then an extended protection policy is used that has PolicyEnforcement set to Never.

This method is asynchronous and does not block while the operation completes. To block until the operation completes, use one of the AuthenticateAsServer method overloads.

The asynchronous authentication operation must be completed by calling the EndAuthenticateAsServer method. Typically, the method is invoked by the asyncCallback delegate. For detailed information about using the asynchronous programming model, see Calling Synchronous Methods Asynchronously

If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.

See also

Applies to

BeginAuthenticateAsServer(AsyncCallback, Object)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. This method does not block.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object containing information about the operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object indicating the status of 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.

Windows 95 and Windows 98 are not supported.

Remarks

The authentication uses the server's DefaultCredentials. No Service Principal Name (SPN) is specified for the server. The impersonation level is Identification, the security level is EncryptAndSign.

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.

To block until the operation completes, use one of the AuthenticateAsServer method overloads.

If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.

Applies to

BeginAuthenticateAsServer(ExtendedProtectionPolicy, AsyncCallback, Object)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified extended protection policy. This method does not block.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (policy As ExtendedProtectionPolicy, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

policy
ExtendedProtectionPolicy

The ExtendedProtectionPolicy that is used for extended protection.

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object containing information about the write operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object indicating the status of the asynchronous operation.

Exceptions

The CustomChannelBinding and CustomServiceNames on the extended protection policy passed in the policy parameter are both 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.

The policy parameter was set to Always on a platform that does not support extended protection.

Windows 95 and Windows 98 are not supported.

Remarks

The authentication uses the server's DefaultCredentials. No Service Principal Name (SPN) is specified for the server. The impersonation level is Identification, the security level is EncryptAndSign.

If the policy parameter is null, then an extended protection policy is used that has PolicyEnforcement set to Never.

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.

To block until the operation completes, use one of the AuthenticateAsServer method overloads.

If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.

See also

Applies to

BeginAuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

Called by servers to begin an asynchronous operation to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified server credentials and authentication options. This method does not block.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (credential As NetworkCredential, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

credential
NetworkCredential

The NetworkCredential that is used to establish the identity of the client.

requiredProtectionLevel
ProtectionLevel

One of the ProtectionLevel values, indicating the security services for the stream.

requiredImpersonationLevel
TokenImpersonationLevel

One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object containing information about the operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object indicating the status of the asynchronous operation.

Exceptions

credential is null.

requiredImpersonationLevel must be Identification, Impersonation, or Delegation,

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 client. You cannot use the stream to retry authentication as the server.

Windows 95 and Windows 98 are not supported.

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.

This method is asynchronous and does not block while the operation completes. To block until the operation completes, use one of the AuthenticateAsServer method overloads.

The asynchronous authentication operation must be completed by calling the EndAuthenticateAsServer method. Typically, the method is invoked by the asyncCallback delegate. For detailed information about using the asynchronous programming model, see Calling Synchronous Methods Asynchronously

If the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. In this case, you can retry the authentication with a different credential.

Applies to