【问题标题】:How can I fix the error when connecting to Ldap and searching in AD?AD连接Ldap搜索报错怎么解决?
【发布时间】:2023-02-10 22:00:40
【问题描述】:

再会。通常,我切换到 Novell.directory.ldap。 Netstandart 4.0.0-beta4 因为我需要升级到 NET6。由于这个版本是最近出现的,我看不懂(我看了官网+PDF。我在指导),但是太旧了,所以不同的功能不起作用。这是我的代码,从

LdapSearchResults

已经抛出错误。

using System;

using System.Linq;

using Novell.Directory.Ldap;

Internal class Program 

{

    static void Main(string[] args)

    {

    LdapConnection ldapConn = new LdapConnection();

    ldapConn.ConnectAsync("example.example2.com", 389);

    ldapConn. BindAsync(null, null);

    LdapSearchResults lsr = (LdapSearchResults)ldapConn. SearchAsync(

    "DC=example, DC=example2, DC=com"

    LdapConnection.ScopeSub,

    "(&(&(objectCategory=person)(objectClass=user))(employeeID=[EnterEmployeeID])(telephoneNumber=*)",

    null,

    false).Result;

    while (...) 

    } 

} 

我收到这样的错误:

**System.AggregateException:** "One or more errors ocurred." 
Internal Exception
LdapLocalExection: Unmatched parentheses, right parenthesis missing

此外,没有 .Result LdapSearchResults 会立即引发错误,因此您还需要对 etm 做一些事情,但我不知道是什么。

因此,我请你帮我解决这个问题。并尝试重新创建此应用程序。

【问题讨论】:

  • 您是否在 "DC=example, DC=example2, DC=com" 后遗漏了一个 ',' ?

标签: c# asp.net ldap


【解决方案1】:

与异常显示一样,您在以下位置缺少右括号:

"(&(&(objectCategory=person)(objectClass=user))(employeeID=[EnterEmployeeID])(telephoneNumber=*))"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多