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

使用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条回答 默认 最新

  • dsgwoh7038 2016-12-08 14:27
    关注

    What library is this?

    I have used http://gopkg.in/ldap.v2 and in my case it was working well (with OpenLDAP server at least). It may be worth trying it - it seems to be the most used library.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器