@@ -72,7 +72,7 @@ func tryFindLDAPUser(username, password string) (*db.User, error) {
7272 searchRequest := ldap .NewSearchRequest (
7373 util .Config .LdapSearchDN ,
7474 ldap .ScopeWholeSubtree , ldap .NeverDerefAliases , 0 , 0 , false ,
75- fmt .Sprintf (util .Config .LdapSearchFilter , username ),
75+ fmt .Sprintf (util .Config .LdapSearchFilter , ldap . EscapeFilter ( username ) ),
7676 []string {util .Config .LdapMappings .DN },
7777 nil ,
7878 )
@@ -105,7 +105,7 @@ func tryFindLDAPUser(username, password string) (*db.User, error) {
105105 searchRequest = ldap .NewSearchRequest (
106106 util .Config .LdapSearchDN ,
107107 ldap .ScopeWholeSubtree , ldap .NeverDerefAliases , 0 , 0 , false ,
108- fmt .Sprintf (util .Config .LdapSearchFilter , username ),
108+ fmt .Sprintf (util .Config .LdapSearchFilter , ldap . EscapeFilter ( username ) ),
109109 []string {util .Config .LdapMappings .DN , util .Config .LdapMappings .Mail , util .Config .LdapMappings .UID , util .Config .LdapMappings .CN },
110110 nil ,
111111 )
@@ -333,7 +333,7 @@ func login(w http.ResponseWriter, r *http.Request) {
333333 "context" : "ldap" ,
334334 "auth" : login .Auth ,
335335 }).Warn ("Failed to find user in LDAP" )
336- w .WriteHeader (http .StatusInternalServerError )
336+ w .WriteHeader (http .StatusUnauthorized )
337337 return
338338 }
339339 }
0 commit comments