如何使用Go与LDAP协议

huangapple go评论123阅读模式
英文:

How to use Go with LDAP protocol

问题

我如何使用Go直接调用和管理Ldap协议?有没有相关的包?还是必须使用UDP和TCP?

英文:

How can I use Go to call and manage Ldap protocol directly? are there any packages? or must I use udp and tcp?

答案1

得分: 18

在Go标准库中没有LDAP库,但是通过快速的谷歌搜索可以找到几个可以尝试的库:

第二个实际上是第一个的一个分支。在github上,你可以查看开放的问题、最后更新和分支网络(https://github.com/mmitton/ldap/network),以便对哪个库应该使用有一个很好的了解,当有很多分支时。

如果你需要一个在Go标准库中省略的库,有几个好的地方可以查找:

  • 总是从快速的谷歌搜索开始
  • 查看:http://go-lang.cat-v.org/pure-go-libs / http://go-lang.cat-v.org/library-bindings
  • 还有:http://godoc.org/
  • 还有:http://code.google.com/p/go-wiki/wiki/Projects

如果所有这些都失败了,而且你不想自己创建实现,记住你可以始终使用cgo来调用C代码(例如,从Go中调用许多C LDAP库)。

英文:

There is no LDAP library in the Go standard libraries, but a quick Google search reveals several you could try:

This second one is actually a fork of the first one. On github you can always view the open issues, last update and forking network (https://github.com/mmitton/ldap/network) to get a pretty good sense of which library you should use when there is a lot of forking.

If you need a library for something omitted in the Go standard libraries there are several good places to look:

If all of those fail you and you don't feel up to creating your own implementation, keep in mind you can always use cgo to call C code (such as one of the many C LDAP libraries for example) from Go.

答案2

得分: 11

我认为我应该在这里添加我的十分之一。这是一个旧帖子,但无论如何在这里。

在使用voidlogic上面提到的mmitton/ldap之后,我使用了https://github.com/mavricknz/ldap库。mmitton库的问题是它在过滤器中不能很好地处理转义字符。

测试过滤器:(&(objectClass=user)(cn=wickd(bracketTest )))

转义过滤器:(&(objectClass=user)(cn=wickd\28bracketTest \29))

MMitton库即使使用了转义过滤器,仍然返回了一个过滤器编译错误。加载了Mavricknz库后,它可以正常工作。甚至还带有EscapeFilter函数!太棒了!

无论如何...我认为我应该为那些遇到与我相同困扰的人发布这个!

英文:

Thought I should add my ten cents here. It is an old post, but here it is nonetheless

I used the https://github.com/mavricknz/ldap library after using the mmitton/ldap one as mentioned by voidlogic above. The problem with the mmitton lib is that it does not handle escape characters very well in the filter.

The test filter: (&(objectClass=user)(cn=wickd(bracketTest )))

Escaped Filter:  (&(objectClass=user)(cn=wickdbracketTest ))

The MMitton library just came back with a filter compile error even with the escaped filter. Loaded the Mavricknz lib and it worked. Even comes with EscapeFilter function! brilliance!

Anyhow... Thought I should post this for anyone that had the same struggle as I did 如何使用Go与LDAP协议

答案3

得分: 3

我开始编写一个辅助库,用于构建能够使用LDAP协议进行通信的服务器软件。
其中包含一些使用示例。

英文:

I started to write a helper library for building server software capable of speaking the LDAP protocol.
There are some usage samples included.

答案4

得分: 2

此外,关于服务器端,我之前写了一个Go语言的包,链接在这里:https://github.com/bradleypeabody/godap

它不是一个完整的LDAP服务器,但非常适合在另一个数据源上实现身份验证(我找不到其他项目来解决这个问题)。

它可以直接管理LDAP协议 如何使用Go与LDAP协议

英文:

Additionally, for the server end of it, I wrote this package (in Go) a while ago:
https://github.com/bradleypeabody/godap

It's not a full LDAP server but works well for implementing authentication on top of another data source (something I have been unable to find any other project that addresses).

It does a lot of "manage Ldap protocol directly" 如何使用Go与LDAP协议

答案5

得分: 2

对于一个简单的高级ldap客户端,请参见go-ldap-clientgo文档

https://godoc.org/?q=ldap 上的大多数选项只是另一个选项的分支,它们大多数都太低级或太有限(例如,不返回错误,这使得难以排查问题)。

英文:

For a simple high-level ldap client, see go-ldap-client, go docs.

Most of the options on https://godoc.org/?q=ldap
are just forks of another one, most of them are too low level or too limited (e.g. do not return errors
which make it hard to troubleshoot issues).

答案6

得分: 1

如果您想在您的网页上提供基于LDAP的身份验证,您可能会喜欢我创建的解决方案:go-ldapc是一个LDAP身份验证客户端模块,只有一个API。

它在github - sona-tar/go-ldapc上。

英文:

If you want to provide LDAP based authentication on your web page, you may like the solution I created: go-ldapc is a LDAP Authentication Client Module, with only one API.

It's on github - sona-tar/go-ldapc.

huangapple
  • 本文由 发表于 2013年3月4日 23:50:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/15205481.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定