我正在尝试确定我的应用程序用于向我的数据库进行身份验证的用户,有没有办法让我可以获得用于执行sql代码的用户?
string connection = WebConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connection))
{
using (SqlDataAdapter adapter = new SqlDataAdapter())
{
adapter.SelectCommand = new SqlCommand();
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
adapter.SelectCommand.CommandText = "MySPName";
adapter.SelectCommand.Connection = conn;
using (DataSet ds = new DataSet())
{
try
{
adapter.SelectCommand.Connection.Open();
logULS("Connection Open");
//Want to log the user that has the connection open...
adapter.Fill(ds);
adapter.SelectCommand.Connection.Close();
}
catch (Exception ex)
{
logULS(ex.ToString());
}
}
}