about summary refs log tree commit diff
path: root/web/panettone/src/authentication.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'web/panettone/src/authentication.lisp')
-rw-r--r--web/panettone/src/authentication.lisp18
1 files changed, 12 insertions, 6 deletions
diff --git a/web/panettone/src/authentication.lisp b/web/panettone/src/authentication.lisp
index 20510257539f..50befbc7a168 100644
--- a/web/panettone/src/authentication.lisp
+++ b/web/panettone/src/authentication.lisp
@@ -79,12 +79,18 @@ and a retry"
 
 (defun find-user-by-dn (dn)
   (with-ldap ()
-    (progn
-      (ldap:search *ldap* `(= objectClass organizationalPerson)
-                   :base dn
-                   :scope 'ldap:base)
-      (when-let ((ldap-entry (ldap:next-search-result *ldap*)))
-        (ldap-entry->user ldap-entry)))))
+    (let ((have-results
+            (handler-case
+              (ldap:search *ldap* `(= objectClass organizationalPerson)
+                           :base dn
+                           :scope 'ldap:base)
+              ; catch ldap-errors generated by trivial-ldap:parse-ldap-message
+              ; since this is thrown on conditions which we don't want this
+              ; function to fail like when there are no search results
+              (trivial-ldap:ldap-error (e) nil))))
+      (when have-results
+        (when-let ((ldap-entry (ldap:next-search-result *ldap*)))
+          (ldap-entry->user ldap-entry))))))
 
 (comment
  (find-user-by-dn "cn=glittershark,ou=users,dc=tvl,dc=fyi")