Skip to content

Commit d3bd2b9

Browse files
committed
fix
1 parent 4c3c3f2 commit d3bd2b9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSSPIContextProvider.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ internal sealed class NegotiateSSPIContextProvider : SSPIContextProvider
1313
{
1414
protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer)
1515
{
16+
NegotiateAuthenticationStatusCode statusCode = default;
17+
1618
for (int i = 0; i < _sniSpnBuffer.Length; i++)
1719
{
18-
var negotiateAuth = new(new NegotiateAuthenticationClientOptions { Package = "Negotiate", TargetName = Encoding.Unicode.GetString(_sniSpnBuffer[i]) });
19-
var result = _negotiateAuth.GetOutgoingBlob(incomingBlob.Span, out var statusCode)!;
20+
var negotiateAuth = new NegotiateAuthentication(new NegotiateAuthenticationClientOptions { Package = "Negotiate", TargetName = Encoding.Unicode.GetString(_sniSpnBuffer[i]) });
21+
var result = negotiateAuth.GetOutgoingBlob(incomingBlob.Span, out statusCode);
22+
2023
// Log session id, status code and the actual SPN used in the negotiation
2124
SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | Session Id {2}, StatusCode={3}, SPN={4}", nameof(NegotiateSSPIContextProvider),
22-
nameof(GenerateSspiClientContext), _physicalStateObj.SessionId, statusCode, _negotiateAuth.TargetName);
25+
nameof(GenerateSspiClientContext), _physicalStateObj.SessionId, statusCode, negotiateAuth.TargetName);
2326
if (statusCode == NegotiateAuthenticationStatusCode.Completed || statusCode == NegotiateAuthenticationStatusCode.ContinueNeeded)
2427
{
2528
outgoingBlobWriter.Write(result);

0 commit comments

Comments
 (0)