Mercurial > emacs
comparison lisp/net/ldap.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 6baa96917e56 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; ldap.el --- client interface to LDAP for Emacs | 1 ;;; ldap.el --- client interface to LDAP for Emacs |
2 | 2 |
3 ;; Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Oscar Figueiredo <oscar@cpe.fr> | 6 ;; Author: Oscar Figueiredo <oscar@cpe.fr> |
6 ;; Maintainer: Pavel Janík <Pavel@Janik.cz> | 7 ;; Maintainer: FSF |
7 ;; Created: April 1998 | 8 ;; Created: April 1998 |
8 ;; Keywords: comm | 9 ;; Keywords: comm |
9 | 10 |
10 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
11 | 12 |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 ;; GNU General Public License for more details. | 21 ;; GNU General Public License for more details. |
21 | 22 |
22 ;; You should have received a copy of the GNU General Public License | 23 ;; You should have received a copy of the GNU General Public License |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02111-1307, USA. | 26 ;; Boston, MA 02110-1301, USA. |
26 | 27 |
27 ;;; Commentary: | 28 ;;; Commentary: |
28 | 29 |
29 ;; This package provides basic functionality to perform searches on LDAP | 30 ;; This package provides basic functionality to perform searches on LDAP |
30 ;; servers. It requires a command line utility generally named | 31 ;; servers. It requires a command line utility generally named |
34 ;; - OpenLDAP (http://www.openldap.org/) | 35 ;; - OpenLDAP (http://www.openldap.org/) |
35 | 36 |
36 ;;; Code: | 37 ;;; Code: |
37 | 38 |
38 (require 'custom) | 39 (require 'custom) |
40 (eval-when-compile (require 'cl)) | |
39 | 41 |
40 (defgroup ldap nil | 42 (defgroup ldap nil |
41 "Lightweight Directory Access Protocol." | 43 "Lightweight Directory Access Protocol." |
42 :version "21.1" | 44 :version "21.1" |
43 :group 'comm) | 45 :group 'comm) |
462 (or host | 464 (or host |
463 (setq host ldap-default-host) | 465 (setq host ldap-default-host) |
464 (error "No LDAP host specified")) | 466 (error "No LDAP host specified")) |
465 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) | 467 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) |
466 result) | 468 result) |
467 (setq result (ldap-search-internal (append host-plist | 469 (setq result (ldap-search-internal (list* 'host host |
468 (list 'host host | 470 'filter filter |
469 'filter filter | 471 'attributes attributes |
470 'attributes attributes | 472 'attrsonly attrsonly |
471 'attrsonly attrsonly | 473 'withdn withdn |
472 'withdn withdn)))) | 474 host-plist))) |
473 (if ldap-ignore-attribute-codings | 475 (if ldap-ignore-attribute-codings |
474 result | 476 result |
475 (mapcar (function | 477 (mapcar (lambda (record) |
476 (lambda (record) | 478 (mapcar 'ldap-decode-attribute record)) |
477 (mapcar 'ldap-decode-attribute record))) | |
478 result)))) | 479 result)))) |
479 | 480 |
480 | 481 |
481 (defun ldap-search-internal (search-plist) | 482 (defun ldap-search-internal (search-plist) |
482 "Perform a search on a LDAP server. | 483 "Perform a search on a LDAP server. |
552 (if (and sizelimit | 553 (if (and sizelimit |
553 (not (equal "" sizelimit))) | 554 (not (equal "" sizelimit))) |
554 (setq arglist (nconc arglist (list (format "-z%s" sizelimit))))) | 555 (setq arglist (nconc arglist (list (format "-z%s" sizelimit))))) |
555 (eval `(call-process ldap-ldapsearch-prog | 556 (eval `(call-process ldap-ldapsearch-prog |
556 nil | 557 nil |
557 buf | 558 `(,buf nil) |
558 nil | 559 nil |
559 ,@arglist | 560 ,@arglist |
560 ,@ldap-ldapsearch-args | 561 ,@ldap-ldapsearch-args |
561 ,@filter)) | 562 ,@filter)) |
562 (insert "\n") | 563 (insert "\n") |
577 (not (eobp))) | 578 (not (eobp))) |
578 (setq dn (buffer-substring (point) (save-excursion | 579 (setq dn (buffer-substring (point) (save-excursion |
579 (end-of-line) | 580 (end-of-line) |
580 (point)))) | 581 (point)))) |
581 (forward-line 1) | 582 (forward-line 1) |
582 (while (looking-at "^\\(\\w*\\)[=:\t ]+\\(<[\t ]*file://\\)?\\(.*\\)$") | 583 (while (looking-at "^\\(\\w*\\)\\(;\\w*\\)?[=:\t ]+\\(<[\t ]*file://\\)?\\(.*\\)$") |
583 (setq name (match-string 1) | 584 (setq name (match-string 1) |
584 value (match-string 3)) | 585 value (match-string 4)) |
586 ;; Need to handle file:///D:/... as generated by OpenLDAP | |
587 ;; on DOS/Windows as local files. | |
588 (if (and (memq system-type '(windows-nt ms-dos)) | |
589 (eq (string-match "/\\(.:.*\\)$" value) 0)) | |
590 (setq value (match-string 1 value))) | |
585 ;; Do not try to open non-existent files | 591 ;; Do not try to open non-existent files |
586 (if (equal value "") | 592 (if (equal value "") |
587 (setq value " ") | 593 (setq value " ") |
588 (save-excursion | 594 (save-excursion |
589 (set-buffer bufval) | 595 (set-buffer bufval) |
605 (message "Parsing results... done") | 611 (message "Parsing results... done") |
606 (nreverse result))))) | 612 (nreverse result))))) |
607 | 613 |
608 (provide 'ldap) | 614 (provide 'ldap) |
609 | 615 |
616 ;;; arch-tag: 47913a76-6155-42e6-ac58-6d28b5d50eb0 | |
610 ;;; ldap.el ends here | 617 ;;; ldap.el ends here |