jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
318 stars 73 forks source link

Connection fails when username has more than one hyphen (`-`) in it. #156

Closed Bargenish closed 2 years ago

Bargenish commented 2 years ago

When trying to create a session with a username that contains more than one hyphen, an exception is raised.

The username (AA-user-with-hyphens) is valid and the connection should be established successfully.

traceback:

Traceback (most recent call last):
  File "<string>", line 8648, in main
  File "<string>", line 8556, in list_dir
  File "<string>", line 8476, in create_session
  File "/usr/local/lib/python3.9/site-packages/smbclient/_pool.py", line 359, in register_session
    session.connect()
  File "/usr/local/lib/python3.9/site-packages/smbprotocol/session.py", line 292, in connect
    response = self.connection.receive(request)
  File "/usr/local/lib/python3.9/site-packages/smbprotocol/connection.py", line 931, in receive
    raise SMBResponseException(response)
smbprotocol.exceptions.SMBResponseException: Received unexpected status from the server: Unknown error. (3221225584) UNKNOWN_ENUM: 0xc0000070
jborean93 commented 2 years ago

The error you get here relates to STATUS_INVALID_WORKSTATION which essentially means the account is not authorized to logon onto the target host in question. In AD these settings are under the Log On To option of the user account

image

I remember this being a complicated option as it actually applies to the workstation specified in the NTLM token which is the client host (one running smbprotocol).

Bargenish commented 2 years ago

@jborean93 Thanks for replying so quickly! Let me check with the customer, not sure that's the case here but I'll double check. will update here soon. Thanks!

Bargenish commented 2 years ago

Customer mentioned the issue is resolved. Thanks for looking into it!!