[英]Enterprise library 5 login failed for user
I've just started to use the enterprise library 5 data access application block, but I keep on getting login failed errors. 我刚刚开始使用企业库5数据访问应用程序块,但是我不断遇到登录失败的错误。
I've tried the connection string that I'm using without the application block and the connection opens fine, but as soon as I use the same connection string with the application block it fails. 我尝试了没有应用程序块的情况下使用的连接字符串,并且连接打开正常,但是一旦我将相同的连接字符串与应用程序块一起使用,它就会失败。
My code that utilises the DAAB is as follows: 我的利用DAAB的代码如下:
public List<AgentInfo> GetAgents()
{
Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LBDashData");
string sql = "Users_GetUsers";
DbCommand cmd = db.GetStoredProcCommand(sql);
List<AgentInfo> oAgents = new List<AgentInfo>();
using (IDataReader dataReader = db.ExecuteReader(cmd))
{
while (dataReader.Read())
{
AgentInfo oAgent = new AgentInfo();
oAgent.ItemID = Convert.ToInt32( dataReader["ItemID"].ToString());
oAgent.ParentID = Convert.ToInt32(dataReader["ParentID"].ToString());
oAgent.TeamID = Convert.ToInt32(dataReader["TeamID"].ToString());
oAgent.Team = dataReader["Team"].ToString();
oAgent.AgentName = dataReader["AgentName"].ToString();
oAgent.NodeType = dataReader["NodeType"].ToString();
oAgents.Add(oAgent);
}
}
return oAgents;
}
My connection string in the config has been set up as follows: 我在配置中的连接字符串已设置如下:
<connectionStrings><add name="LBDashData" connectionString="Data Source=(local);Initial Catalog=LBDash;Persist Security Info=True;User id=<userid>;password=<password>" <providerName="System.Data.SqlClient" /></connectionStrings>
If I try the same connection string with the following code it works 如果我尝试使用以下代码使用相同的连接字符串,则可以正常工作
public bool testConn ()
{
SqlConnection oconn = new SqlConnection("Data Source=(local);Initial Catalog=LBDash;Persist Security Info=True;User id=<userid>;password=<password>");
try
{
oconn.Open();
return true;
}
catch
{
return false;
}
finally
{
oconn.Close();
}
}
Does anyone have any ideas what I can try next? 有谁知道我接下来可以尝试什么?
Found solution to problem :) 找到问题的解决方案:)
< hangs head in shame > < 垂头丧气 >
I had tables in stored procedure that were using a linked server, once I set up the correct impersonation for the linked server, life was good again. 我在存储过程中有使用链接服务器的表,一旦为链接服务器设置了正确的模拟,生活就再好不过了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.