Function: ldap-search

ldap-search is an interactive and byte-compiled function defined in ldap.el.gz.

Signature

(ldap-search FILTER &optional HOST ATTRIBUTES ATTRSONLY WITHDN)

Documentation

Perform an LDAP search.

FILTER is the search filter in RFC1558 syntax. HOST is the LDAP host on which to perform the search. ATTRIBUTES are the specific attributes to retrieve, nil means retrieve all. ATTRSONLY, if non-nil, retrieves the attributes only, without the associated values. If WITHDN is non-nil, each entry in the result will be prepended with its distinguished name WITHDN. Additional search parameters can be specified through ldap-host-parameters-alist, which see. See ldap-search-internal for the description of return value.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/net/ldap.el.gz
(defun ldap-search (filter &optional host attributes attrsonly withdn)
  "Perform an LDAP search.
FILTER is the search filter in RFC1558 syntax.
HOST is the LDAP host on which to perform the search.
ATTRIBUTES are the specific attributes to retrieve, nil means
retrieve all.
ATTRSONLY, if non-nil, retrieves the attributes only, without
the associated values.
If WITHDN is non-nil, each entry in the result will be prepended with
its distinguished name WITHDN.
Additional search parameters can be specified through
`ldap-host-parameters-alist', which see.
See `ldap-search-internal' for the description of return value."
  (interactive "sFilter:")
  (or host
      (setq host ldap-default-host)
      (error "No LDAP host specified"))
  (let* ((host-plist (cdr (assoc host ldap-host-parameters-alist)))
         (result (ldap-search-internal `(host ,host
					 filter ,filter
                                         attributes ,attributes
                                         attrsonly ,attrsonly
                                         withdn ,withdn
                                         ,@host-plist))))
    (if ldap-ignore-attribute-codings
	result
      (mapcar (lambda (record)
                (append (and withdn (list (car record)))
                        (mapcar #'ldap-decode-attribute
                                (if withdn (cdr record) record))))
	      result))))