NT authentication / Active Directory

I wrote a VB application that uses SQL Server DTS packages and stored procedures.  The app pops up a login form and uses the UserID and Password supplied by the user to pass to SQL Server when loading DTS packages and when creating ADO connections.

Now I have been asked to eliminate the login form and instead use NT authentication or Active Directory (which the company uses) so SQL Server will recognize the user (or the group to which user belongs?) from the network login.  I've been researching this but I'm confused as to how to proceed.

So far, I have created a new user in Active Directory, and I have added the SQL Server instance to AD.

The goal is to transparently give the user access to a specific database on the server so they don't have to enter login info when they run this app, and to make security maintenance more streamlined.

Also, here are examples of the lines of VB code I think will have to change.  Can you provide guidance on this?

DTS:
            Call dtsExport.LoadFromSQLServer(strDTSServer, strUID, strPwd, _
                DTSSQLStgFlag_Default, , , , strDTSMainPackageName)
ADO:
            cn.ConnectionString = "DSN=MyDatabase;UID=" & strUID & ";PWD=" & strPwd

If SQL Server is not expecting a userID and pwd, can I just leave them out of these calls?

Thanks for your help!

wlevyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

danblakeCommented:
Hi wlevy,

You're nearly there..
SQL Server is not expecting a user ID / pwd combination; instead it needs to know that you wish to use Integrated Security (NT Authentication).
This is normally by adding to the cn.Connectionstring "Trusted_Connection = True" or "Integrated Security = SSPI"

If you ever forget youre connection string or want to know the difference between vendors/types try: www.connectionstrings.com

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wlevyAuthor Commented:
Great!

My code now looks like this:

ADO
cn.ConnectionString = "DSN=MyDatabase;Trusted_Connection=True;UID=" & strUID

DTS
Call dtsExport.LoadFromSQLServer(strDTSServer, strUID, , DTSSQLStgFlag_UseTrustedConnection, , , , strDTSMainPackageName)

Works like a charm.  Thanks for your help.  I'm awarding point to you.

I am getting strUID by calling the Win32 API GetUserName function.  Is that the best way to do this?

0
danblakeCommented:
You do not need the userid usually when using a trusted connection; the connection normally takes the userID automatically from the source of the connection being used.
0
wlevyAuthor Commented:
Thank you, Dan, you're absolutely right.  My boss is happy!  :)

- Walter
0
danblakeCommented:
Not a problem, glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.