Cuthbert
Cuthbert

Reputation: 2998

Build SQL Connection string with integrated security for use over VPN?

I have Winforms application that connects to a SQL database. We are changing the connection strings so that they will now use integrated security (Windows Authentication) instead of SQL authentication. We have a few cases where people use the application over a VPN on their home computer.

Connecting to the database with SQL authentication isn't a problem over the VPN. I was wondering if there was a way in .NET to build a connection string with user's Windows Credentials specified to connect to the SQL database.

I've seen this question. But the application I'm working with is a Click-Once application. And I'm unsure if this will work. I'm hoping for a solution that will require little-to no effort on the part of the end-user.

Upvotes: 3

Views: 1686

Answers (1)

Ben
Ben

Reputation: 35613

The VPN is a red herring. The issue is that the user is not logged in under the same domain as the SQL Server. The same issue would arise with any non-domain-joined PC, whether on a VPN or not.

  1. You could join the PC to the domain. This is the best solution.

  2. You could use the Legacy method - create matching usernames and passwords. However you then need to make sure they stay in sync.

  3. You could use the NET USE command or NetUseAdd API to log in to the domain after connecting to the VPN.

See this question for more:

Upvotes: 2

Related Questions