///////////// Run a simple LDAP server func main() { s := ldap.NewServer() // register Bind and Search function handlers handler := ldapHandler{} s.BindFunc("", handler) s.SearchFunc("", handler) // start the server listen := "localhost:3389" log.Printf("Starting example LDAP server on %s", listen) if err := s.ListenAndServe(listen); err != nil { log.Fatal("LDAP Server Failed: %s", err.Error()) } }
///////////// Run a simple LDAP proxy func main() { s := ldap.NewServer() handler := ldapHandler{ sessions: make(map[string]session), ldapServer: "localhost", ldapPort: 10389, } s.BindFunc("", handler) s.SearchFunc("", handler) s.CloseFunc("", handler) // start the server if err := s.ListenAndServe("localhost:2389"); err != nil { log.Fatal("LDAP Server Failed: %s", err.Error()) } }