mirror of
https://github.com/netauth/ldap.git
synced 2024-11-24 12:31:55 -06:00
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package ldap
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/ps78674/goldap/message"
|
|
ldap "github.com/ps78674/ldapserver"
|
|
|
|
"github.com/netauth/ldap/internal/buildinfo"
|
|
)
|
|
|
|
func (s *server) handleSearchDSE(w ldap.ResponseWriter, m *ldap.Message) {
|
|
nc := strings.Join(s.nc, ", ")
|
|
|
|
e := ldap.NewSearchResultEntry("")
|
|
e.AddAttribute("vendorName", "NetAuth")
|
|
e.AddAttribute("vendorVersion", message.AttributeValue(buildinfo.Version))
|
|
e.AddAttribute("objectClass", "top", "extensibleObject")
|
|
e.AddAttribute("supportedLDAPVersion", "3")
|
|
e.AddAttribute("namingContexts", message.AttributeValue(nc))
|
|
w.Write(e)
|
|
|
|
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultSuccess)
|
|
w.Write(res)
|
|
}
|
|
|
|
func (s *server) handleSearch(w ldap.ResponseWriter, m *ldap.Message) {
|
|
r := m.GetSearchRequest()
|
|
log.Printf("Request BaseDn=%s", r.BaseObject())
|
|
log.Printf("Request Filter=%s", r.Filter())
|
|
log.Printf("Request FilterString=%s", r.FilterString())
|
|
log.Printf("Request Attributes=%s", r.Attributes())
|
|
log.Printf("Request TimeLimit=%d", r.TimeLimit().Int())
|
|
|
|
// Handle Stop Signal (server stop / client disconnected / Abandoned request....)
|
|
select {
|
|
case <-m.Done:
|
|
log.Print("Leaving handleSearch...")
|
|
return
|
|
default:
|
|
}
|
|
|
|
e := ldap.NewSearchResultEntry("cn=Valere JEANTET, " + string(r.BaseObject()))
|
|
e.AddAttribute("mail", "valere.jeantet@gmail.com", "mail@vjeantet.fr")
|
|
e.AddAttribute("company", "SODADI")
|
|
e.AddAttribute("department", "DSI/SEC")
|
|
e.AddAttribute("l", "Ferrieres en brie")
|
|
e.AddAttribute("mobile", "0612324567")
|
|
e.AddAttribute("telephoneNumber", "0612324567")
|
|
e.AddAttribute("cn", "Valère JEANTET")
|
|
w.Write(e)
|
|
|
|
e = ldap.NewSearchResultEntry("cn=Claire Thomas, " + string(r.BaseObject()))
|
|
e.AddAttribute("mail", "claire.thomas@gmail.com")
|
|
e.AddAttribute("cn", "Claire THOMAS")
|
|
w.Write(e)
|
|
|
|
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultSuccess)
|
|
w.Write(res)
|
|
}
|