ghost_mv
ghost_mv

Reputation: 1200

Can OLEDB connection strings be configured to use Windows Authentication?

My knowledge on OLEDB is minimal at best. Is there a way to build a connection string to use a trusted Windows authentication rather than using User ID and Password?

Upvotes: 3

Views: 16381

Answers (3)

Mehrad
Mehrad

Reputation: 4203

As MSDN states in the How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0 article,

The connection string used with Windows authentication must include either the Trusted_Connection=Yes attribute, or the equivalent attribute Integrated Security=SSPI, as shown here.

So instead of User Id=...; and Password=...; you should include one of the options below in your connection string,

  • Trusted_Connection=Yes
  • Integrated Security=SSPI

Upvotes: 1

David
David

Reputation: 73564

Yes. Here's an example for SQL Server 2008.

Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;

If your database is something other than SQL Server 2008 (and the odds are probably pretty good that it's not), you can get just about any Connection String example from this site: http://www.connectionstrings.com/

or here http://www.carlprothman.net/Default.aspx?tabid=81

Upvotes: 3

ajdams
ajdams

Reputation: 2314

Since you didn't state what language you would be using the OLEDB call through I just posted some basic C# to do the trick.

using System.Data.OleDb;

OleDbConnection conn = new OleDbConnection();
conn.ConnectionString =
"Driver=SQLOLEDB;" +
"Data Source=ServerName;" +
"Initial Catalog=DataBaseName;" +
"Integrated Security=SSPI;";

conn.Open();

Upvotes: 1

Related Questions