Perhaps someone can help me out here. I'm writing a program in C# to connect to a database on a remote server. The server in question uses Windows Authentication. I'm also not the admin of the server.
In any event to connect to server using SQL Server Management Studio I have to use a different credentials. So I use the runas.exe to connect.
Basically, Something along the lines of:
runas.exe /netonly /user:DIFFERENT_DOMAIN\SAME_USERNAME "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
Using the runas.exe is the only way I can connect to the database, if I try running ssms without the runas, I will not connect at all.
So now my question. In the program I'm making in C#. How can I get my program to connect to the same database using different credentials without having to use runas.exe?
I've tried using:
Sqlconnection sc = new Sqlconnection();
sc.ConnectionString = "Data Source= myServer;Initial Catalog= myDB;Integrated Security=true";
sc.Open();
But I just get "Login failed for user ''. User not associated with a trusted SQL Server Connection."
If I use the above code and Runas.exe with the correct credentials. It will work fine and connect. However I don't want to have to use it.
Anyone have any idea how to get the connection to work?