[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 87ff9ae 07/17: Add password-cache support to ldap.e
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 87ff9ae 07/17: Add password-cache support to ldap.el |
Date: |
Fri, 23 Jan 2015 22:20:32 +0000 |
branch: master
commit 87ff9aeb42780e7d5e713360d6ee96d0b7609cff
Author: Thomas Fitzsimmons <address@hidden>
Commit: Thomas Fitzsimmons <address@hidden>
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.
---
lisp/ChangeLog | 7 +++++++
lisp/net/ldap.el | 21 ++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 658f5b6..dc27519 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
2014-11-13 Thomas Fitzsimmons <address@hidden>
+ * 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.
+
+2014-11-13 Thomas Fitzsimmons <address@hidden>
+
* net/eudc-vars.el (eudc-expansion-overwrites-query): Change
default to nil.
diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el
index 2b5b2fb..113a9bc 100644
--- a/lisp/net/ldap.el
+++ b/lisp/net/ldap.el
@@ -34,6 +34,7 @@
;;; Code:
(require 'custom)
+(require 'password-cache)
(autoload 'auth-source-search "auth-source")
@@ -476,6 +477,20 @@ Additional search parameters can be specified through
(mapcar 'ldap-decode-attribute record))
result))))
+(defun ldap-password-read (host)
+ "Read LDAP password for HOST. If the password is cached, it is
+read from the cache, otherwise the user is prompted for the
+password and the password is cached. The cache can be cleared
+with `password-reset`."
+ ;; Add ldap: namespace to allow empty string for default host.
+ (let ((host-key (concat "ldap:" host)))
+ (when (not (password-in-cache-p host-key))
+ (password-cache-add host-key (password-read
+ (format "Enter LDAP Password%s: "
+ (if (equal host "")
+ ""
+ (format " for %s" host))))))
+ (password-read-from-cache host-key)))
(defun ldap-search-internal (search-plist)
"Perform a search on a LDAP server.
@@ -531,7 +546,11 @@ an alist of attribute/value pairs."
(passwd (or (plist-get search-plist 'passwd)
(plist-get asfound :secret)))
;; convert the password from a function call if needed
- (passwd (if (functionp passwd) (funcall passwd) passwd))
+ (passwd (if (functionp passwd)
+ (if (eq passwd 'ldap-password-read)
+ (funcall passwd host)
+ (funcall passwd))
+ passwd))
;; get the binddn from the search-list or from the
;; auth-source user or binddn tokens
(binddn (or (plist-get search-plist 'binddn)
- [Emacs-diffs] master updated (fd62486 -> ac5475d), Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 0dee070 02/17: Support new-style LDAP URIs in ldap-search-internal, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 090cbf9 01/17: Change eudc-server-hotlist from a defvar to a defcustom, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master fa9a3ca 04/17: Improve eudc-inline-expansion-format's default value, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 6dda29f 03/17: Improve eudc-inline-query-format's default value, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master c8d2553 05/17: Ignore text properties in eudc-expand-inline, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master b7d2dfa 06/17: Change eudc-expansion-overwrites-query default to nil, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 6a3a3b0 09/17: Downcase field names in LDAP results, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 87ff9ae 07/17: Add password-cache support to ldap.el,
Stefan Monnier <=
- [Emacs-diffs] master ea0ea90 08/17: ldap-search-internal: Send password to ldapsearch through a pipe, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 1e1f5b9 10/17: Append LDAP wildcard character to end of search string, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 81d0909 12/17: Restore former eudc-expand-inline settings after a nonlocal exit, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 7860227 11/17: Do not ask the user for an LDAP base if a default has been provided, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 9006ccd 13/17: Handle nil password-cache in ldap-password-read, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 4a77d69 14/17: ldap-password-read: Validate password before caching it, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master e56e1b9 16/17: Mention binddn in LDAP credentials error message, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master a6d4651 15/17: Update LDAP configuration section of EUDC manual, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master ac5475d 17/17: lisp/net/{eudc, ldap}: Merge branch streamline-eudc-configuration, Stefan Monnier, 2015/01/23