Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database + Windows Authentication + Username/Password?

I have always thought that in order to connect to SQL server using windows authentication with explicitly specified credentials, you must LogonUser, Impersonate, then connect.

It seems to me that this link suggests that it's possible to connect to SQL server without all this hassle, simply by specifying "uid=...;pwd=..." in connection string. I tested this method just to be sure it doesn't work, and - lo and behold - it didn't. If that blog post wasn't on msdn.com, I would have just dismissed it as noob talk, but it is.

Does anyone have an idea what am I missing?

EDIT1: Many respondents misunderstood what I was referring to. Here's a copy/paste of what I was talking about. It's not integrated SQL, nor it's an ASP.NET impersonation made by IIS:

string sql4 = String.Format(    @"Data Source={0};Integrated Security=SSPI;uid=<uid>;pwd=<pid>", server);      // Database + Windows Authentication + Username/Password 
like image 312
galets Avatar asked May 06 '09 18:05

galets


People also ask

How do I find my SQL authentication username and password?

You can see the user mappings by opening Sql Server Management Studio and connecting to your server. In the Object Explorer area expand the Security and then Login folders (just under "Databases"). Double-click a login to open it's Properties window, and find the User Mappings section.

What is the login and password for SQL Server authentication?

Where: Instance_name is the SQL Server instance name. Username is the user name that is used to login to the SQL server. Password is the password of the user.


1 Answers

There are two distinct kinds of security with SQL Server. "Windows Authentication", and "SQL Server Authentication". When you see uid and pwd you're seeing the latter. The uid in this case is not a Windows principal - the OS knows nothing about it.

So the answer to your question is, no, you can't pass Windows user name and password in the connection string to log in to SQL Server.

like image 197
John Saunders Avatar answered Sep 19 '22 17:09

John Saunders