You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Connection pooling encapsulated for go-ldap packets
The official package does not provide connection pooling by default. In some cases, we will generate too many requests and exceed the connection limit, resulting in an error of closed (connection lost).
This library will be aimed at solving this problem。
Use the example:
package main
import (
"fmt""github.com/eryajf/ldapool""github.com/go-ldap/ldap/v3"
)
funcmain() {
ldapConf:= ldapool.LdapConfig{
Url: "ldap://localhost:389",
BaseDN: "dc=eryajf,dc=net",
AdminDN: "cn=admin,dc=eryajf,dc=net",
AdminPass: "123456",
MaxOpen: 30,
}
conn, err:=ldapool.Open(ldapConf)
iferr!=nil {
panic(fmt.Sprintf("get conn failed:%v\n", err))
}
// Construct query requestsearchRequest:=ldap.NewSearchRequest(
ldapConf.BaseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
"(&(objectClass=*))",
[]string{},
nil,
)
// Search through ldap built-in searchsr, err:=conn.Search(searchRequest)
iferr!=nil {
fmt.Printf("search err:%v\n", err)
}
// Refers to the entry that returns data. If it is greater than 0, the interface returns normally.iflen(sr.Entries) >0 {
for_, v:=rangesr.Entries {
fmt.Println(v.DN)
}
}
}
The above are examples of the use of the current package。
If you want to connect to more go-ldap library usage, you can refer to another project of mine. It is ldapctl.
Thanks to RoninZc, he wrote most of the code. I integrated it on the basis of it.
About
Connection pooling encapsulated for go-ldap packets