SQL Server 2005 username/password validation

  • 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.

  • 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:

    www.connectionstrings.com

    Greets

    Flo

  • 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?

  • 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

  • Florian Reischl (5/13/2009)


    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

    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]

  • 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