Re: JDBC connection to SQL Server 2005 with domain user



On Feb 1, 11:50 am, "Rupert Woodman" <rupert.wood...@xxxxxxxxxxxxxx>
wrote:
I can connect to a SQL Server 2005 database using the Microsoft JDBC driver,
using either a SQL Server user, or using the credentials of the user
currently logged in without any problems.
However, I want to login using a domain user, different to the user
currently logged in to the machine running the application.

I've tried using both URL connection strings and a Properties object, but I
can't get it to work. As soon as I specify "integratedSecurity=true", it
uses the credentials of the current user.

I'm sure it must be possible, but I couldn't find anything on Google.
Could someone give me a clue (or an example would be even better!) please?

Many thanks

You're not going to make that work. You have two choices:

1 - set an explicit user and password string in the properties for the
driver to send to the DBMS. That will work anywhere for any OS user
as long as the DBMS user/password are valid.

2 - Use the driver's integrated security, which automatically absorbs
the *current OS user's* identity to verify with the DBMS at runtime.

There is no way to tell the driver/JVM/Windows to automatically act
as if some other person is running your Java program.

Joe Weinstein at BEA Systems

.