TdsAuthenticationResult Class

Represents the result of an authentication attempt.

public sealed class TdsAuthenticationResult

Properties

NameDescription
DatabaseGets the default database to report after login, if any.
ErrorClassGets the error class to send on failure.
ErrorMessageGets the error message to send to the client on failure.
ErrorNumberGets the SQL Server-style error number to send on failure.
ErrorStateGets the error state to send on failure.
IsAuthenticatedGets a value indicating whether authentication succeeded.
IsSspiContinuationNeededGets a value indicating whether the SSPI exchange goes on: the server sends TdsAuthenticationResult.SspiToken to the client and waits for its answer.
SspiTokenGets the SSPI token to send to the client, or an empty value when there is none.
UserContextGets the authenticated user context that will be propagated to query handlers.

Gets the default database to report after login, if any.

public string? Database { get; }

Property value

string?

Gets the error class to send on failure.

public byte ErrorClass { get; }

Property value

byte

Gets the error message to send to the client on failure.

public string? ErrorMessage { get; }

Property value

string?

Gets the SQL Server-style error number to send on failure.

public uint ErrorNumber { get; }

Property value

uint

Gets the error state to send on failure.

public byte ErrorState { get; }

Property value

byte

Gets a value indicating whether authentication succeeded.

public bool IsAuthenticated { get; }

Property value

bool

IsSspiContinuationNeeded

TdsAuthenticationResult.cs

Gets a value indicating whether the SSPI exchange goes on: the server sends TdsAuthenticationResult.SspiToken to the client and waits for its answer.

public bool IsSspiContinuationNeeded { get; }

Property value

bool

Gets the SSPI token to send to the client, or an empty value when there is none.

public ReadOnlyMemory<byte> SspiToken { get; }

Property value

ReadOnlyMemory<byte>

Gets the authenticated user context that will be propagated to query handlers.

public ClaimsPrincipal? UserContext { get; }

Property value

ClaimsPrincipal?

Methods

NameDescription
ContinueSspi(ReadOnlyMemory<byte>)Creates a result that continues the SSPI exchange: the server sends the token to the client and calls the handler again with the client's answer.
Fail(string, uint, byte, byte)Creates a failed authentication result.
Success(ReadOnlyMemory<byte>, string?, ClaimsPrincipal?)Creates a successful authentication result that ends an SSPI exchange with a last token for the client.
Success(string?, ClaimsPrincipal?)Creates a successful authentication result.

ContinueSspi(ReadOnlyMemory<byte>)

TdsAuthenticationResult.cs

Creates a result that continues the SSPI exchange: the server sends the token to the client and calls the handler again with the client's answer.

public static TdsAuthenticationResult ContinueSspi(ReadOnlyMemory<byte> sspiToken)

Parameters

sspiToken ReadOnlyMemory<byte>
The SSPI token to send to the client.

Returns

TdsAuthenticationResult

Fail(string, uint, byte, byte)

TdsAuthenticationResult.cs

Creates a failed authentication result.

public static TdsAuthenticationResult Fail(string message, uint errorNumber = 18456U, byte errorState = 1, byte errorClass = 14)

Parameters

message string
errorNumber uint
errorState byte
errorClass byte

Returns

TdsAuthenticationResult

Success overloads

Success(ReadOnlyMemory<byte>, string?, ClaimsPrincipal?)

TdsAuthenticationResult.cs

Creates a successful authentication result that ends an SSPI exchange with a last token for the client.

public static TdsAuthenticationResult Success(ReadOnlyMemory<byte> sspiToken, string? database = null, ClaimsPrincipal? userContext = null)
Parameters
sspiToken ReadOnlyMemory<byte>
The final SSPI token, sent to the client before the login acknowledgment. It can be empty.
database string?
The default database to report after login, if any.
userContext ClaimsPrincipal?
The authenticated user context that will be propagated to query handlers.
Returns

TdsAuthenticationResult

Success(string?, ClaimsPrincipal?)

TdsAuthenticationResult.cs

Creates a successful authentication result.

public static TdsAuthenticationResult Success(string? database = null, ClaimsPrincipal? userContext = null)
Parameters
database string?
userContext ClaimsPrincipal?
Returns

TdsAuthenticationResult