Build SQL Connection string with built-in security for use over VPN?
I have a Winforms application that connects to a SQL database. We are changing the connection strings to use Integrated Security (Windows Authentication) instead of SQL Authentication. We have a couple of cases where people use an app over a VPN on their home computer.
Connecting to the database using SQL authentication is not a problem for VPN. I was wondering if there is a way in .NET to create a connection string with the Windows user credentials specified to connect to a SQL database.
I've seen this question. But the app I'm working with is a Click-Once app. And I'm not sure if this will work. I hope for a solution that requires little or no effort on the part of the end user.
source to share
VPN is a red herring. The problem is that the user is not logged in under the same domain as SQL Server. The same problem would occur with any PC connected without a domain, VPN or not.
-
You can join a PC in the domain. This is the best solution.
-
You can use the Legacy method - create appropriate usernames and passwords. However, you need to make sure they stay in sync.
-
You can use NET USE command or API
NetUseAdd
to log into the domain after connecting to VPN.
See this question for details:
-
This is the best you can use: SQL Server Integrated Security
-
But see also this: SQL Server Management Studio 2008 Runas User for Different Domains via VPN
source to share