Search code examples
sql-serveroledbwindows-authentication

How do I connect to SQL Server using OLEDB using Windows Authentication connection string


I have SQL Server 2010 running in windows auth mode and the proper groups have been assigned. I can connect via the SQL Server Client Studio using windows auth. That works. But when connecting using .NET OLEDB connections it fails and I can't figure out why.

Here is the string:

data source=172.20.0.113;initial catalog=ForgeEnterprise;Integrated Security=SSPI;multipleactiveresultsets=True;App=EntityFramework

And here is the error:

Login failed for user 'MOMENTUMI\jmcclure'

Is there something I'm missing?


Solution

  • According to http://connectionstrings.com/sql-server-2008 this should do the trick

    Provider=SQLNCLI10;Server=172.20.0.113;Database=ForgeEnterprise;Trusted_Connection=yes;
    

    Where Trusted_Connection is the same as Integrated Security apparently.

    If that doesn't work, you should verify that the user is added in the permissions tab (picture) for the database, but I guess you already did that.

    As seen in this picture