Function: eudc-ldap-cleanup-record-filtering-addresses

eudc-ldap-cleanup-record-filtering-addresses is a byte-compiled function defined in eudcb-ldap.el.gz.

Signature

(eudc-ldap-cleanup-record-filtering-addresses RECORD)

Documentation

Clean up RECORD to make it suitable for EUDC.

Make the record a cons-cell instead of a list if it is single-valued. Change the $ character in postal addresses to a newline. Combine separate mail fields into one mail field with multiple addresses.

Source Code

;; Defined in /usr/src/emacs/lisp/net/eudcb-ldap.el.gz
(defun eudc-ldap-cleanup-record-filtering-addresses (record)
  "Clean up RECORD to make it suitable for EUDC.
Make the record a cons-cell instead of a list if it is
single-valued.  Change the `$' character in postal addresses to a
newline.  Combine separate mail fields into one mail field with
multiple addresses."
  (let ((clean-up-addresses (or (not (boundp 'ldap-ignore-attribute-codings))
				(not ldap-ignore-attribute-codings)))
	result mail-addresses)
    (dolist (field record)
      ;; 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.
      (let ((name (intern (downcase (car field))))
	    (value (cdr field)))
	(when (and clean-up-addresses
		   (memq name '(postaladdress registeredaddress)))
	  (setq value (mapcar #'eudc-filter-$ value)))
	(if (eq name 'mail)
	    (setq mail-addresses (append mail-addresses value))
	  (push (cons name (if (cdr value)
			       value
			     (car value)))
		result))))
    (push (cons 'mail (if (cdr mail-addresses)
			  mail-addresses
			(car mail-addresses)))
          result)
    (nreverse result)))