2018-05-10 21:12:42 +00:00
|
|
|
package ldaputil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
|
2019-11-08 16:18:36 +00:00
|
|
|
"github.com/go-ldap/ldap/v3"
|
2018-05-10 21:12:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewLDAP() LDAP {
|
|
|
|
return &ldapIfc{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// LDAP provides ldap functionality, but through an interface
|
|
|
|
// rather than statically. This allows faking it for tests.
|
|
|
|
type LDAP interface {
|
|
|
|
Dial(network, addr string) (Connection, error)
|
|
|
|
DialTLS(network, addr string, config *tls.Config) (Connection, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ldapIfc struct{}
|
|
|
|
|
|
|
|
func (l *ldapIfc) Dial(network, addr string) (Connection, error) {
|
|
|
|
return ldap.Dial(network, addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *ldapIfc) DialTLS(network, addr string, config *tls.Config) (Connection, error) {
|
|
|
|
return ldap.DialTLS(network, addr, config)
|
|
|
|
}
|