go-guardian icon indicating copy to clipboard operation
go-guardian copied to clipboard

Doesn't work with LDAP version >3.4.4

Open iliesh opened this issue 2 months ago • 0 comments

What version of Go are you using (go version)?

$ go version
go version go1.22.4 linux/amd64

Does this issue reproduce with the latest release?

yes

What version of Go-Guardian are you using ?

Go-Guardian Version: 
github.com/shaj13/go-guardian/v2 v2.11.5

What did you do?

var strategy auth.Strategy
var cacheObj libcache.Cache

func InitLDAPConnection(cfg *config.Config) {
	ldapConfig := &ldap.Config{
		BaseDN:       cfg.LDAPBaseDN,
		BindDN:       "uid=" + cfg.LDAPBindUser + "," + cfg.LDAPBaseDN,
		Port:         cfg.LDAPPort,
		Host:         cfg.LDAPHost,
		BindPassword: cfg.LDAPBindPassord,
		Filter:       "(uid=%s)",
	}
	cacheObj = libcache.FIFO.New(0)
	cacheObj.SetTTL(time.Minute * 10)
	strategy = ldap.NewCached(ldapConfig, cacheObj)
}

What did you see instead?

# github.com/shaj13/go-guardian/v2/auth/strategies/ldap
/home/user/go/pkg/mod/github.com/shaj13/go-guardian/[email protected]/auth/strategies/ldap/ldap.go:71:9: cannot use ldap.DialURL(cfg.URL, opts...) (value of type *"github.com/go-ldap/ldap/v3".Conn) as conn value in return statement: *"github.com/go-ldap/ldap/v3".Conn does not implement conn (wrong type for method Close)
                have Close() (error)
                want Close()

Works ok with LDAP version 3.4.4:

github.com/go-ldap/ldap/v3 v3.4.4

iliesh avatar Jun 21 '24 13:06 iliesh