doucuyu2259
2016-10-06 18:32
浏览 705
已采纳

使用goLang的LDAP认证

I am trying to authenticate with LDAP server using goLang also trying to search the user. I am new to goLang and LDAP so I pulled GitHub code. While trying with below code, I am getting error in authentication

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)

Note: LDAP server working with http connection

Could anyone help me to fix this...

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题