// handleBind return Success if login == mysql func handleBind(w ldap.ResponseWriter, m *ldap.Message) { r := m.GetBindRequest() res := ldap.NewBindResponse(ldap.LDAPResultSuccess) if string(r.Name()) == "myLogin" { w.Write(res) return } log.Printf("Bind failed User=%s, Pass=%s", string(r.Name()), string(r.AuthenticationSimple())) res.SetResultCode(ldap.LDAPResultInvalidCredentials) res.SetDiagnosticMessage("invalid credentials") w.Write(res) }
func handleBind(w ldap.ResponseWriter, m *ldap.Message) { r := m.GetBindRequest() res := ldap.NewBindResponse(ldap.LDAPResultSuccess) if r.AuthenticationChoice() == "simple" { if string(r.Name()) == "login" { w.Write(res) return } log.Printf("Bind failed User=%s, Pass=%#v", string(r.Name()), r.Authentication()) res.SetResultCode(ldap.LDAPResultInvalidCredentials) res.SetDiagnosticMessage("invalid credentials") } else { res.SetResultCode(ldap.LDAPResultUnwillingToPerform) res.SetDiagnosticMessage("Authentication choice not supported") } w.Write(res) }