package main import ( "html/template" "log" "net/http" ) func tryLogin(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { displayTmpl(w, "login.html", map[string]interface{}{}) return } conn, err := myLDAP.Connect() if err != nil || conn == nil { log.Println(err) displayTmplError(w, http.StatusInternalServerError, "login.html", map[string]interface{}{"error": err.Error()}) } else if err := conn.ServiceBind(); err != nil { log.Println(err) displayTmplError(w, http.StatusInternalServerError, "login.html", map[string]interface{}{"error": err.Error()}) } else if dn, err := conn.SearchDN(r.PostFormValue("login")); err != nil { log.Println(err) displayTmplError(w, http.StatusInternalServerError, "login.html", map[string]interface{}{"error": err.Error()}) } else if err := conn.Bind(dn, r.PostFormValue("password")); err != nil { log.Println(err) displayTmplError(w, http.StatusUnauthorized, "login.html", map[string]interface{}{"error": err.Error()}) } else if entries, err := conn.GetEntry(dn); err != nil { log.Println(err) displayTmplError(w, http.StatusInternalServerError, "login.html", map[string]interface{}{"error": err.Error()}) } else { cnt := "")}) } }