From: Joe Cool on 13 Jan 2010 15:01 I need to be able to connect to a database on a remote SQL Server from a .NET client using ODBC and Windows Authentication. I need to be able to specify a Domain username and password to connect where the domain username may or may not be the my currently logged in Domain username. In other words, let's say I was logged into the username DOMAIN1\user1. The username DOMAIN1\user2 has been added as a username on the SQL Server. I would like to establish a ODBC .NET connection to the remote server specifying the DOMAIN1\user2 username (and password if needed, which I would suppose it is). I have tried this with the connection string: DataSource=servername;Initial Catalog=databasename;User Id=DOMAIN1\user2;Password=password And this fails to connect. All the exception message says is "Login failed for user 'DOMAIN1\\user2'."
From: Tom Moreau on 13 Jan 2010 15:18 Remove the User Id and Password from the connect string. Check out: http://www.sqlteam.com/article/sql-server-connection-string -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "Joe Cool" <joecool1969(a)live.com> wrote in message news:be90d1ea-ed70-4d0f-8e87-fedc3e66d7eb(a)e37g2000yqn.googlegroups.com... I need to be able to connect to a database on a remote SQL Server from a .NET client using ODBC and Windows Authentication. I need to be able to specify a Domain username and password to connect where the domain username may or may not be the my currently logged in Domain username. In other words, let's say I was logged into the username DOMAIN1\user1. The username DOMAIN1\user2 has been added as a username on the SQL Server. I would like to establish a ODBC .NET connection to the remote server specifying the DOMAIN1\user2 username (and password if needed, which I would suppose it is). I have tried this with the connection string: DataSource=servername;Initial Catalog=databasename;User Id=DOMAIN1\user2;Password=password And this fails to connect. All the exception message says is "Login failed for user 'DOMAIN1\\user2'."
From: Joe Cool on 13 Jan 2010 15:30 On Jan 13, 3:18 pm, "Tom Moreau" <t...(a)dont.spam.me.cips.ca> wrote: > Remove the User Id and Password from the connect string. Check out:http://www.sqlteam.com/article/sql-server-connection-string > You have miusunderstood my question. If I take out the username and password and specify integrated security instead, the connection will attempt to connect with my currently logged in domain username. I want to be able to connect to a DIFFERENT domain username (different from my currently logged in domain username) that had been previously entered in the SQL Server's Security logins as a windows login. > > "Joe Cool" <joecool1...(a)live.com> wrote in message > > news:be90d1ea-ed70-4d0f-8e87-fedc3e66d7eb(a)e37g2000yqn.googlegroups.com... > I need to be able to connect to a database on a remote SQL Server from > a .NET client using ODBC and Windows Authentication. I need to be able > to specify a Domain username and password to connect where the domain > username may or may not be the my currently logged in Domain username. > In other words, let's say I was logged into the username > DOMAIN1\user1. The username DOMAIN1\user2 has been added as a username > on the SQL Server. I would like to establish a ODBC .NET connection to > the remote server specifying the DOMAIN1\user2 username (and password > if needed, which I would suppose it is). > > I have tried this with the connection string: > > DataSource=servername;Initial Catalog=databasename;User > Id=DOMAIN1\user2;Password=password > > And this fails to connect. All the exception message says is "Login > failed for user 'DOMAIN1\\user2'."
From: Erland Sommarskog on 13 Jan 2010 16:37 Joe Cool (joecool1969(a)live.com) writes: > I need to be able to connect to a database on a remote SQL Server from > a .NET client using ODBC and Windows Authentication. I need to be able > to specify a Domain username and password to connect where the domain > username may or may not be the my currently logged in Domain username. > In other words, let's say I was logged into the username > DOMAIN1\user1. The username DOMAIN1\user2 has been added as a username > on the SQL Server. I would like to establish a ODBC .NET connection to > the remote server specifying the DOMAIN1\user2 username (and password > if needed, which I would suppose it is). You can only log into SQL Server through Windows Authentication with the user you are currently log into Windows as. There is *no* way you can log into SQL Server as another Windows user. Thus, to do this, you would need to impersonate that user in Windows, before you event start to look at SQL Server. Whether you actually can do this, I don't know, but I know that Windows has something called Run As, so maybe. It would be a topic for different newsgroup anyway. -- Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
From: William Vaughn (MVP) on 13 Jan 2010 19:16 Mr. Sommarskog is right. Unless you execute the application using Run As, SSPI authentication picks up the credentials from the system--not the ConnectionString. -- __________________________________________________________________________ William R. Vaughn President and Founder Beta V Corporation Author, Mentor, Dad, Grandpa Microsoft MVP (425) 556-9205 (Pacific time) Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) http://betav.com http://betav.com/blog/billva ____________________________________________________________________________________________ "Erland Sommarskog" <esquel(a)sommarskog.se> wrote in message news:Xns9CFFE621218B1Yazorman(a)127.0.0.1... > Joe Cool (joecool1969(a)live.com) writes: >> I need to be able to connect to a database on a remote SQL Server from >> a .NET client using ODBC and Windows Authentication. I need to be able >> to specify a Domain username and password to connect where the domain >> username may or may not be the my currently logged in Domain username. >> In other words, let's say I was logged into the username >> DOMAIN1\user1. The username DOMAIN1\user2 has been added as a username >> on the SQL Server. I would like to establish a ODBC .NET connection to >> the remote server specifying the DOMAIN1\user2 username (and password >> if needed, which I would suppose it is). > > You can only log into SQL Server through Windows Authentication > with the user you are currently log into Windows as. There is *no* way > you can log into SQL Server as another Windows user. > > Thus, to do this, you would need to impersonate that user in Windows, > before > you event start to look at SQL Server. Whether you actually can do this, > I don't know, but I know that Windows has something called Run As, so > maybe. It would be a topic for different newsgroup anyway. > > > > -- > Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se > > Links for SQL Server Books Online: > SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx > SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx > SQL 2000: > http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx >
|
Next
|
Last
Pages: 1 2 Prev: Help with sql query Next: Can I do this? invoke function with parameter from join table |