【问题标题】:Inherited ASP.NET code that connects to OD not working when connected to AD连接到 OD 的继承的 ASP.NET 代码在连接到 AD 时不起作用
【发布时间】:2012-05-25 04:39:54
【问题描述】:

我继承了一个连接到我们的 Open Directory 以提供 Web 身份验证的软件。当连接到 OD 时,它就像一个魅力,但我们希望过渡到使用 Active Directory 作为我们的主要身份验证提供程序。

显然,两者之间的 LDAP 方案存在差异,我在过去的 6 个小时里一直在谷歌搜索和阅读,但我仍然有点不知所措。当您尝试登录 web interface 时,会显示错误(这是 Web 界面的样子 http://cl.ly/Grgo);

异常详情:

System.DirectoryServices.DirectoryServicesCOMException:一个操作 发生错误。
[DirectoryServicesCOMException (0x80072020):发生操作错误。]
C:\Program 中的 LBOX.Membership.LDAPMembershipProvider.ValidateUser(字符串用户名,字符串密码) Files\CruiseControl.NET\server\users.lbox.com\WorkingDirectory\LDAPMembershipProvider\LDAPMembershipProvider.cs:59
c:\Program 中的 LBUserService.Login.loginButton_Click(Object sender, EventArgs e) Files\CruiseControl.NET\server\users.lbox.com\WorkingDirectory\LBUserService\Login.aspx.cs:21
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

这显然与LDAPMembershipProvider.cs 的第59 行和我的web.config 文件有关。

来自 CruiseControl.net 的 web.config 文件

<membership defaultProvider="LDAP">
  <providers>
    <add name="LDAP" 
         type="LBOX.Membership.LDAPMembershipProvider" 
         LDAPRoot="LDAP://10.0.1.19:389/cn=administrator,cn=users,dc=office,dc=lbox,dc=com" />
  </providers>
</membership>

第 59 行来自LDAPMembershipProvider.cs

// Attempt to log into the LDAP server as this user
DirectoryEntry root2 = new DirectoryEntry(LDAPRoot, distinctName, password, AuthenticationTypes.ServerBind);
DirectorySearcher searcher2 = new DirectorySearcher(root2);
searcher2.SearchScope = SearchScope.Subtree;
searcher2.Filter = String.Format("cn={0}", username);

我几乎可以肯定,这与我使用 LDAP:// 连接到 AD 的方式有关,我尝试过但无法连接。即使只是猜测,任何帮助都将不胜感激。想法是允许AD在不受约束的情况下验证用户名和密码。

【问题讨论】:

    标签: asp.net active-directory ldap


    【解决方案1】:

    web.config 中的 LDAPRoot 路径对我来说有点可疑 - 它似乎表示实际的用户

    LDAPRoot="LDAP://10.0.1.19:389/cn=administrator,cn=users,dc=office,dc=lbox,dc=com"
                                   ****************
                                   User "administrator" 
    

    但这不应该是某种容器吗?在对用户进行身份验证时,我假设 LDAP 成员资格提供商必须在 LDAP 容器内查找敲击您的数字门的用户,以查看他/她是否有效。

    您正在基于该 LDAP 根目录创建目录搜索器 - 并且在用户中搜索 通常不会返回任何结果...。

    我会尝试使用

    LDAPRoot="LDAP://10.0.1.19:389/cn=users,dc=office,dc=lbox,dc=com"
    

    这只会在cn=users 容器内进行搜索,并承诺更多的结果机会,我希望!

    【讨论】:

    • 感谢您的建议。这可以连接到 OpenDirectory LDAP &lt;add name="LDAP" type="LBOX.Membership.LDAPMembershipProvider" LDAPRoot="LDAP://10.0.1.6:389/cn=users,dc=fileserver,dc=office,dc=lbox,dc=com" /&gt; 如果我希望它连接到 Windows 2008 R2 Active Directory,那么在同一行中是否有方案更改? AD 的主机名是winvm1 域是office.lbox.com
    • 我会尝试:LDAPRoot="LDAP://winvm1/cn=users,dc=office,dc=lbox,dc=com" - 我从您的 LDAP 字符串中删除了 IP 和端口,以及 dc=fileserver - 它有效吗?
    猜你喜欢
    • 2023-03-28
    • 2023-03-22
    • 1970-01-01
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    相关资源
    最近更新 更多