Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic ASP - SQL Server 2008 Connection String using Windows Authentication

This should be painfully simple, but I cannot come up with a working connection string for a local copy of SQL Server 2008 using Windows Authentication. I've tried using the Data Link Properties tool to create a connection string and it has no problems connecting, but when I copy paste the generated string into my ADODB.Connection object's ConnectionString property I get all sorts of fun and different errors.

Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);"

Microsoft OLE DB Service Components (0x80040E21) Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

I've tried a variety of similar connection strings but I cannot find one that will work with Windows Authentication. Can someone point me in the right direction?

Thanks!

like image 607
Nathan Taylor Avatar asked Aug 31 '09 21:08

Nathan Taylor


People also ask

How do I connect to SQL Server Remote using Windows Authentication?

Right-click on your server name and click 'Properties'. Go to the Security page for Server Authentication, and select 'SQL Server and Windows Authentication' mode. Then, go to the Connections page and ensure that "Allow remote connections to this server" is checked, and click OK.

Does SQL database support Windows integrated authentication?

To connect to SQL Server using Windows integrated authentication, you must identify the Windows identity under which your ASP.NET application is running. You must also be sure that the identity has been granted access to the SQL Server database.

How does Windows Authentication work in SQL Server?

Windows authentication uses a series of encrypted messages to authenticate users in SQL Server. When SQL Server logins are used, SQL Server login names and encrypted passwords are passed across the network, which makes them less secure.

How do you give a connection string in AppSettings JSON for Windows Authentication?

Adding the AppSettings.json file Then click Add, then New Item and then choose App Settings File option (shown below) and click Add button. Once the File is created, it will have a DefaultConnection, below that a new Connection String with Windows Authentication is added.


2 Answers

Here's an easy way to generate connection strings that work.

  1. Right-click an empty spot on the desktop and choose NEW, TEXT DOCUMENT from the context menu

  2. Save it with a .udl extension, and click yes when it asks are you sure.

  3. Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.

  4. Go to the Connection tab and fill in the server name and database name, and choose NT authentication (or use a specific username and password, which is SQL authentication). Now click Test Connection. If it works, you're ready to click OK and move on to the final step. If it doesn't you need to resolve permission issues, or you've mis-typed something.

  5. Now right-click the file on the desktop and open it in notepad. It will display the connection string that you can copy and paste to wherever you need it.

like image 99
Mike Avatar answered Oct 20 '22 08:10

Mike


I assume you have the 2008 Native Client installed? Also, I noticed that you're missing the "provider" tag at the beginning - do you have any more luck with this one:

Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);
like image 30
SqlRyan Avatar answered Oct 20 '22 07:10

SqlRyan