Exemplo n.º 1
0
func main() {
	s := ldap.NewServer()
	handler := ldapHandler{}
	searchHandler := searchSimple{}
	log.Println("Starting server on localhost:1389")
	s.BindFunc("", handler)
	s.SearchFunc("", searchHandler)
	if err := s.ListenAndServe("localhost:1389"); err != nil {
		log.Fatal("LDAP Server Failed: %s", err.Error())
	}
}
Exemplo n.º 2
0
func main() {
	stderr := initLogging()
	log.Debug("AP start")

	cfg, err := doConfig()
	if err != nil {
		log.Fatalf("Configuration file error: %s", err.Error())
	}
	if cfg.Syslog {
		enableSyslog(stderr)
	}

	// stats
	stats_general.Set("version", stringer(version))

	// web API
	if cfg.API.Enabled {
		log.Debug("Web API enabled")
		go RunAPI(cfg)
	}

	// configure the backend
	s := ldap.NewServer()
	s.EnforceLDAP = true
	var handler Backend
	switch cfg.Backend.Datastore {
	case "ldap":
		handler = newLdapHandler(cfg)
	case "config":
		handler = newConfigHandler(cfg)
	default:
		log.Fatalf("Unsupported backend %s - must be 'config' or 'ldap'.", cfg.Backend.Datastore)
	}
	log.Notice(fmt.Sprintf("Using %s backend", cfg.Backend.Datastore))
	s.BindFunc("", handler)
	s.SearchFunc("", handler)
	s.CloseFunc("", handler)

	// start the frontend server
	if cfg.Frontend.TLS {
		log.Notice(fmt.Sprintf("Frontend LDAPS server listening on %s", cfg.Frontend.Listen))
		if err := s.ListenAndServeTLS(cfg.Frontend.Listen, cfg.Frontend.Cert, cfg.Frontend.Key); err != nil {
			log.Fatalf("LDAP Server Failed: %s", err.Error())
		}
	} else {
		log.Notice(fmt.Sprintf("Frontend LDAP server listening on %s", cfg.Frontend.Listen))
		if err := s.ListenAndServe(cfg.Frontend.Listen); err != nil {
			log.Fatalf("LDAP Server Failed: %s", err.Error())
		}
	}
	log.Critical("AP exit")
}
Exemplo n.º 3
0
///////////// 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())
	}
}
Exemplo n.º 4
0
///////////// Run a simple LDAP proxy
func main() {
	s := ldap.NewServer()

	handler := ldapHandler{
		sessions:   make(map[string]session),
		ldapServer: "localhost",
		ldapPort:   3389,
	}
	s.BindFunc("", handler)
	s.SearchFunc("", handler)
	s.CloseFunc("", handler)

	// start the server
	if err := s.ListenAndServe("localhost:3388"); err != nil {
		log.Fatal("LDAP Server Failed: %s", err.Error())
	}
}