【问题标题】:LDAPS works on Visual Studio 2008 but does not work on IIS 5.1LDAPS 适用于 Visual Studio 2008,但不适用于 IIS 5.1
【发布时间】:2009-06-12 14:10:28
【问题描述】:

我正在使用 C# 对我的应用程序的用户进行身份验证,如下所示:

LdapConnection connection = null;
       try
       {                
           using (connection = new LdapConnection(Configuration.JonahLdapServer))
           {
               connection.Credential = new NetworkCredential(userName, password, Configuration.JonahDomain);
               connection.AuthType = AuthType.Basic;
               connection.SessionOptions.SecureSocketLayer = true;
               connection.SessionOptions.VerifyServerCertificate = 
                   new VerifyServerCertificateCallback(AlwaysTrustCertificateDelegate);
               connection.Bind();
               return true;
           }
       }

当我在 VS 2008 中运行它时,它工作得很好。但是,当我将应用程序部署到 IIS 5.1 时,它给了我以下堆栈跟踪:

System.DirectoryServices.Protocols.LdapException:LDAP 服务器不可用。 System.DirectoryServices.Protocols.LdapConnection.Connect() 在 System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential,布尔需要SetCredential) 在 System.DirectoryServices.Protocols.LdapConnection.Bind() 在 Jonahgroup.Lychee.Presentation.Security.SecurityManager.AuthenticateUser(String userName, String password)

应该注意的是,如果我在没有 SSL 的情况下运行代码,它在 IIS 和 VS 上都可以正常工作。

任何帮助将不胜感激。

【问题讨论】:

    标签: c# visual-studio iis ldap


    【解决方案1】:

    IIS 帐户无权访问证书存储区。您可以更改 IIS 帐户以自己运行(不建议用于生产部署)或授予当前 IIS 帐户访问每个证书的权限(在 c:\Documents And Settings\All Users\Application Data\Microsoft\Crypto\ RSA)。

    顺便发现了一个类似的帖子,作者可以从IUSR_账号切换IIS账号使用ASPNET。

    http://www.velocityreviews.com/forums/t109404-aspnet-and-ldap.html

    【讨论】:

      【解决方案2】:

      应该注意的是,如果我在没有 SSL 的情况下运行代码,它在 IIS 和 VS 上都可以正常工作。

      这意味着问题更多地与您的 ssl 配置有关,尽管为什么您在 windows xp (iis 5.1) 上运行它,这是一个桌面级系统,而不是 windows 服务器版本不清楚。

      【讨论】:

      • 我不明白 SSL 配置如何在这里发挥作用。安全连接位于代码和 ldap 服务器之间。因此,IIS 不应该关心身份验证是如何完成的(除非需要使用 IIS 配置 ldap 设置,我不知道)。
      猜你喜欢
      • 2013-04-30
      • 1970-01-01
      • 2015-11-23
      • 2021-02-25
      • 2020-06-13
      • 2015-07-02
      • 2016-04-25
      • 1970-01-01
      • 2011-09-27
      相关资源
      最近更新 更多