Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8401a77

Browse files
arelleguemdaigle
authored andcommitted
Fix | Fixed GenerateSspiClientContext to retry negotiation with default port (#2559)
1 parent6c48d05 commit8401a77

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,25 @@ internal sealed class NegotiateSSPIContextProvider : SSPIContextProvider
1414

1515
internaloverridevoidGenerateSspiClientContext(ReadOnlyMemory<byte>received,refbyte[]sendBuff,refuintsendLength,byte[][]_sniSpnBuffer)
1616
{
17-
_negotiateAuth??=new(newNegotiateAuthenticationClientOptions{Package="Negotiate",TargetName=Encoding.Unicode.GetString(_sniSpnBuffer[0])});
18-
sendBuff=_negotiateAuth.GetOutgoingBlob(received.Span,outNegotiateAuthenticationStatusCodestatusCode)!;
19-
SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.GenerateSspiClientContext | Info | Session Id {0}, StatusCode={1}",_physicalStateObj.SessionId,statusCode);
17+
NegotiateAuthenticationStatusCodestatusCode=NegotiateAuthenticationStatusCode.UnknownCredentials;
18+
19+
for(inti=0;i<_sniSpnBuffer.Length;i++)
20+
{
21+
_negotiateAuth??=new(newNegotiateAuthenticationClientOptions{Package="Negotiate",TargetName=Encoding.Unicode.GetString(_sniSpnBuffer[i])});
22+
sendBuff=_negotiateAuth.GetOutgoingBlob(received.Span,outstatusCode)!;
23+
// Log session id, status code and the actual SPN used in the negotiation
24+
SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.GenerateSspiClientContext | Info | Session Id {0}, StatusCode={1}, SPN={2}",_physicalStateObj.SessionId,statusCode,_negotiateAuth.TargetName);
25+
if(statusCode==NegotiateAuthenticationStatusCode.Completed||statusCode==NegotiateAuthenticationStatusCode.ContinueNeeded)
26+
break;// Successful case, exit the loop with current SPN.
27+
else
28+
_negotiateAuth=null;// Reset _negotiateAuth to be generated again for next SPN.
29+
}
30+
2031
if(statusCodeis notNegotiateAuthenticationStatusCode.Completed and notNegotiateAuthenticationStatusCode.ContinueNeeded)
2132
{
2233
thrownewInvalidOperationException(SQLMessage.SSPIGenerateError()+Environment.NewLine+statusCode);
2334
}
35+
2436
sendLength=(uint)(sendBuff!=null?sendBuff.Length:0);
2537
}
2638
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp