2
我正嘗試使用goLang驗證LDAP服務器並嘗試搜索用戶。 我是goLang和LDAP的新手,所以我推出了GitHub代碼。 雖然與下面的代碼嘗試,我得到錯誤認證使用goLang進行LDAP驗證
func ExampleLDAPClient_Authenticate() {
client := &ldap.LDAPClient{
Base: "cn=admin,dc=testing,dc=io",
Host: "52.51.245.219",
Port: 389,
UseSSL: false,
BindDN: "cn=admin,dc=testing,dc=io",
BindPassword: "test123",
UserFilter: "(uid='*api*')",
// GroupFilter: "(memberUid=%s)",
Attributes: []string{"givenName", "sn", "mail", "uid"},
}
defer client.Close()
username := "cn=admin,dc=testing,dc=io"
password := "test123"
ok, user, err := client.Authenticate(username, password)
if err != nil {
log.Fatalf("Error authenticating user %s: %+v", "*cn=admin,dc=testing,dc=io*", err)
}
if !ok {
log.Fatalf("Authenticating failed for user %s", "*cn=admin,dc=testing,dc=io*")
}
log.Printf("User: %+v", user)
}
go run example.go 2016/10/06 23:52:25 Error authenticating user *cn=admin,dc=testing,dc=io*: LDAP Result Code 201 "": ldap: finished compiling filter with extra at end: %!(EXTRA string=bmui)
注:LDAP服務器的HTTP連接工作
誰能幫我解決這個問題...