如何修复 GoLang 的 LDAP 过滤器操作错误?

How can I fix GoLang's LDAP Filter Operations Error?

所以我是 GoLang 的新手,我正在尝试制作 LDAP 过滤器。但是,我不断收到以下错误:

LDAP Result Code 1 "Operations Error": 000020D6: SvcErr: DSID-031007E5, problem 5012 (DIR_ERROR), data 0

我在此处 (LDAP Errors) 读到 "Operations Error" 发生在未完成所有必要的调用或调用的操作顺序错误时。

老实说,我不确定我可能遗漏了什么或者我做错了什么。

我的代码如下

 import (
    "crypto/tls"
    "fmt"
    "github.com/go-ldap/ldap/v3"
    "log"
)


func ApiCaller(){
    // The username and password we want to check
    username := "username"
    password := "password"

    //Establishing connection to the LDAP server
    l, err := ldap.Dial("tcp", "exampleURL.com:389")
    if err != nil {
        log.Fatal(err)
    }

    // Closing connection in case of error
    defer l.Close()

    // Reconnect with TLS
    err = l.StartTLS(&tls.Config{InsecureSkipVerify: true})
    if err != nil {
        log.Fatal(err)
    }

    // Bind as the user to verify their password
    err = l.Bind(username, password)
    if err != nil {
        log.Fatal(err)
    }
    // Setting up the search criterias with filter
    searchRequest := ldap.NewSearchRequest(
        "OU=OUg_Applications",
        ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
        fmt.Sprintf("(&(OU=OUg_Applications))"),
        []string{""},
        nil,
    )

    // Performing search in the LDAP Server
    sr, err := l.Search(searchRequest)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(sr.Entries)
}

问题评论帮助我弄明白了。我的 base-DN 已关闭。它应该是 "DC=example,DC=com",而不是 "OU=OUg_Applications"。