aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Fitzsimmons2014-11-13 01:23:54 -0500
committerThomas Fitzsimmons2014-11-13 02:31:14 -0500
commit87ff9aeb42780e7d5e713360d6ee96d0b7609cff (patch)
tree3dc725da397a3231c199c084ccc19bd5ddb06296
parentb7d2dfa9f3eb4daf1499de8cc7ad76683ac5dbec (diff)
downloademacs-87ff9aeb42780e7d5e713360d6ee96d0b7609cff.tar.gz
emacs-87ff9aeb42780e7d5e713360d6ee96d0b7609cff.zip
Add password-cache support to ldap.el
* net/ldap.el: Require password-cache. (ldap-password-read): New function. (ldap-search-internal): Call ldap-password-read when it is configured to be called.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/net/ldap.el21
2 files changed, 27 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 658f5b6ca84..dc27519765c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12014-11-13 Thomas Fitzsimmons <fitzsim@fitzsim.org> 12014-11-13 Thomas Fitzsimmons <fitzsim@fitzsim.org>
2 2
3 * net/ldap.el: Require password-cache.
4 (ldap-password-read): New function.
5 (ldap-search-internal): Call ldap-password-read when it is
6 configured to be called.
7
82014-11-13 Thomas Fitzsimmons <fitzsim@fitzsim.org>
9
3 * net/eudc-vars.el (eudc-expansion-overwrites-query): Change 10 * net/eudc-vars.el (eudc-expansion-overwrites-query): Change
4 default to nil. 11 default to nil.
5 12
diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el
index 2b5b2fb89a5..113a9bcd5ff 100644
--- a/lisp/net/ldap.el
+++ b/lisp/net/ldap.el
@@ -34,6 +34,7 @@
34;;; Code: 34;;; Code:
35 35
36(require 'custom) 36(require 'custom)
37(require 'password-cache)
37 38
38(autoload 'auth-source-search "auth-source") 39(autoload 'auth-source-search "auth-source")
39 40
@@ -476,6 +477,20 @@ Additional search parameters can be specified through
476 (mapcar 'ldap-decode-attribute record)) 477 (mapcar 'ldap-decode-attribute record))
477 result)))) 478 result))))
478 479
480(defun ldap-password-read (host)
481 "Read LDAP password for HOST. If the password is cached, it is
482read from the cache, otherwise the user is prompted for the
483password and the password is cached. The cache can be cleared
484with `password-reset`."
485 ;; Add ldap: namespace to allow empty string for default host.
486 (let ((host-key (concat "ldap:" host)))
487 (when (not (password-in-cache-p host-key))
488 (password-cache-add host-key (password-read
489 (format "Enter LDAP Password%s: "
490 (if (equal host "")
491 ""
492 (format " for %s" host))))))
493 (password-read-from-cache host-key)))
479 494
480(defun ldap-search-internal (search-plist) 495(defun ldap-search-internal (search-plist)
481 "Perform a search on a LDAP server. 496 "Perform a search on a LDAP server.
@@ -531,7 +546,11 @@ an alist of attribute/value pairs."
531 (passwd (or (plist-get search-plist 'passwd) 546 (passwd (or (plist-get search-plist 'passwd)
532 (plist-get asfound :secret))) 547 (plist-get asfound :secret)))
533 ;; convert the password from a function call if needed 548 ;; convert the password from a function call if needed
534 (passwd (if (functionp passwd) (funcall passwd) passwd)) 549 (passwd (if (functionp passwd)
550 (if (eq passwd 'ldap-password-read)
551 (funcall passwd host)
552 (funcall passwd))
553 passwd))
535 ;; get the binddn from the search-list or from the 554 ;; get the binddn from the search-list or from the
536 ;; auth-source user or binddn tokens 555 ;; auth-source user or binddn tokens
537 (binddn (or (plist-get search-plist 'binddn) 556 (binddn (or (plist-get search-plist 'binddn)