I want to add windows user to SQL users pragmatically. my problem is that I want to do this on systems that have SQL installed in mixed mode but I don't have username and password , I just know the instance name and I don't know how can I execute my script of adding windows user to SQL users in this situation.
I know the script is :
use master
GO
create login [<YourDomain>\User1] from windows;
GO
my connection string is :
ServerConnection myServerConnection = new ServerConnection(myinstancename);
Server myServer = new Server(myServerConnection);
SqlConnection scSqlConnction = new SqlConnection(myServerConnection.ConnectionString);
but when I create a server connection with my instance name, and want to execute script with related connection string I get the error of
login failed for user (windows user)