【发布时间】:2010-05-10 18:55:15
【问题描述】:
我在我的 asp.net mvc 2.0 站点中使用了一个非常简单的 Ldap 查询:
String ldapPath = ConfigReader.LdapPath; 字符串 emailAddress = null;
try
{
DirectorySearcher search = new DirectorySearcher(ConfigReader.LdapPath);
search.Filter = String.Format("(&(objectClass=user)(objectCategory=person)(objectSid={0})) ", securityIdentifierValue);
// add the mail property to the list of props to retrieve
search.PropertiesToLoad.Add("mail");
var result = search.FindOne();
if (result == null)
{
throw new Exception("Ldap Query with filter:" + search.Filter.ToString() + " returned a null value (no match found)");
}
else
{
emailAddress = result.Properties["mail"][0].ToString();
}
}
catch (ArgumentOutOfRangeException aoorEx)
{
throw new Exception( "The query could not find an email for this user.");
}
catch (Exception ex)
{
//_log.Error(string.Format("======!!!!!! ERROR ERROR ERROR !!!!! in LdapLookupUtil.cs getEmailFromLdap Exception: {0}", ex));
throw ex;
}
return emailAddress;
它在我的本地主机上运行良好。当我在服务器上的 VS2010 中运行它时,它工作正常。部署时它总是返回一个空结果。
这是我的 web.config:
Visual Studio 中的 Asp.Net 配置选项。
设置和 cmets 的完整列表可以在
machine.config.cmets 通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
部分启用配置 使用的安全认证模式 ASP.NET 来识别传入用户。 -->
<!--
--> 部分启用配置 如果/当发生未处理的错误时该怎么办 在执行请求期间。具体来说, 它使开发人员能够配置 html 错误页面 代替错误堆栈跟踪显示。 -->
我在默认应用程序池下运行它。
有人看到问题了吗?这快把我逼疯了!
【问题讨论】:
标签: asp.net asp.net-mvc deployment ldap ldap-query