]> code.delx.au - gnu-emacs/blobdiff - lisp/net/eudcb-ldap.el
Downcase field names in LDAP results
[gnu-emacs] / lisp / net / eudcb-ldap.el
index 14594409dfab68a20e0d174c01e0dbcac0631c89..1b01d21be8c874cc092c1ff5bd250075eddc9297 100644 (file)
@@ -1,9 +1,9 @@
-;;; eudcb-ldap.el --- Emacs Unified Directory Client - LDAP Backend
+;;; eudcb-ldap.el --- Emacs Unified Directory Client - LDAP Backend -*- coding: utf-8 -*-
 
-;; Copyright (C) 1998-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2014 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <oscar@cpe.fr>
-;; Maintainer: Pavel Janík <Pavel@Janik.cz>
+;; Maintainer: Pavel Janík <Pavel@Janik.cz>
 ;; Keywords: comm
 ;; Package: eudc
 
   (mapcar
    (function
     (lambda (field)
-      (cons (intern (car field))
+      ;; Some servers return case-sensitive names (e.g. givenName
+      ;; instead of givenname); downcase the field's name so that it
+      ;; can be matched against
+      ;; eudc-ldap-attributes-translation-alist.
+      (cons (intern (downcase (car field)))
            (if (cdr (cdr field))
                (cdr field)
              (car (cdr field))))))
@@ -95,7 +99,7 @@
   (mapcar
    (function
     (lambda (field)
-      (let ((name (intern (car field)))
+      (let ((name (intern (downcase (car field))))
            (value (cdr field)))
        (if (memq name '(postaladdress registeredaddress))
            (setq value (mapcar 'eudc-filter-$ value)))
@@ -136,7 +140,7 @@ RETURN-ATTRS is a list of attributes to return, defaulting to
         result))
     final-result))
 
-(defun eudc-ldap-get-field-list (dummy &optional objectclass)
+(defun eudc-ldap-get-field-list (_dummy &optional objectclass)
   "Return a list of valid attribute names for the current server.
 OBJECTCLASS is the LDAP object class for which the valid
 attribute names are returned. Default to `person'"
@@ -172,10 +176,10 @@ attribute names are returned. Default to `person'"
   "Format the EUDC QUERY list as a RFC1558 LDAP search filter."
   (format "(&%s)"
          (apply 'concat
-                (mapcar '(lambda (item)
-                           (format "(%s=%s)"
-                                   (car item)
-                                   (eudc-ldap-escape-query-special-chars (cdr item))))
+                (mapcar (lambda (item)
+                           (format "(%s=%s)"
+                                   (car item)
+                                   (eudc-ldap-escape-query-special-chars (cdr item))))
                         query))))