pymssql / pymssql

Official home for the pymssql source code.
https://pymssql.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
837 stars 310 forks source link

Unable to connect to mssql database through python pymssql with active directory authentication from linux machine #672

Open vptayde opened 4 years ago

vptayde commented 4 years ago

I am trying to connect to mssql database through python with pymssql with active directory authentication My mssql database are present on window machin.

My code is : conn = pymssql.connect(server=url, user=username, password=password, database=database) here username = domain\username

I am getting below error: (18452, b'Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.DB-Lib error message 20018,severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed

Can you please suggest solution, we need to connect to 1000 mssql database so want to avoid kerbores things.

noisycomputation commented 4 years ago

Try using two backslashes between domain and username: domain\\username. Just tried it and it seemed to work for me. See this.

That said, I know absolutely nothing about Windows networking, it's just a magical black box to me. So if this doesn't work for you, I won't be much help.