Mercurial > emacs
annotate lisp/net/ldap.el @ 98467:1523ad03b1d2
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Thu, 02 Oct 2008 20:04:58 +0000 |
parents | 92660418caae |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33930
diff
changeset
|
1 ;;; ldap.el --- client interface to LDAP for Emacs |
27313 | 2 |
74509 | 3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
79714 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
27313 | 5 |
42607
033986c328d5
New maintainer. New e-mail address of the author.
Pavel Janík <Pavel@Janik.cz>
parents:
42579
diff
changeset
|
6 ;; Author: Oscar Figueiredo <oscar@cpe.fr> |
59941 | 7 ;; Maintainer: FSF |
27313 | 8 ;; Created: April 1998 |
9 ;; Keywords: comm | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
27313 | 14 ;; it under the terms of the GNU General Public License as published by |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
27313 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
27313 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This package provides basic functionality to perform searches on LDAP | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
29 ;; servers. It requires a command line utility generally named |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
30 ;; `ldapsearch' to actually perform the searches. That program can be |
27313 | 31 ;; found in all LDAP developer kits such as: |
32 ;; - UM-LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/) | |
33 ;; - OpenLDAP (http://www.openldap.org/) | |
34 | |
35 ;;; Code: | |
36 | |
37 (require 'custom) | |
54805
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
38 (eval-when-compile (require 'cl)) |
27313 | 39 |
40 (defgroup ldap nil | |
41 "Lightweight Directory Access Protocol." | |
33930 | 42 :version "21.1" |
27313 | 43 :group 'comm) |
44 | |
45 (defcustom ldap-default-host nil | |
46 "*Default LDAP server. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
47 A TCP port number can be appended to that name using a colon as |
27313 | 48 a separator." |
49 :type '(choice (string :tag "Host name") | |
50 (const :tag "Use library default" nil)) | |
51 :group 'ldap) | |
52 | |
53 (defcustom ldap-default-port nil | |
54 "*Default TCP port for LDAP connections. | |
55 Initialized from the LDAP library at build time. Default value is 389." | |
56 :type '(choice (const :tag "Use library default" nil) | |
57 (integer :tag "Port number")) | |
58 :group 'ldap) | |
59 | |
60 (defcustom ldap-default-base nil | |
61 "*Default base for LDAP searches. | |
62 This is a string using the syntax of RFC 1779. | |
63 For instance, \"o=ACME, c=US\" limits the search to the | |
64 Acme organization in the United States." | |
65 :type '(choice (const :tag "Use library default" nil) | |
66 (string :tag "Search base")) | |
67 :group 'ldap) | |
68 | |
69 | |
70 (defcustom ldap-host-parameters-alist nil | |
71 "*Alist of host-specific options for LDAP transactions. | |
72 The format of each list element is (HOST PROP1 VAL1 PROP2 VAL2 ...). | |
42573 | 73 HOST is the hostname of an LDAP server (with an optional TCP port number |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
74 appended to it using a colon as a separator). |
27313 | 75 PROPn and VALn are property/value pairs describing parameters for the server. |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
76 Valid properties include: |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
77 `binddn' is the distinguished name of the user to bind as |
27313 | 78 (in RFC 1779 syntax). |
79 `passwd' is the password to use for simple authentication. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
80 `auth' is the authentication method to use. |
27313 | 81 Possible values are: `simple', `krbv41' and `krbv42'. |
82 `base' is the base for the search as described in RFC 1779. | |
83 `scope' is one of the three symbols `subtree', `base' or `onelevel'. | |
84 `deref' is one of the symbols `never', `always', `search' or `find'. | |
85 `timelimit' is the timeout limit for the connection in seconds. | |
86 `sizelimit' is the maximum number of matches to return." | |
87 :type '(repeat :menu-tag "Host parameters" | |
88 :tag "Host parameters" | |
89 (list :menu-tag "Host parameters" | |
90 :tag "Host parameters" | |
91 :value nil | |
92 (string :tag "Host name") | |
93 (checklist :inline t | |
94 :greedy t | |
95 (list | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
96 :tag "Search Base" |
27313 | 97 :inline t |
98 (const :tag "Search Base" base) | |
99 string) | |
100 (list | |
101 :tag "Binding DN" | |
102 :inline t | |
103 (const :tag "Binding DN" binddn) | |
104 string) | |
105 (list | |
106 :tag "Password" | |
107 :inline t | |
108 (const :tag "Password" passwd) | |
109 string) | |
110 (list | |
111 :tag "Authentication Method" | |
112 :inline t | |
113 (const :tag "Authentication Method" auth) | |
114 (choice | |
115 (const :menu-tag "None" :tag "None" nil) | |
116 (const :menu-tag "Simple" :tag "Simple" simple) | |
117 (const :menu-tag "Kerberos 4.1" :tag "Kerberos 4.1" krbv41) | |
118 (const :menu-tag "Kerberos 4.2" :tag "Kerberos 4.2" krbv42))) | |
119 (list | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
120 :tag "Search Scope" |
27313 | 121 :inline t |
122 (const :tag "Search Scope" scope) | |
123 (choice | |
124 (const :menu-tag "Default" :tag "Default" nil) | |
125 (const :menu-tag "Subtree" :tag "Subtree" subtree) | |
126 (const :menu-tag "Base" :tag "Base" base) | |
127 (const :menu-tag "One Level" :tag "One Level" onelevel))) | |
128 (list | |
129 :tag "Dereferencing" | |
130 :inline t | |
131 (const :tag "Dereferencing" deref) | |
132 (choice | |
133 (const :menu-tag "Default" :tag "Default" nil) | |
134 (const :menu-tag "Never" :tag "Never" never) | |
135 (const :menu-tag "Always" :tag "Always" always) | |
136 (const :menu-tag "When searching" :tag "When searching" search) | |
137 (const :menu-tag "When locating base" :tag "When locating base" find))) | |
138 (list | |
139 :tag "Time Limit" | |
140 :inline t | |
141 (const :tag "Time Limit" timelimit) | |
142 (integer :tag "(in seconds)")) | |
143 (list | |
144 :tag "Size Limit" | |
145 :inline t | |
146 (const :tag "Size Limit" sizelimit) | |
147 (integer :tag "(number of records)"))))) | |
148 :group 'ldap) | |
149 | |
150 (defcustom ldap-ldapsearch-prog "ldapsearch" | |
151 "*The name of the ldapsearch command line program." | |
152 :type '(string :tag "`ldapsearch' Program") | |
153 :group 'ldap) | |
154 | |
71331
f4495654b2ad
2006-06-13 Martin J. Reed <mjreed@essex.ac.uk> (tiny change)
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
155 (defcustom ldap-ldapsearch-args '("-LL" "-tt") |
42783
c1bb3d3c9621
(ldap-ldapsearch-prog): Default to OpenLDAP version 2 ldapsearch.
Pavel Janík <Pavel@Janik.cz>
parents:
42607
diff
changeset
|
156 "*A list of additional arguments to pass to `ldapsearch'." |
27313 | 157 :type '(repeat :tag "`ldapsearch' Arguments" |
158 (string :tag "Argument")) | |
159 :group 'ldap) | |
160 | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
161 (defcustom ldap-ignore-attribute-codings nil |
27313 | 162 "*If non-nil, do not encode/decode LDAP attribute values." |
163 :type 'boolean | |
164 :group 'ldap) | |
165 | |
166 (defcustom ldap-default-attribute-decoder nil | |
167 "*Decoder function to use for attributes whose syntax is unknown." | |
168 :type 'symbol | |
169 :group 'ldap) | |
170 | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
171 (defcustom ldap-coding-system 'utf-8 |
27313 | 172 "*Coding system of LDAP string values. |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
173 LDAP v3 specifies the coding system of strings to be UTF-8." |
27313 | 174 :type 'symbol |
175 :group 'ldap) | |
176 | |
177 (defvar ldap-attribute-syntax-encoders | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
178 [nil ; 1 ACI Item N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
179 nil ; 2 Access Point Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
180 nil ; 3 Attribute Type Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
181 nil ; 4 Audio N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
182 nil ; 5 Binary N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
183 nil ; 6 Bit String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
184 ldap-encode-boolean ; 7 Boolean Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
185 nil ; 8 Certificate N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
186 nil ; 9 Certificate List N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
187 nil ; 10 Certificate Pair N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
188 ldap-encode-country-string ; 11 Country String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
189 ldap-encode-string ; 12 DN Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
190 nil ; 13 Data Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
191 nil ; 14 Delivery Method Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
192 ldap-encode-string ; 15 Directory String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
193 nil ; 16 DIT Content Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
194 nil ; 17 DIT Structure Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
195 nil ; 18 DL Submit Permission Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
196 nil ; 19 DSA Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
197 nil ; 20 DSE Type Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
198 nil ; 21 Enhanced Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
199 nil ; 22 Facsimile Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
200 nil ; 23 Fax N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
201 nil ; 24 Generalized Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
202 nil ; 25 Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
203 nil ; 26 IA5 String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
204 number-to-string ; 27 INTEGER Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
205 nil ; 28 JPEG N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
206 nil ; 29 Master And Shadow Access Points Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
207 nil ; 30 Matching Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
208 nil ; 31 Matching Rule Use Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
209 nil ; 32 Mail Preference Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
210 nil ; 33 MHS OR Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
211 nil ; 34 Name And Optional UID Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
212 nil ; 35 Name Form Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
213 nil ; 36 Numeric String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
214 nil ; 37 Object Class Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
215 nil ; 38 OID Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
216 nil ; 39 Other Mailbox Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
217 nil ; 40 Octet String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
218 ldap-encode-address ; 41 Postal Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
219 nil ; 42 Protocol Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
220 nil ; 43 Presentation Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
221 ldap-encode-string ; 44 Printable String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
222 nil ; 45 Subtree Specification Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
223 nil ; 46 Supplier Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
224 nil ; 47 Supplier Or Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
225 nil ; 48 Supplier And Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
226 nil ; 49 Supported Algorithm N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
227 nil ; 50 Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
228 nil ; 51 Teletex Terminal Identifier Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
229 nil ; 52 Telex Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
230 nil ; 53 UTC Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
231 nil ; 54 LDAP Syntax Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
232 nil ; 55 Modify Rights Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
233 nil ; 56 LDAP Schema Definition Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
234 nil ; 57 LDAP Schema Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
235 nil ; 58 Substring Assertion Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
236 ] |
27313 | 237 "A vector of functions used to encode LDAP attribute values. |
238 The sequence of functions corresponds to the sequence of LDAP attribute syntax | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
239 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in |
27313 | 240 RFC2252 section 4.3.2") |
241 | |
242 (defvar ldap-attribute-syntax-decoders | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
243 [nil ; 1 ACI Item N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
244 nil ; 2 Access Point Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
245 nil ; 3 Attribute Type Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
246 nil ; 4 Audio N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
247 nil ; 5 Binary N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
248 nil ; 6 Bit String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
249 ldap-decode-boolean ; 7 Boolean Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
250 nil ; 8 Certificate N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
251 nil ; 9 Certificate List N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
252 nil ; 10 Certificate Pair N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
253 ldap-decode-string ; 11 Country String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
254 ldap-decode-string ; 12 DN Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
255 nil ; 13 Data Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
256 nil ; 14 Delivery Method Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
257 ldap-decode-string ; 15 Directory String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
258 nil ; 16 DIT Content Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
259 nil ; 17 DIT Structure Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
260 nil ; 18 DL Submit Permission Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
261 nil ; 19 DSA Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
262 nil ; 20 DSE Type Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
263 nil ; 21 Enhanced Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
264 nil ; 22 Facsimile Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
265 nil ; 23 Fax N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
266 nil ; 24 Generalized Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
267 nil ; 25 Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
268 nil ; 26 IA5 String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
269 string-to-number ; 27 INTEGER Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
270 nil ; 28 JPEG N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
271 nil ; 29 Master And Shadow Access Points Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
272 nil ; 30 Matching Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
273 nil ; 31 Matching Rule Use Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
274 nil ; 32 Mail Preference Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
275 nil ; 33 MHS OR Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
276 nil ; 34 Name And Optional UID Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
277 nil ; 35 Name Form Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
278 nil ; 36 Numeric String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
279 nil ; 37 Object Class Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
280 nil ; 38 OID Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
281 nil ; 39 Other Mailbox Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
282 nil ; 40 Octet String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
283 ldap-decode-address ; 41 Postal Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
284 nil ; 42 Protocol Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
285 nil ; 43 Presentation Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
286 ldap-decode-string ; 44 Printable String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
287 nil ; 45 Subtree Specification Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
288 nil ; 46 Supplier Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
289 nil ; 47 Supplier Or Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
290 nil ; 48 Supplier And Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
291 nil ; 49 Supported Algorithm N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
292 nil ; 50 Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
293 nil ; 51 Teletex Terminal Identifier Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
294 nil ; 52 Telex Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
295 nil ; 53 UTC Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
296 nil ; 54 LDAP Syntax Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
297 nil ; 55 Modify Rights Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
298 nil ; 56 LDAP Schema Definition Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
299 nil ; 57 LDAP Schema Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
300 nil ; 58 Substring Assertion Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
301 ] |
27313 | 302 "A vector of functions used to decode LDAP attribute values. |
303 The sequence of functions corresponds to the sequence of LDAP attribute syntax | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
304 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in |
27313 | 305 RFC2252 section 4.3.2") |
306 | |
307 | |
308 (defvar ldap-attribute-syntaxes-alist | |
309 '((createtimestamp . 24) | |
310 (modifytimestamp . 24) | |
311 (creatorsname . 12) | |
312 (modifiersname . 12) | |
313 (subschemasubentry . 12) | |
314 (attributetypes . 3) | |
315 (objectclasses . 37) | |
316 (matchingrules . 30) | |
317 (matchingruleuse . 31) | |
318 (namingcontexts . 12) | |
319 (altserver . 26) | |
320 (supportedextension . 38) | |
321 (supportedcontrol . 38) | |
322 (supportedsaslmechanisms . 15) | |
323 (supportedldapversion . 27) | |
324 (ldapsyntaxes . 16) | |
325 (ditstructurerules . 17) | |
326 (nameforms . 35) | |
327 (ditcontentrules . 16) | |
328 (objectclass . 38) | |
329 (aliasedobjectname . 12) | |
330 (cn . 15) | |
331 (sn . 15) | |
332 (serialnumber . 44) | |
333 (c . 15) | |
334 (l . 15) | |
335 (st . 15) | |
336 (street . 15) | |
337 (o . 15) | |
338 (ou . 15) | |
339 (title . 15) | |
340 (description . 15) | |
341 (searchguide . 25) | |
342 (businesscategory . 15) | |
343 (postaladdress . 41) | |
344 (postalcode . 15) | |
345 (postofficebox . 15) | |
346 (physicaldeliveryofficename . 15) | |
347 (telephonenumber . 50) | |
348 (telexnumber . 52) | |
349 (telexterminalidentifier . 51) | |
350 (facsimiletelephonenumber . 22) | |
351 (x121address . 36) | |
352 (internationalisdnnumber . 36) | |
353 (registeredaddress . 41) | |
354 (destinationindicator . 44) | |
355 (preferreddeliverymethod . 14) | |
356 (presentationaddress . 43) | |
357 (supportedapplicationcontext . 38) | |
358 (member . 12) | |
359 (owner . 12) | |
360 (roleoccupant . 12) | |
361 (seealso . 12) | |
362 (userpassword . 40) | |
363 (usercertificate . 8) | |
364 (cacertificate . 8) | |
365 (authorityrevocationlist . 9) | |
366 (certificaterevocationlist . 9) | |
367 (crosscertificatepair . 10) | |
368 (name . 15) | |
369 (givenname . 15) | |
370 (initials . 15) | |
371 (generationqualifier . 15) | |
372 (x500uniqueidentifier . 6) | |
373 (dnqualifier . 44) | |
374 (enhancedsearchguide . 21) | |
375 (protocolinformation . 42) | |
376 (distinguishedname . 12) | |
377 (uniquemember . 34) | |
378 (houseidentifier . 15) | |
379 (supportedalgorithms . 49) | |
380 (deltarevocationlist . 9) | |
381 (dmdname . 15)) | |
382 "A map of LDAP attribute names to their type object id minor number. | |
383 This table is built from RFC2252 Section 5 and RFC2256 Section 5") | |
384 | |
385 | |
386 ;; Coding/decoding functions | |
387 | |
388 (defun ldap-encode-boolean (bool) | |
389 (if bool | |
390 "TRUE" | |
391 "FALSE")) | |
392 | |
393 (defun ldap-decode-boolean (str) | |
394 (cond | |
395 ((string-equal str "TRUE") | |
396 t) | |
397 ((string-equal str "FALSE") | |
398 nil) | |
399 (t | |
400 (error "Wrong LDAP boolean string: %s" str)))) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
401 |
27313 | 402 (defun ldap-encode-country-string (str) |
403 ;; We should do something useful here... | |
404 (if (not (= 2 (length str))) | |
405 (error "Invalid country string: %s" str))) | |
406 | |
407 (defun ldap-decode-string (str) | |
408 (decode-coding-string str ldap-coding-system)) | |
409 | |
410 (defun ldap-encode-string (str) | |
411 (encode-coding-string str ldap-coding-system)) | |
412 | |
413 (defun ldap-decode-address (str) | |
414 (mapconcat 'ldap-decode-string | |
415 (split-string str "\\$") | |
416 "\n")) | |
417 | |
418 (defun ldap-encode-address (str) | |
419 (mapconcat 'ldap-encode-string | |
420 (split-string str "\n") | |
421 "$")) | |
422 | |
423 | |
424 ;; LDAP protocol functions | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
425 |
27313 | 426 (defun ldap-get-host-parameter (host parameter) |
427 "Get the value of PARAMETER for HOST in `ldap-host-parameters-alist'." | |
428 (plist-get (cdr (assoc host ldap-host-parameters-alist)) | |
429 parameter)) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
430 |
27313 | 431 (defun ldap-decode-attribute (attr) |
432 "Decode the attribute/value pair ATTR according to LDAP rules. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
433 The attribute name is looked up in `ldap-attribute-syntaxes-alist' |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
434 and the corresponding decoder is then retrieved from |
27313 | 435 `ldap-attribute-syntax-decoders' and applied on the value(s)." |
436 (let* ((name (car attr)) | |
437 (values (cdr attr)) | |
438 (syntax-id (cdr (assq (intern (downcase name)) | |
439 ldap-attribute-syntaxes-alist))) | |
440 decoder) | |
441 (if syntax-id | |
442 (setq decoder (aref ldap-attribute-syntax-decoders | |
443 (1- syntax-id))) | |
444 (setq decoder ldap-default-attribute-decoder)) | |
445 (if decoder | |
446 (cons name (mapcar decoder values)) | |
447 attr))) | |
448 | |
449 (defun ldap-search (filter &optional host attributes attrsonly withdn) | |
450 "Perform an LDAP search. | |
451 FILTER is the search filter in RFC1558 syntax. | |
452 HOST is the LDAP host on which to perform the search. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
453 ATTRIBUTES are the specific attributes to retrieve, nil means |
27313 | 454 retrieve all. |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
455 ATTRSONLY, if non-nil, retrieves the attributes only, without |
27313 | 456 the associated values. |
457 If WITHDN is non-nil, each entry in the result will be prepended with | |
458 its distinguished name WITHDN. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
459 Additional search parameters can be specified through |
27313 | 460 `ldap-host-parameters-alist', which see." |
461 (interactive "sFilter:") | |
462 (or host | |
463 (setq host ldap-default-host) | |
464 (error "No LDAP host specified")) | |
465 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) | |
466 result) | |
54805
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
467 (setq result (ldap-search-internal (list* 'host host |
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
468 'filter filter |
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
469 'attributes attributes |
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
470 'attrsonly attrsonly |
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
471 'withdn withdn |
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
472 host-plist))) |
27313 | 473 (if ldap-ignore-attribute-codings |
474 result | |
54805
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
475 (mapcar (lambda (record) |
37581abcf761
(ldap-search): Use list*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54359
diff
changeset
|
476 (mapcar 'ldap-decode-attribute record)) |
27313 | 477 result)))) |
478 | |
479 | |
480 (defun ldap-search-internal (search-plist) | |
481 "Perform a search on a LDAP server. | |
482 SEARCH-PLIST is a property list describing the search request. | |
483 Valid keys in that list are: | |
484 `host' is a string naming one or more (blank-separated) LDAP servers to | |
485 to try to connect to. Each host name may optionally be of the form HOST:PORT. | |
486 `filter' is a filter string for the search as described in RFC 1558. | |
487 `attributes' is a list of strings indicating which attributes to retrieve | |
488 for each matching entry. If nil, return all available attributes. | |
489 `attrsonly', if non-nil, indicates that only attributes are retrieved, | |
490 not their associated values. | |
72701
891321627212
* net/ldap.el (ldap-search-internal): Handle `auth' key.
Chong Yidong <cyd@stupidchicken.com>
parents:
71331
diff
changeset
|
491 `auth' is one of the symbols `simple', `krbv41' or `krbv42'. |
27313 | 492 `base' is the base for the search as described in RFC 1779. |
493 `scope' is one of the three symbols `sub', `base' or `one'. | |
494 `binddn' is the distinguished name of the user to bind as (in RFC 1779 syntax). | |
72752
f9449f64d4b8
(ldap-search-internal): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
72701
diff
changeset
|
495 `auth' is one of the symbols `simple', `krbv41' or `krbv42' |
27313 | 496 `passwd' is the password to use for simple authentication. |
497 `deref' is one of the symbols `never', `always', `search' or `find'. | |
498 `timelimit' is the timeout limit for the connection in seconds. | |
499 `sizelimit' is the maximum number of matches to return. | |
500 `withdn' if non-nil each entry in the result will be prepended with | |
501 its distinguished name DN. | |
502 The function returns a list of matching entries. Each entry is itself | |
503 an alist of attribute/value pairs." | |
504 (let ((buf (get-buffer-create " *ldap-search*")) | |
505 (bufval (get-buffer-create " *ldap-value*")) | |
506 (host (or (plist-get search-plist 'host) | |
507 ldap-default-host)) | |
508 (filter (plist-get search-plist 'filter)) | |
509 (attributes (plist-get search-plist 'attributes)) | |
510 (attrsonly (plist-get search-plist 'attrsonly)) | |
511 (base (or (plist-get search-plist 'base) | |
512 ldap-default-base)) | |
513 (scope (plist-get search-plist 'scope)) | |
514 (binddn (plist-get search-plist 'binddn)) | |
72701
891321627212
* net/ldap.el (ldap-search-internal): Handle `auth' key.
Chong Yidong <cyd@stupidchicken.com>
parents:
71331
diff
changeset
|
515 (auth (plist-get search-plist 'auth)) |
27313 | 516 (passwd (plist-get search-plist 'passwd)) |
517 (deref (plist-get search-plist 'deref)) | |
518 (timelimit (plist-get search-plist 'timelimit)) | |
519 (sizelimit (plist-get search-plist 'sizelimit)) | |
520 (withdn (plist-get search-plist 'withdn)) | |
521 (numres 0) | |
522 arglist dn name value record result) | |
523 (if (or (null filter) | |
524 (equal "" filter)) | |
525 (error "No search filter")) | |
526 (setq filter (cons filter attributes)) | |
527 (save-excursion | |
528 (set-buffer buf) | |
529 (erase-buffer) | |
530 (if (and host | |
531 (not (equal "" host))) | |
532 (setq arglist (nconc arglist (list (format "-h%s" host))))) | |
533 (if (and attrsonly | |
534 (not (equal "" attrsonly))) | |
535 (setq arglist (nconc arglist (list "-A")))) | |
536 (if (and base | |
537 (not (equal "" base))) | |
538 (setq arglist (nconc arglist (list (format "-b%s" base))))) | |
539 (if (and scope | |
540 (not (equal "" scope))) | |
541 (setq arglist (nconc arglist (list (format "-s%s" scope))))) | |
542 (if (and binddn | |
543 (not (equal "" binddn))) | |
544 (setq arglist (nconc arglist (list (format "-D%s" binddn))))) | |
72701
891321627212
* net/ldap.el (ldap-search-internal): Handle `auth' key.
Chong Yidong <cyd@stupidchicken.com>
parents:
71331
diff
changeset
|
545 (if (and auth |
891321627212
* net/ldap.el (ldap-search-internal): Handle `auth' key.
Chong Yidong <cyd@stupidchicken.com>
parents:
71331
diff
changeset
|
546 (equal 'simple auth)) |
891321627212
* net/ldap.el (ldap-search-internal): Handle `auth' key.
Chong Yidong <cyd@stupidchicken.com>
parents:
71331
diff
changeset
|
547 (setq arglist (nconc arglist (list "-x")))) |
27313 | 548 (if (and passwd |
549 (not (equal "" passwd))) | |
550 (setq arglist (nconc arglist (list (format "-w%s" passwd))))) | |
551 (if (and deref | |
552 (not (equal "" deref))) | |
553 (setq arglist (nconc arglist (list (format "-a%s" deref))))) | |
554 (if (and timelimit | |
555 (not (equal "" timelimit))) | |
556 (setq arglist (nconc arglist (list (format "-l%s" timelimit))))) | |
557 (if (and sizelimit | |
558 (not (equal "" sizelimit))) | |
559 (setq arglist (nconc arglist (list (format "-z%s" sizelimit))))) | |
560 (eval `(call-process ldap-ldapsearch-prog | |
561 nil | |
71331
f4495654b2ad
2006-06-13 Martin J. Reed <mjreed@essex.ac.uk> (tiny change)
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
562 buf |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
563 nil |
27313 | 564 ,@arglist |
565 ,@ldap-ldapsearch-args | |
566 ,@filter)) | |
567 (insert "\n") | |
568 (goto-char (point-min)) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
569 |
45247
6baa96917e56
(ldap-search-internal): Unfold folded lines before parsing.
Pavel Janík <Pavel@Janik.cz>
parents:
42783
diff
changeset
|
570 (while (re-search-forward "[\t\n\f]+ " nil t) |
6baa96917e56
(ldap-search-internal): Unfold folded lines before parsing.
Pavel Janík <Pavel@Janik.cz>
parents:
42783
diff
changeset
|
571 (replace-match "" nil nil)) |
6baa96917e56
(ldap-search-internal): Unfold folded lines before parsing.
Pavel Janík <Pavel@Janik.cz>
parents:
42783
diff
changeset
|
572 (goto-char (point-min)) |
6baa96917e56
(ldap-search-internal): Unfold folded lines before parsing.
Pavel Janík <Pavel@Janik.cz>
parents:
42783
diff
changeset
|
573 |
27313 | 574 (if (looking-at "usage") |
575 (error "Incorrect ldapsearch invocation") | |
576 (message "Parsing results... ") | |
42579
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
577 ;; Skip error message when retrieving attribute list |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
578 (if (looking-at "Size limit exceeded") |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
579 (forward-line 1)) |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
580 (while (progn |
27313 | 581 (skip-chars-forward " \t\n") |
582 (not (eobp))) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
583 (setq dn (buffer-substring (point) (save-excursion |
27313 | 584 (end-of-line) |
585 (point)))) | |
586 (forward-line 1) | |
97435
92660418caae
(ldap-search-internal): Tweak URL regexp.
Chong Yidong <cyd@stupidchicken.com>
parents:
94677
diff
changeset
|
587 (while (looking-at "^\\([A-Za-z][-A-Za-z0-9]*\ |
92660418caae
(ldap-search-internal): Tweak URL regexp.
Chong Yidong <cyd@stupidchicken.com>
parents:
94677
diff
changeset
|
588 \\|[0-9]+\\(?:\\.[0-9]+\\)*\\)\\(;[-A-Za-z0-9]+\\)*[=:\t ]+\ |
92660418caae
(ldap-search-internal): Tweak URL regexp.
Chong Yidong <cyd@stupidchicken.com>
parents:
94677
diff
changeset
|
589 \\(<[\t ]*file://\\)\\(.*\\)$") |
27313 | 590 (setq name (match-string 1) |
59935
ccb26cb917af
(ldap-search-internal): Support attributes with
Eli Zaretskii <eliz@gnu.org>
parents:
55698
diff
changeset
|
591 value (match-string 4)) |
54359
e63d620f8988
(ldap-search-internal): Handle file URLs with drive
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
592 ;; Need to handle file:///D:/... as generated by OpenLDAP |
e63d620f8988
(ldap-search-internal): Handle file URLs with drive
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
593 ;; on DOS/Windows as local files. |
e63d620f8988
(ldap-search-internal): Handle file URLs with drive
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
594 (if (and (memq system-type '(windows-nt ms-dos)) |
e63d620f8988
(ldap-search-internal): Handle file URLs with drive
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
595 (eq (string-match "/\\(.:.*\\)$" value) 0)) |
e63d620f8988
(ldap-search-internal): Handle file URLs with drive
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
596 (setq value (match-string 1 value))) |
42579
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
597 ;; Do not try to open non-existent files |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
598 (if (equal value "") |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
599 (setq value " ") |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
600 (save-excursion |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
601 (set-buffer bufval) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
602 (erase-buffer) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
603 (set-buffer-multibyte nil) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
604 (insert-file-contents-literally value) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
605 (delete-file value) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
606 (setq value (buffer-string)))) |
27313 | 607 (setq record (cons (list name value) |
608 record)) | |
609 (forward-line 1)) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
610 (setq result (cons (if withdn |
27313 | 611 (cons dn (nreverse record)) |
612 (nreverse record)) result)) | |
613 (setq record nil) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
614 (skip-chars-forward " \t\n") |
27313 | 615 (message "Parsing results... %d" numres) |
616 (1+ numres)) | |
617 (message "Parsing results... done") | |
618 (nreverse result))))) | |
619 | |
620 (provide 'ldap) | |
621 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79714
diff
changeset
|
622 ;; arch-tag: 47913a76-6155-42e6-ac58-6d28b5d50eb0 |
27313 | 623 ;;; ldap.el ends here |