how to use windows authentication with vb .net 2003 application connecting to sql 2005

Posted on 2009-02-09
Last Modified: 2012-05-06
I have an application that I want the user that is logged on to use their login session as security for connecting to a database on a sql server 2005.

Or, how do I pass credentials or not to a connection string on the db connection in my app so i can open a connection to the database without hard coding an ID or password to the connection string.

Thank You.
Question by:mphillip85
    LVL 8

    Expert Comment

    LVL 8

    Expert Comment

    create users on the SQL Server using Enterprise Manager. Users is located under your SQL Server -> Security -> Logins.

    Create a new login, and tick "SQL Authentication". Then on the database tab, click the databases you want that user to access.

    Once this is done, I then used a document on MSDN to use a login screen that looks at the logins on the server.
    This document can be found:

    You will need to sit and work out what each section does, I basically copy and pasted all the programming from the document to my project, changed the database / IP settings as necessary, and then printed out the programming, looked at it, worked out what it does and made other changes from there.


    Author Comment

    I have my code already checking to see if the security group that has been assigned permissions to the database is created, if so then i check if the user that is logge on is in that security group.  

    Now i need to be able to connect to a database (passthrough authentication) without having to logon again.

    You know like outlook email, where you can logon to the pc then open your mail without having to put your name and or password /profile in again.
    LVL 8

    Accepted Solution

    Do you mean something lie this

    connstring = "Data Source=myserver;Initial Catalog=databasename;Integrated Security=True"

    Author Comment

    Here is my conn string;

    Trust Server Certificate=False;User ID=123;Tag with column collation when possible=False;Data Source="Server";Password="123";Initial Catalog=Redwood_II;DataTypeCompatibility=0;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=True;Provider="SQLNCLI.1";MARS Connection=False;Workstation ID=PLUTO;Use Encryption for Data=False;Packet Size=4096

    How do i change that to allow me to use my logon ID as windows authentication to connect to database?

    Thank You

    Author Closing Comment

    Integrated Security= True , for what I needed is Integrated Security=SSPI;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now