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



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

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

我在这里读到(LDAP 错误(,当未进行所有必要的调用或调用的操作顺序错误时,就会发生"操作错误"。

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

我的代码如下

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)
}

问题评论帮助我弄清楚了。我的基本DN关闭了。它应该是"DC=example,DC=com",而不是"OU=OUg_Applications"。

相关内容

最新更新