Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Go with LDAP protocol [closed]

Tags:

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

like image 774
Mahdi Sardari Avatar asked Mar 04 '13 15:03

Mahdi Sardari


People also ask

What protocol is used by LDAP?

Lightweight Directory Access Protocol (LDAP) is an internet protocol works on TCP/IP, used to access information from directories.

How does LDAP connect to Active Directory?

The way you begin an LDAP session is by connecting to an LDAP server, known as a Directory System Agent, which “listens” for LDAP requests. “Domain controller” is another name for the server responsible for security authentication requests. For users, domain control (DC) is the centerpiece of Active Directory.

How does LDAP authorization work?

In short, a client sends a request for information stored within an LDAP database along with the user's credentials to an LDAP server. The LDAP server then authenticates the credentials submitted by the user against their core user identity, which is stored in the LDAP database.


2 Answers

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

  • https://github.com/mmitton/ldap
  • https://github.com/tonnerre/go-ldap

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:

  • Always start with a quick Google search
  • Checkout: http://go-lang.cat-v.org/pure-go-libs / http://go-lang.cat-v.org/library-bindings
  • And: http://godoc.org/
  • And: http://code.google.com/p/go-wiki/wiki/Projects

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.

like image 70
voidlogic Avatar answered Sep 25 '22 00:09

voidlogic


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=wickd\28bracketTest \29)) 

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

like image 23
wickd Avatar answered Sep 25 '22 00:09

wickd