It is recommended to use the `-T' switch with Nescape's
implementation to avoid line wrapping.
`-L' is needed to get LDIF outout.
-(`-LL' is needed to get rid of comments from OpenLDAP's ldapsearch.)
+\(`-LL' is needed to get rid of comments from OpenLDAP's ldapsearch.\)
`-x' is needed to use simple authentication.
The `-B' switch should be used to enable the retrieval of
binary values."
:group 'ldap)
(defcustom ldap-default-host nil
- "*Default LDAP server hostname.
-A TCP port number can be appended to that name using a colon as
-a separator."
+ "*Default LDAP server hostname."
:type '(choice (string :tag "Host name")
(const :tag "Use library default" nil))
:group 'ldap)
nil (current-buffer) t
(append arglist
(list dn))))
- (if (integerp ret)
- (if (not (zerop ret))
- (error (car (split-string (buffer-string) "\n"))))
- (if (and (setq ret (buffer-string)); Nemacs
- (string-match "ldap_delete:" ret))
- (error (car (split-string ret "\n"))))))))
+ (cond ((integerp ret)
+ (or (zerop ret)
+ (error "%s" (car (split-string (buffer-string) "\n")))))
+ ((and (setq ret (buffer-string)); Nemacs
+ (string-match "ldap_delete:" ret))
+ (error "%s" (car (split-string ret "\n"))))))))
(defmacro ldap/ldif-insert-field (attr value)
(` (if (not (ldap/ldif-safe-string-p (, value)))
ldap-modify-program
t t nil
arglist))
- (if (integerp ret)
- (if (not (zerop ret))
- (error (car (split-string (buffer-string) "\n"))))
- (if (and (setq ret (buffer-string)); Nemacs
- (string-match "ldap_modify:" ret))
- (error (car (split-string ret "\n"))))))))
+ (cond ((integerp ret)
+ (or (zerop ret)
+ (error "%s" (car (split-string (buffer-string) "\n")))))
+ ((and (setq ret (buffer-string)); Nemacs
+ (string-match "ldap_modify:" ret))
+ (error "%s" (car (split-string ret "\n"))))))))
(defun ldap-add (ldap dn entry)
"Add an entry to an LDAP directory.
ldap-add-program
t t nil
arglist))
- (if (integerp ret)
- (if (not (zerop ret))
- (error (car (split-string (buffer-string) "\n"))))
- (if (and (setq ret (buffer-string)) ; Nemacs
- (string-match "ldap_add:" ret))
- (error (car (split-string ret "\n"))))))))
+ (cond ((integerp ret)
+ (or (zerop ret)
+ (error "%s" (car (split-string (buffer-string) "\n")))))
+ ((and (setq ret (buffer-string)) ; Nemacs
+ (string-match "ldap_add:" ret))
+ (error "%s" (car (split-string ret "\n"))))))))
(defun ldap-search-basic (ldap filter base scope
&optional attrs attrsonly withdn verbose)
(not (zerop ret))
;; When openldap's `ldapsearch' exceeds response size limit,
;; it's exit status becomes `4'.
- (/= ret 4))
+ (/= ret 4)
+ ;; When openldap's `ldapsearch' uses referral,
+ ;; it's exit status becomes `32'.
+ (/= ret 32))
(error "LDAP error: \"No such object\""))
(goto-char (point-min))
(setq start (point))
(defun ldap-decode-string (str)
"Decode LDAP STR."
- (if (fboundp 'decode-coding-string)
- (decode-coding-string str ldap-coding-system)))
+ (if (and (fboundp 'decode-coding-string)
+ ldap-coding-system)
+ (decode-coding-string str ldap-coding-system)
+ str))
(defun ldap-encode-string (str)
"Encode LDAP STR."
- (if (fboundp 'encode-coding-string)
- (encode-coding-string str ldap-coding-system)))
+ (if (and (fboundp 'encode-coding-string)
+ ldap-coding-system)
+ (encode-coding-string str ldap-coding-system)
+ str))
(defun ldap-decode-address (str)
"Decode LDAP address STR."
(setq ldap (ldap-open host host-plist))
(if ldap-verbose
(message "Searching with LDAP on %s..." host))
- (setq result (ldap-search ldap filter
+ (setq result (ldap-search ldap (ldap-encode-string filter)
(plist-get host-plist 'base)
(plist-get host-plist 'scope)
attributes attrsonly withdn