Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (4k points)

How can I connect to a SQL Server database using user login/password that is in another domain?

If I use my account to connect to DB, it works fine:

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server_name;DATABASE=testdb;UID=MY_Domain\\username;PWD=pass; Trusted connection=YES')

But I need to use another user's credentials like

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server_name;DATABASE=testdb;UID=Another_Domain\\username;PWD=pass; Trusted connection=YES')

When I try the latter I get an error of "failed login for MY_Domain\username" rather than for the user "Another_Domain\username".

In both cases by running SQL Server Management Studio I can use Windows Authentication to connect to the db.

1 Answer

0 votes
by (8.7k points)

There is no way to connect with the SQL server as passing UID and Password as an impersonated window user but you can connect to it as SQL Server User or as a trusted connection as Window authenticated user.

Browse Categories

...