tags:

views:

105

answers:

2

Is there a way to explicitly specify a user/domain/password when using windows authentication for MS SQL?

I mean in the connection string.

Edit: I would like to connect to another SQL server with a specific username and password on a different computer so impersonating I don't think is possible.

+1  A: 

No that is not possible. When using Windows authentication you send the current user's identity and you have no way of specifying that explicitly. You could change the current thread principal though.

Otávio Décio
+4  A: 

No, there isn't - your two choices in the connection string are Integrated Authentication (the current Windows user) and SQL authentication.

If I understand you correctly, what you're trying to do it log in to the SQL Server as a different Windows user. You can look at either impersonating a user (though this would have to be a separate process, not your main application), or you can look into something like Database Roles:

MSDN Article

UPDATE: Since you've stated that you're in a workgroup (I assume both the client and server are), then this blog post seems to say that as long as the username and password you're using exactly match a user on the server, you should be okay. Not sure if this is a possibility, but worth consider. Also, if either computer is on a domain, the bet is off - in that case, you'll have to impersonate to make this happen.

rwmnau
Yes correct I'd like to explicitly specify a different username/password. Impersonating I don't think will be an option because the SQL computer is on a different computer.
Brian R. Bondy
If you're on a domain, it's definitely an option, but if you're just in a workgroup, things get a little hairier. What language are you calling the SQL Server from? Any other details you have, and maybe we can lead you to some impersonation code or something else that will work.
rwmnau