@@ -297,12 +297,6 @@ public SspiHelper(string securityPackage, string remotePrincipal)
297297 {
298298 _securityPackage = securityPackage ;
299299 _remotePrincipal = remotePrincipal ;
300- _clientCredentials = new SecHandle ( ) ;
301- var resCode = AcquireCredentialsHandle ( null , securityPackage , SECPKG_CRED_OUTBOUND ,
302- IntPtr . Zero , IntPtr . Zero , 0 , IntPtr . Zero ,
303- out _clientCredentials , out var expiry ) ;
304- if ( resCode != SEC_E_OK )
305- throw new Exception ( $ "{ nameof ( AcquireCredentialsHandle ) } failed") ;
306300 }
307301
308302 #endregion
@@ -317,6 +311,7 @@ public byte[] InitializeClientSecurity()
317311 {
318312 EnsureDisposed ( ) ;
319313 CloseClientContext ( ) ;
314+ InitializeClientCredentials ( ) ;
320315 _clientContext = new SecHandle ( ) ;
321316 var clientTokenBuf = new SecBufferDesc ( MAX_TOKEN_SIZE ) ;
322317 try
@@ -423,6 +418,16 @@ private void Dispose(bool disposing)
423418 }
424419 }
425420
421+ private void InitializeClientCredentials ( )
422+ {
423+ _clientCredentials = new SecHandle ( ) ;
424+ var resCode = AcquireCredentialsHandle ( null , _securityPackage , SECPKG_CRED_OUTBOUND ,
425+ IntPtr . Zero , IntPtr . Zero , 0 , IntPtr . Zero ,
426+ out _clientCredentials , out var expiry ) ;
427+ if ( resCode != SEC_E_OK )
428+ throw new Exception ( $ "{ nameof ( AcquireCredentialsHandle ) } failed") ;
429+ }
430+
426431 private void CloseClientContext ( )
427432 {
428433 if ( ! _clientContext . IsInvalid )
0 commit comments