【问题标题】:Ldap query returns null result when deployed部署时 Ldap 查询返回空结果
【发布时间】: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


    【解决方案1】:

    好的,所以我忘了添加我已将运行默认应用程序池的用户帐户更改为具有运行 LDAP 查询的身份验证的用户。

    【讨论】:

      猜你喜欢
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      • 2021-11-20
      • 2019-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多