diff options
| author | Filipp Gunbin | 2022-04-13 23:10:35 +0300 |
|---|---|---|
| committer | Filipp Gunbin | 2022-04-14 16:52:01 +0300 |
| commit | 2a2f5530fa230e2b994be5683e63763833bb6a0a (patch) | |
| tree | 90273ccef6ceb0d857375aba668469b08cc2f076 | |
| parent | 36da6ceb926b684e4cee5888175924ccd79fac83 (diff) | |
| download | emacs-2a2f5530fa230e2b994be5683e63763833bb6a0a.tar.gz emacs-2a2f5530fa230e2b994be5683e63763833bb6a0a.zip | |
Fix eudc-get-attribute-list
* lisp/net/eudc-vars.el (eudc-ldap-no-wildcard-attributes): New
defcustom.
* doc/misc/eudc.texi (LDAP Configuration): Mention it.
* lisp/net/eudcb-ldap.el (eudc-ldap-format-query-as-rfc1558): Use it.
(eudc-ldap-get-field-list): Set scope and sizelimit, instead of
overriding the whole ldap-host-parameters-alist.
* lisp/net/ldap.el (ldap-search-internal): Allow "size limit exceeded"
exit code. Allow empty attribute values.
| -rw-r--r-- | doc/misc/eudc.texi | 4 | ||||
| -rw-r--r-- | lisp/net/eudc-vars.el | 9 | ||||
| -rw-r--r-- | lisp/net/eudcb-ldap.el | 41 | ||||
| -rw-r--r-- | lisp/net/ldap.el | 4 |
4 files changed, 39 insertions, 19 deletions
diff --git a/doc/misc/eudc.texi b/doc/misc/eudc.texi index 71e3e6b9ed7..d2850282fea 100644 --- a/doc/misc/eudc.texi +++ b/doc/misc/eudc.texi | |||
| @@ -254,7 +254,9 @@ To: * Smith | |||
| 254 | @noindent | 254 | @noindent |
| 255 | will return all LDAP entries with surnames that begin with | 255 | will return all LDAP entries with surnames that begin with |
| 256 | @code{Smith}. In every LDAP query it makes, EUDC implicitly appends | 256 | @code{Smith}. In every LDAP query it makes, EUDC implicitly appends |
| 257 | the wildcard character to the end of the last word. | 257 | the wildcard character to the end of the last word, except if the word |
| 258 | corresponds to an attribute which is a member of | ||
| 259 | `eudc-ldap-no-wildcard-attributes'. | ||
| 258 | 260 | ||
| 259 | @menu | 261 | @menu |
| 260 | * Emacs-only Configuration:: Configure with @file{.emacs} | 262 | * Emacs-only Configuration:: Configure with @file{.emacs} |
diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el index d58fab896ed..90d89e87fba 100644 --- a/lisp/net/eudc-vars.el +++ b/lisp/net/eudc-vars.el | |||
| @@ -425,6 +425,15 @@ BBDB fields. SPECs are sexps which are evaluated: | |||
| 425 | (symbol :tag "BBDB Field") | 425 | (symbol :tag "BBDB Field") |
| 426 | (sexp :tag "Conversion Spec")))) | 426 | (sexp :tag "Conversion Spec")))) |
| 427 | 427 | ||
| 428 | (defcustom eudc-ldap-no-wildcard-attributes | ||
| 429 | '(objectclass objectcategory) | ||
| 430 | "LDAP attributes which are always searched for without wildcard character. | ||
| 431 | This is the list of special dictionary-valued attributes, where | ||
| 432 | wildcarded search may fail. For example, it fails with | ||
| 433 | objectclass in Active Directory servers." | ||
| 434 | :type '(repeat (symbol :tag "Directory attribute"))) | ||
| 435 | |||
| 436 | |||
| 428 | ;;}}} | 437 | ;;}}} |
| 429 | 438 | ||
| 430 | ;;{{{ BBDB Custom Group | 439 | ;;{{{ BBDB Custom Group |
diff --git a/lisp/net/eudcb-ldap.el b/lisp/net/eudcb-ldap.el index 365dace961a..1201c84f2d3 100644 --- a/lisp/net/eudcb-ldap.el +++ b/lisp/net/eudcb-ldap.el | |||
| @@ -151,16 +151,20 @@ attribute names are returned. Default to `person'." | |||
| 151 | (interactive) | 151 | (interactive) |
| 152 | (or eudc-server | 152 | (or eudc-server |
| 153 | (call-interactively 'eudc-set-server)) | 153 | (call-interactively 'eudc-set-server)) |
| 154 | (let ((ldap-host-parameters-alist | 154 | (let ((plist (copy-sequence |
| 155 | (list (cons eudc-server | 155 | (alist-get eudc-server ldap-host-parameters-alist |
| 156 | '(scope subtree sizelimit 1))))) | 156 | nil nil #'equal)))) |
| 157 | (mapcar #'eudc-ldap-cleanup-record-filtering-addresses | 157 | (plist-put plist 'scope 'subtree) |
| 158 | (ldap-search | 158 | (plist-put plist 'sizelimit '1) |
| 159 | (eudc-ldap-format-query-as-rfc1558 | 159 | (let ((ldap-host-parameters-alist |
| 160 | (list (cons "objectclass" | 160 | (list (cons eudc-server plist)))) |
| 161 | (or objectclass | 161 | (mapcar #'eudc-ldap-cleanup-record-filtering-addresses |
| 162 | "person")))) | 162 | (ldap-search |
| 163 | eudc-server nil t)))) | 163 | (eudc-ldap-format-query-as-rfc1558 |
| 164 | (list (cons 'objectclass | ||
| 165 | (or objectclass | ||
| 166 | "person")))) | ||
| 167 | eudc-server nil t))))) | ||
| 164 | 168 | ||
| 165 | (defun eudc-ldap-escape-query-special-chars (string) | 169 | (defun eudc-ldap-escape-query-special-chars (string) |
| 166 | "Value is STRING with characters forbidden in LDAP queries escaped." | 170 | "Value is STRING with characters forbidden in LDAP queries escaped." |
| @@ -178,12 +182,17 @@ attribute names are returned. Default to `person'." | |||
| 178 | 182 | ||
| 179 | (defun eudc-ldap-format-query-as-rfc1558 (query) | 183 | (defun eudc-ldap-format-query-as-rfc1558 (query) |
| 180 | "Format the EUDC QUERY list as a RFC1558 LDAP search filter." | 184 | "Format the EUDC QUERY list as a RFC1558 LDAP search filter." |
| 181 | (let ((formatter (lambda (item &optional wildcard) | 185 | (let ((formatter |
| 182 | (format "(%s=%s)" | 186 | (lambda (item &optional wildcard) |
| 183 | (car item) | 187 | (format "(%s=%s)" |
| 184 | (concat | 188 | (car item) |
| 185 | (eudc-ldap-escape-query-special-chars | 189 | (concat |
| 186 | (cdr item)) (if wildcard "*" "")))))) | 190 | (eudc-ldap-escape-query-special-chars |
| 191 | (cdr item)) | ||
| 192 | (if (and wildcard | ||
| 193 | (not (memq (car item) | ||
| 194 | eudc-ldap-no-wildcard-attributes))) | ||
| 195 | "*" "")))))) | ||
| 187 | (format "(&%s)" | 196 | (format "(&%s)" |
| 188 | (concat | 197 | (concat |
| 189 | (mapconcat formatter (butlast query) "") | 198 | (mapconcat formatter (butlast query) "") |
diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el index ce6c270e0bc..94632821353 100644 --- a/lisp/net/ldap.el +++ b/lisp/net/ldap.el | |||
| @@ -663,7 +663,7 @@ an alist of attribute/value pairs." | |||
| 663 | (while (not (memq (process-status proc) '(exit signal))) | 663 | (while (not (memq (process-status proc) '(exit signal))) |
| 664 | (sit-for 0.1)) | 664 | (sit-for 0.1)) |
| 665 | (let ((status (process-exit-status proc))) | 665 | (let ((status (process-exit-status proc))) |
| 666 | (when (not (eq status 0)) | 666 | (when (not (memql status '(0 4))) ; 4 = Size limit exceeded |
| 667 | ;; Handle invalid credentials exit status specially | 667 | ;; Handle invalid credentials exit status specially |
| 668 | ;; for ldap-password-read. | 668 | ;; for ldap-password-read. |
| 669 | (if (eq status 49) | 669 | (if (eq status 49) |
| @@ -699,7 +699,7 @@ an alist of attribute/value pairs." | |||
| 699 | (forward-line 1) | 699 | (forward-line 1) |
| 700 | (while (looking-at "^\\([A-Za-z][-A-Za-z0-9]*\ | 700 | (while (looking-at "^\\([A-Za-z][-A-Za-z0-9]*\ |
| 701 | \\|[0-9]+\\(?:\\.[0-9]+\\)*\\)\\(;[-A-Za-z0-9]+\\)*[=:\t ]+\ | 701 | \\|[0-9]+\\(?:\\.[0-9]+\\)*\\)\\(;[-A-Za-z0-9]+\\)*[=:\t ]+\ |
| 702 | \\(<[\t ]*file://\\)\\(.*\\)$") | 702 | \\(<[\t ]*file://\\)?\\(.*\\)$") |
| 703 | (setq name (match-string 1) | 703 | (setq name (match-string 1) |
| 704 | value (match-string 4)) | 704 | value (match-string 4)) |
| 705 | ;; Need to handle file:///D:/... as generated by OpenLDAP | 705 | ;; Need to handle file:///D:/... as generated by OpenLDAP |