Open darouwan opened 4 months ago
Solved by indicate ntlm authentication explicitly
Can you share more details on how you are creating the connection. Are you using explicit credentials or relying on the ccached ticket? It sounds like there might either be some sort of race condition or something else where listdir
is trying to re-authenticate the session but at that point in time it has no explicit credential so is trying to rely on the ccache which doesn't exist. Knowing what you are doing here and potentially the full traceback from Python would be very useful.
@jborean93 I set auth_protocol='ntlm'
in the client config before register_session. The default value is negotiate, and my smb service use ntlm rather than Kerberos. Maybe negotiate setting cannot get the correct authentication method?
smbclient.ClientConfig(username=self._username, password=self._password,auth_protocol='ntlm')
register_session(self._hostname, username=self._username,password=self._password)
Setting an explicit username and password in the ClientConfig
should always ensure that a credential is provided when creating a session avoiding that error you see. It is interesting that it is also fixed by using ntlm
explicitly as that should suffer from the same problem but with a different error message.
If you can still replicate the problem could you try and share the traceback?
import traceback
try:
code_that_fails()
except:
traceback.print_exc()
raise
Sometimes the command like
smbclient.listdir
has the following error, but sometimes not:When I restart my application, sometimes it works fine.
When regiester session, it seems successful:
The smb protocal is v2. Do I need to do more config?