May 12, 2009 at 11:41 am
Hi All,
I have setup my SQL Server 2005 using windows authentication. I can connect to SQL Server 2005 without any issues. But I'm facing issues in connecting to SQL Server 2005 using VB.Net.
How do I accept user name/password and create an SQL Server 2005 (which uses windows authentication) connection using that user name/password. The screen to accept username/password is developed in VB.net.
May 12, 2009 at 1:07 pm
Hi
You don't have to specify username/password in this case. Here an example connection-string:
This works for OLEDB and SQL Server Client:
"Data Source=YourServer;Initial Catalog=YourDb;Integrated Security=SSPI;"
If you use SQL Server Client you can simplify:
"Server=YourServer;Database=YourDb;Integrated Security=SSPI;"
For further information:
Greets
Flo
May 12, 2009 at 6:53 pm
I understand I don't have to specify username/password. But is there anyway to go thru windows authenication by providing windows username/password while establishing the DB connection or to override credentials of current logged in user with some other users during windows authentication for SQL connection?
May 13, 2009 at 3:25 am
Hi
Usually your application connects with windows credentials of the current connected user to connect to database.
If you want to use windows authentication but connect with another user you have to look for impersonation to change the windows account of your process while run time.
Greets
Flo
May 13, 2009 at 7:52 am
Florian Reischl (5/13/2009)
HiUsually your application connects with windows credentials of the current connected user to connect to database.
If you want to use windows authentication but connect with another user you have to look for impersonation to change the windows account of your process while run time.
Greets
Flo
Agreed, this actually has to occur inside your application layer, and it requires unmanaged hooks into the win32 LoginUser API. You can find an example on codeproject:
http://www.codeproject.com/KB/cs/cpimpersonation1.aspx
What you are trying to do is not hard, but it is not trivial either.
Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]
May 13, 2009 at 6:46 pm
Florian, Jonathan,
Thank your very much for your help. The sample codeproject code helped !!.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply