How can I run my C# app using a SQLConnection to SQL Server with Windows Authentication in a PC not joined to domain?

36 Views Asked by At

I've been struggling with this for a few days.

I work as developer for a company in where is a MUST using the Windows Authentication for any app that I develop that connects to the company SQL Server databases.

Recently I had to left my company provided laptop as it is going to be replaced, but at the moment I'm working with my personal laptop for any of my tasks. Almost everything goes fine... If I need to connect to any IT resource of company I get prompted for the network domain credentials and once I typed them it allows me to access...

But I'm struggling with this; my apps makes use of a connection string created with Visual Studio IDE, but basically is:

Data Source=my_company_servers_database_ip;Initial Catalog=my_company_database;Integrated Security=True

And then I just create the connection with the code:

 var connectionString = ConfigurationManager.ConnectionStrings[
        "MyProject.Properties.Settings.MyProjectConnectionString"
    ].ConnectionString;

 sqlConnection = new SqlConnection(connectionString);

 sqlConnection.Open();

It works perfectly in any company PC joined to domain, but my personal laptop is not part of domain.

Is there someway I can connect to the database providing my company domain account credentials in someway ? I know that when I set IntegratedSecurity=True it will ignore any provided credentials in connection string and just take the ones of the current logged in user.

I think there should be someway to being able to connect to database in my personal laptop.

Note I can successfully connect to databases using SMSS with the trick of using the /runas /netonly user:domain\password.

I tried that last thing in my app but seems to not be working. Is there someway to run my C# app in my not-joined-to-domain laptop?

Thank you!

0

There are 0 best solutions below