Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 要始终以其他用户身份打开我的windows应用程序吗_C#_Sql_Connection String_Impersonation - Fatal编程技术网

C# 要始终以其他用户身份打开我的windows应用程序吗

C# 要始终以其他用户身份打开我的windows应用程序吗,c#,sql,connection-string,impersonation,C#,Sql,Connection String,Impersonation,我希望在c#中始终以不同域上的不同用户的身份打开windows应用程序。我已将下拉列表的连接字符串设置为“Server=HRAOSQLSAV1\SAI01;DataBase=Diablo;Integrated Security=SSPI;User Id=xxxxx\xxxxx;password=xxxxxxxxxxxxx”,但它始终接受我的本地计算机凭据,但不接受我在连接字符串中提供的凭据。但是,如果我以连接字符串中指定的用户身份运行.exe,它将运行得非常完美。有人能帮我解决这个问题吗 con

我希望在c#中始终以不同域上的不同用户的身份打开windows应用程序。我已将下拉列表的连接字符串设置为“Server=HRAOSQLSAV1\SAI01;DataBase=Diablo;Integrated Security=SSPI;User Id=xxxxx\xxxxx;password=xxxxxxxxxxxxx”,但它始终接受我的本地计算机凭据,但不接受我在连接字符串中提供的凭据。但是,如果我以连接字符串中指定的用户身份运行.exe,它将运行得非常完美。有人能帮我解决这个问题吗

const string dataSource = "Server=HRAOSQLSAV1\\SAI01; DataBase=Diablo;"
                        + "Integrated Security=SSPI;User Id = xxxxxxxxx; "
                        + "password = xxxxxxxxxxx";
SqlConnection connection = new SqlConnection(dataSource);
connection.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read()) {
    PICFilter.Items.Add(dr.GetString(0));
}
connection.Close(); 

我们可以看看你用来打开连接的代码吗?这个连接字符串存储在哪里?windows应用程序的哪个部分构造了连接字符串?@DeeMac:我不知道哪个部分构造了连接字符串。你能帮我找到它吗?我想你在找。此外,这里还有一个将其与SQL结合使用的好例子:尝试删除位integratedsecurity=SSPI;