comparison lisp/ldap.el @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 0784d089fdc9
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
4 4
5 ;; Author: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> 5 ;; Author: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
6 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> 6 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
7 ;; Created: Jan 1998 7 ;; Created: Jan 1998
8 ;; Version: $Revision: 1.7.2.8 $ 8 ;; Version: $Revision: 1.7.2.9 $
9 ;; Keywords: help comm 9 ;; Keywords: help comm
10 10
11 ;; This file is part of XEmacs 11 ;; This file is part of XEmacs
12 12
13 ;; XEmacs is free software; you can redistribute it and/or modify it 13 ;; XEmacs is free software; you can redistribute it and/or modify it
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of 19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 ;; General Public License for more details. 21 ;; General Public License for more details.
22 22
23 ;; 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
24 ;; along with XEmacs; see the file COPYING. If not, write to 24 ;; along with XEmacs; see the file COPYING. If not, write to
25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA. 26 ;; Boston, MA 02111-1307, USA.
27 27
28 ;;; Commentary: 28 ;;; Commentary:
29 ;; This file provides mid-level and user-level functions to access directory 29 ;; This file provides mid-level and user-level functions to access directory
30 ;; servers using the LDAP protocol (RFC 1777). 30 ;; servers using the LDAP protocol (RFC 1777).
31 31
32 ;;; Installation: 32 ;;; Installation:
33 ;; LDAP support must have been built into XEmacs. 33 ;; LDAP support must have been built into XEmacs.
34 34
35 35
43 "Lightweight Directory Access Protocol" 43 "Lightweight Directory Access Protocol"
44 :group 'comm) 44 :group 'comm)
45 45
46 (defcustom ldap-default-host nil 46 (defcustom ldap-default-host nil
47 "*Default LDAP server hostname. 47 "*Default LDAP server hostname.
48 A TCP port number can be appended to that name using a colon as 48 A TCP port number can be appended to that name using a colon as
49 a separator." 49 a separator."
50 :type '(choice (string :tag "Host name") 50 :type '(choice (string :tag "Host name")
51 (const :tag "Use library default" nil)) 51 (const :tag "Use library default" nil))
52 :group 'ldap) 52 :group 'ldap)
53 53
71 (defcustom ldap-host-parameters-alist nil 71 (defcustom ldap-host-parameters-alist nil
72 "*Alist of host-specific options for LDAP transactions. 72 "*Alist of host-specific options for LDAP transactions.
73 The format of each list element is: 73 The format of each list element is:
74 \(HOST PROP1 VAL1 PROP2 VAL2 ...) 74 \(HOST PROP1 VAL1 PROP2 VAL2 ...)
75 HOST is the hostname of an LDAP server (with an optional TCP port number 75 HOST is the hostname of an LDAP server (with an optional TCP port number
76 appended to it using a colon as a separator). 76 appended to it using a colon as a separator).
77 PROPn and VALn are property/value pairs describing parameters for the server. 77 PROPn and VALn are property/value pairs describing parameters for the server.
78 Valid properties include: 78 Valid properties include:
79 `binddn' is the distinguished name of the user to bind as 79 `binddn' is the distinguished name of the user to bind as
80 (in RFC 1779 syntax). 80 (in RFC 1779 syntax).
81 `passwd' is the password to use for simple authentication. 81 `passwd' is the password to use for simple authentication.
82 `auth' is the authentication method to use. 82 `auth' is the authentication method to use.
83 Possible values are: `simple', `krbv41' and `krbv42'. 83 Possible values are: `simple', `krbv41' and `krbv42'.
84 `base' is the base for the search as described in RFC 1779. 84 `base' is the base for the search as described in RFC 1779.
85 `scope' is one of the three symbols `subtree', `base' or `onelevel'. 85 `scope' is one of the three symbols `subtree', `base' or `onelevel'.
86 `deref' is one of the symbols `never', `always', `search' or `find'. 86 `deref' is one of the symbols `never', `always', `search' or `find'.
87 `timelimit' is the timeout limit for the connection in seconds. 87 `timelimit' is the timeout limit for the connection in seconds.
93 :value nil 93 :value nil
94 (string :tag "Host name") 94 (string :tag "Host name")
95 (checklist :inline t 95 (checklist :inline t
96 :greedy t 96 :greedy t
97 (list 97 (list
98 :tag "Search Base" 98 :tag "Search Base"
99 :inline t 99 :inline t
100 (const :tag "Search Base" base) 100 (const :tag "Search Base" base)
101 string) 101 string)
102 (list 102 (list
103 :tag "Binding DN" 103 :tag "Binding DN"
117 (const :menu-tag "None" :tag "None" nil) 117 (const :menu-tag "None" :tag "None" nil)
118 (const :menu-tag "Simple" :tag "Simple" simple) 118 (const :menu-tag "Simple" :tag "Simple" simple)
119 (const :menu-tag "Kerberos 4.1" :tag "Kerberos 4.1" krbv41) 119 (const :menu-tag "Kerberos 4.1" :tag "Kerberos 4.1" krbv41)
120 (const :menu-tag "Kerberos 4.2" :tag "Kerberos 4.2" krbv42))) 120 (const :menu-tag "Kerberos 4.2" :tag "Kerberos 4.2" krbv42)))
121 (list 121 (list
122 :tag "Search Scope" 122 :tag "Search Scope"
123 :inline t 123 :inline t
124 (const :tag "Search Scope" scope) 124 (const :tag "Search Scope" scope)
125 (choice 125 (choice
126 (const :menu-tag "Default" :tag "Default" nil) 126 (const :menu-tag "Default" :tag "Default" nil)
127 (const :menu-tag "Subtree" :tag "Subtree" subtree) 127 (const :menu-tag "Subtree" :tag "Subtree" subtree)
164 :type 'symbol 164 :type 'symbol
165 :group 'ldap) 165 :group 'ldap)
166 166
167 (defcustom ldap-coding-system nil 167 (defcustom ldap-coding-system nil
168 "*Coding system of LDAP string values. 168 "*Coding system of LDAP string values.
169 LDAP v3 specifies the coding system of strings to be UTF-8. 169 LDAP v3 specifies the coding system of strings to be UTF-8.
170 Mule support is needed for this." 170 Mule support is needed for this."
171 :type 'symbol 171 :type 'symbol
172 :group 'ldap) 172 :group 'ldap)
173 173
174 (defvar ldap-attribute-syntax-encoders 174 (defvar ldap-attribute-syntax-encoders
175 [nil ; 1 ACI Item N 175 [nil ; 1 ACI Item N
176 nil ; 2 Access Point Y 176 nil ; 2 Access Point Y
177 nil ; 3 Attribute Type Description Y 177 nil ; 3 Attribute Type Description Y
178 nil ; 4 Audio N 178 nil ; 4 Audio N
179 nil ; 5 Binary N 179 nil ; 5 Binary N
180 nil ; 6 Bit String Y 180 nil ; 6 Bit String Y
181 ldap-encode-boolean ; 7 Boolean Y 181 ldap-encode-boolean ; 7 Boolean Y
182 nil ; 8 Certificate N 182 nil ; 8 Certificate N
183 nil ; 9 Certificate List N 183 nil ; 9 Certificate List N
184 nil ; 10 Certificate Pair N 184 nil ; 10 Certificate Pair N
185 ldap-encode-country-string ; 11 Country String Y 185 ldap-encode-country-string ; 11 Country String Y
186 ldap-encode-string ; 12 DN Y 186 ldap-encode-string ; 12 DN Y
187 nil ; 13 Data Quality Syntax Y 187 nil ; 13 Data Quality Syntax Y
188 nil ; 14 Delivery Method Y 188 nil ; 14 Delivery Method Y
189 ldap-encode-string ; 15 Directory String Y 189 ldap-encode-string ; 15 Directory String Y
190 nil ; 16 DIT Content Rule Description Y 190 nil ; 16 DIT Content Rule Description Y
191 nil ; 17 DIT Structure Rule Description Y 191 nil ; 17 DIT Structure Rule Description Y
192 nil ; 18 DL Submit Permission Y 192 nil ; 18 DL Submit Permission Y
193 nil ; 19 DSA Quality Syntax Y 193 nil ; 19 DSA Quality Syntax Y
194 nil ; 20 DSE Type Y 194 nil ; 20 DSE Type Y
195 nil ; 21 Enhanced Guide Y 195 nil ; 21 Enhanced Guide Y
196 nil ; 22 Facsimile Telephone Number Y 196 nil ; 22 Facsimile Telephone Number Y
197 nil ; 23 Fax N 197 nil ; 23 Fax N
198 nil ; 24 Generalized Time Y 198 nil ; 24 Generalized Time Y
199 nil ; 25 Guide Y 199 nil ; 25 Guide Y
200 nil ; 26 IA5 String Y 200 nil ; 26 IA5 String Y
201 number-to-string ; 27 INTEGER Y 201 number-to-string ; 27 INTEGER Y
202 nil ; 28 JPEG N 202 nil ; 28 JPEG N
203 nil ; 29 Master And Shadow Access Points Y 203 nil ; 29 Master And Shadow Access Points Y
204 nil ; 30 Matching Rule Description Y 204 nil ; 30 Matching Rule Description Y
205 nil ; 31 Matching Rule Use Description Y 205 nil ; 31 Matching Rule Use Description Y
206 nil ; 32 Mail Preference Y 206 nil ; 32 Mail Preference Y
207 nil ; 33 MHS OR Address Y 207 nil ; 33 MHS OR Address Y
208 nil ; 34 Name And Optional UID Y 208 nil ; 34 Name And Optional UID Y
209 nil ; 35 Name Form Description Y 209 nil ; 35 Name Form Description Y
210 nil ; 36 Numeric String Y 210 nil ; 36 Numeric String Y
211 nil ; 37 Object Class Description Y 211 nil ; 37 Object Class Description Y
212 nil ; 38 OID Y 212 nil ; 38 OID Y
213 nil ; 39 Other Mailbox Y 213 nil ; 39 Other Mailbox Y
214 nil ; 40 Octet String Y 214 nil ; 40 Octet String Y
215 ldap-encode-address ; 41 Postal Address Y 215 ldap-encode-address ; 41 Postal Address Y
216 nil ; 42 Protocol Information Y 216 nil ; 42 Protocol Information Y
217 nil ; 43 Presentation Address Y 217 nil ; 43 Presentation Address Y
218 ldap-encode-string ; 44 Printable String Y 218 ldap-encode-string ; 44 Printable String Y
219 nil ; 45 Subtree Specification Y 219 nil ; 45 Subtree Specification Y
220 nil ; 46 Supplier Information Y 220 nil ; 46 Supplier Information Y
221 nil ; 47 Supplier Or Consumer Y 221 nil ; 47 Supplier Or Consumer Y
222 nil ; 48 Supplier And Consumer Y 222 nil ; 48 Supplier And Consumer Y
223 nil ; 49 Supported Algorithm N 223 nil ; 49 Supported Algorithm N
224 nil ; 50 Telephone Number Y 224 nil ; 50 Telephone Number Y
225 nil ; 51 Teletex Terminal Identifier Y 225 nil ; 51 Teletex Terminal Identifier Y
226 nil ; 52 Telex Number Y 226 nil ; 52 Telex Number Y
227 nil ; 53 UTC Time Y 227 nil ; 53 UTC Time Y
228 nil ; 54 LDAP Syntax Description Y 228 nil ; 54 LDAP Syntax Description Y
229 nil ; 55 Modify Rights Y 229 nil ; 55 Modify Rights Y
230 nil ; 56 LDAP Schema Definition Y 230 nil ; 56 LDAP Schema Definition Y
231 nil ; 57 LDAP Schema Description Y 231 nil ; 57 LDAP Schema Description Y
232 nil ; 58 Substring Assertion Y 232 nil ; 58 Substring Assertion Y
233 ] 233 ]
234 "A vector of functions used to encode LDAP attribute values. 234 "A vector of functions used to encode LDAP attribute values.
235 The sequence of functions corresponds to the sequence of LDAP attribute syntax 235 The sequence of functions corresponds to the sequence of LDAP attribute syntax
236 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in 236 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in
237 RFC2252 section 4.3.2") 237 RFC2252 section 4.3.2")
238 238
239 (defvar ldap-attribute-syntax-decoders 239 (defvar ldap-attribute-syntax-decoders
240 [nil ; 1 ACI Item N 240 [nil ; 1 ACI Item N
241 nil ; 2 Access Point Y 241 nil ; 2 Access Point Y
242 nil ; 3 Attribute Type Description Y 242 nil ; 3 Attribute Type Description Y
243 nil ; 4 Audio N 243 nil ; 4 Audio N
244 nil ; 5 Binary N 244 nil ; 5 Binary N
245 nil ; 6 Bit String Y 245 nil ; 6 Bit String Y
246 ldap-decode-boolean ; 7 Boolean Y 246 ldap-decode-boolean ; 7 Boolean Y
247 nil ; 8 Certificate N 247 nil ; 8 Certificate N
248 nil ; 9 Certificate List N 248 nil ; 9 Certificate List N
249 nil ; 10 Certificate Pair N 249 nil ; 10 Certificate Pair N
250 ldap-decode-string ; 11 Country String Y 250 ldap-decode-string ; 11 Country String Y
251 ldap-decode-string ; 12 DN Y 251 ldap-decode-string ; 12 DN Y
252 nil ; 13 Data Quality Syntax Y 252 nil ; 13 Data Quality Syntax Y
253 nil ; 14 Delivery Method Y 253 nil ; 14 Delivery Method Y
254 ldap-decode-string ; 15 Directory String Y 254 ldap-decode-string ; 15 Directory String Y
255 nil ; 16 DIT Content Rule Description Y 255 nil ; 16 DIT Content Rule Description Y
256 nil ; 17 DIT Structure Rule Description Y 256 nil ; 17 DIT Structure Rule Description Y
257 nil ; 18 DL Submit Permission Y 257 nil ; 18 DL Submit Permission Y
258 nil ; 19 DSA Quality Syntax Y 258 nil ; 19 DSA Quality Syntax Y
259 nil ; 20 DSE Type Y 259 nil ; 20 DSE Type Y
260 nil ; 21 Enhanced Guide Y 260 nil ; 21 Enhanced Guide Y
261 nil ; 22 Facsimile Telephone Number Y 261 nil ; 22 Facsimile Telephone Number Y
262 nil ; 23 Fax N 262 nil ; 23 Fax N
263 nil ; 24 Generalized Time Y 263 nil ; 24 Generalized Time Y
264 nil ; 25 Guide Y 264 nil ; 25 Guide Y
265 nil ; 26 IA5 String Y 265 nil ; 26 IA5 String Y
266 string-to-number ; 27 INTEGER Y 266 string-to-number ; 27 INTEGER Y
267 nil ; 28 JPEG N 267 nil ; 28 JPEG N
268 nil ; 29 Master And Shadow Access Points Y 268 nil ; 29 Master And Shadow Access Points Y
269 nil ; 30 Matching Rule Description Y 269 nil ; 30 Matching Rule Description Y
270 nil ; 31 Matching Rule Use Description Y 270 nil ; 31 Matching Rule Use Description Y
271 nil ; 32 Mail Preference Y 271 nil ; 32 Mail Preference Y
272 nil ; 33 MHS OR Address Y 272 nil ; 33 MHS OR Address Y
273 nil ; 34 Name And Optional UID Y 273 nil ; 34 Name And Optional UID Y
274 nil ; 35 Name Form Description Y 274 nil ; 35 Name Form Description Y
275 nil ; 36 Numeric String Y 275 nil ; 36 Numeric String Y
276 nil ; 37 Object Class Description Y 276 nil ; 37 Object Class Description Y
277 nil ; 38 OID Y 277 nil ; 38 OID Y
278 nil ; 39 Other Mailbox Y 278 nil ; 39 Other Mailbox Y
279 nil ; 40 Octet String Y 279 nil ; 40 Octet String Y
280 ldap-decode-address ; 41 Postal Address Y 280 ldap-decode-address ; 41 Postal Address Y
281 nil ; 42 Protocol Information Y 281 nil ; 42 Protocol Information Y
282 nil ; 43 Presentation Address Y 282 nil ; 43 Presentation Address Y
283 ldap-decode-string ; 44 Printable String Y 283 ldap-decode-string ; 44 Printable String Y
284 nil ; 45 Subtree Specification Y 284 nil ; 45 Subtree Specification Y
285 nil ; 46 Supplier Information Y 285 nil ; 46 Supplier Information Y
286 nil ; 47 Supplier Or Consumer Y 286 nil ; 47 Supplier Or Consumer Y
287 nil ; 48 Supplier And Consumer Y 287 nil ; 48 Supplier And Consumer Y
288 nil ; 49 Supported Algorithm N 288 nil ; 49 Supported Algorithm N
289 nil ; 50 Telephone Number Y 289 nil ; 50 Telephone Number Y
290 nil ; 51 Teletex Terminal Identifier Y 290 nil ; 51 Teletex Terminal Identifier Y
291 nil ; 52 Telex Number Y 291 nil ; 52 Telex Number Y
292 nil ; 53 UTC Time Y 292 nil ; 53 UTC Time Y
293 nil ; 54 LDAP Syntax Description Y 293 nil ; 54 LDAP Syntax Description Y
294 nil ; 55 Modify Rights Y 294 nil ; 55 Modify Rights Y
295 nil ; 56 LDAP Schema Definition Y 295 nil ; 56 LDAP Schema Definition Y
296 nil ; 57 LDAP Schema Description Y 296 nil ; 57 LDAP Schema Description Y
297 nil ; 58 Substring Assertion Y 297 nil ; 58 Substring Assertion Y
298 ] 298 ]
299 "A vector of functions used to decode LDAP attribute values. 299 "A vector of functions used to decode LDAP attribute values.
300 The sequence of functions corresponds to the sequence of LDAP attribute syntax 300 The sequence of functions corresponds to the sequence of LDAP attribute syntax
301 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in 301 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in
302 RFC2252 section 4.3.2") 302 RFC2252 section 4.3.2")
303 303
304 304
305 (defvar ldap-attribute-syntaxes-alist 305 (defvar ldap-attribute-syntaxes-alist
306 '((createtimestamp . 24) 306 '((createtimestamp . 24)
393 t) 393 t)
394 ((string-equal str "FALSE") 394 ((string-equal str "FALSE")
395 nil) 395 nil)
396 (t 396 (t
397 (error "Wrong LDAP boolean string: %s" str)))) 397 (error "Wrong LDAP boolean string: %s" str))))
398 398
399 (defun ldap-encode-country-string (str) 399 (defun ldap-encode-country-string (str)
400 ;; We should do something useful here... 400 ;; We should do something useful here...
401 (if (not (= 2 (length str))) 401 (if (not (= 2 (length str)))
402 (error "Invalid country string: %s" str))) 402 (error "Invalid country string: %s" str)))
403 403
419 (split-string str "\n") 419 (split-string str "\n")
420 "$")) 420 "$"))
421 421
422 422
423 ;; LDAP protocol functions 423 ;; LDAP protocol functions
424 424
425 (defun ldap-get-host-parameter (host parameter) 425 (defun ldap-get-host-parameter (host parameter)
426 "Get the value of PARAMETER for HOST in `ldap-host-parameters-alist'." 426 "Get the value of PARAMETER for HOST in `ldap-host-parameters-alist'."
427 (plist-get (cdr (assoc host ldap-host-parameters-alist)) 427 (plist-get (cdr (assoc host ldap-host-parameters-alist))
428 parameter)) 428 parameter))
429 429
430 (defun ldap-decode-attribute (attr) 430 (defun ldap-decode-attribute (attr)
431 "Decode the attribute/value pair ATTR according to LDAP rules. 431 "Decode the attribute/value pair ATTR according to LDAP rules.
432 The attribute name is looked up in `ldap-attribute-syntaxes-alist' 432 The attribute name is looked up in `ldap-attribute-syntaxes-alist'
433 and the corresponding decoder is then retrieved from 433 and the corresponding decoder is then retrieved from
434 `ldap-attribute-syntax-decoders' and applied on the value(s)." 434 `ldap-attribute-syntax-decoders' and applied on the value(s)."
435 (let* ((name (car attr)) 435 (let* ((name (car attr))
436 (values (cdr attr)) 436 (values (cdr attr))
437 (syntax-id (cdr (assq (intern (downcase name)) 437 (syntax-id (cdr (assq (intern (downcase name))
438 ldap-attribute-syntaxes-alist))) 438 ldap-attribute-syntaxes-alist)))
456 (if dn 456 (if dn
457 (cons dn decoded) 457 (cons dn decoded)
458 decoded))) 458 decoded)))
459 459
460 (defun ldap-search (arg1 &rest args) 460 (defun ldap-search (arg1 &rest args)
461 "Perform an LDAP search." 461 "Perform an LDAP search."
462 (apply (if (ldapp arg1) 462 (apply (if (ldapp arg1)
463 'ldap-search-basic 463 'ldap-search-basic
464 'ldap-search-entries) arg1 args)) 464 'ldap-search-entries) arg1 args))
465 465
466 (make-obsolete 'ldap-search 466 (make-obsolete 'ldap-search
467 "Use `ldap-search-entries' instead or 467 "Use `ldap-search-entries' instead or
468 `ldap-search-basic' for the low-level search API.") 468 `ldap-search-basic' for the low-level search API.")
469 469
470 (defun ldap-search-entries (filter &optional host attributes attrsonly withdn) 470 (defun ldap-search-entries (filter &optional host attributes attrsonly withdn)
471 "Perform an LDAP search. 471 "Perform an LDAP search.
472 FILTER is the search filter in RFC1558 syntax, i.e., something that 472 FILTER is the search filter in RFC1558 syntax, i.e., something that
475 ATTRIBUTES is a list of attributes to retrieve; nil means retrieve all. 475 ATTRIBUTES is a list of attributes to retrieve; nil means retrieve all.
476 If ATTRSONLY is non nil, the attributes will be retrieved without 476 If ATTRSONLY is non nil, the attributes will be retrieved without
477 the associated values. 477 the associated values.
478 If WITHDN is non-nil each entry in the result will be prepennded with 478 If WITHDN is non-nil each entry in the result will be prepennded with
479 its distinguished name DN. 479 its distinguished name DN.
480 Additional search parameters can be specified through 480 Additional search parameters can be specified through
481 `ldap-host-parameters-alist' which see. 481 `ldap-host-parameters-alist' which see.
482 The function returns a list of matching entries. Each entry is itself 482 The function returns a list of matching entries. Each entry is itself
483 an alist of attribute/value pairs optionally preceded by the DN of the 483 an alist of attribute/value pairs optionally preceded by the DN of the
484 entry according to the value of WITHDN." 484 entry according to the value of WITHDN."
485 (interactive "sFilter:") 485 (interactive "sFilter:")
492 (if ldap-verbose 492 (if ldap-verbose
493 (message "Opening LDAP connection to %s..." host)) 493 (message "Opening LDAP connection to %s..." host))
494 (setq ldap (ldap-open host host-plist)) 494 (setq ldap (ldap-open host host-plist))
495 (if ldap-verbose 495 (if ldap-verbose
496 (message "Searching with LDAP on %s..." host)) 496 (message "Searching with LDAP on %s..." host))
497 (setq result (ldap-search ldap filter 497 (setq result (ldap-search ldap filter
498 (plist-get host-plist 'base) 498 (plist-get host-plist 'base)
499 (plist-get host-plist 'scope) 499 (plist-get host-plist 'scope)
500 attributes attrsonly withdn 500 attributes attrsonly withdn
501 ldap-verbose)) 501 ldap-verbose))
502 (ldap-close ldap) 502 (ldap-close ldap)
504 result 504 result
505 (mapcar 'ldap-decode-entry result)))) 505 (mapcar 'ldap-decode-entry result))))
506 506
507 (defun ldap-add-entries (entries &optional host binddn passwd) 507 (defun ldap-add-entries (entries &optional host binddn passwd)
508 "Add entries to an LDAP directory. 508 "Add entries to an LDAP directory.
509 ENTRIES is a list of entry specifications of 509 ENTRIES is a list of entry specifications of
510 the form (DN (ATTR . VALUE) (ATTR . VALUE) ...) where 510 the form (DN (ATTR . VALUE) (ATTR . VALUE) ...) where
511 DN is the distinguished name of an entry to add, the following 511 DN is the distinguished name of an entry to add, the following
512 are cons cells containing attribute/value string pairs. 512 are cons cells containing attribute/value string pairs.
513 HOST is the LDAP host, defaulting to `ldap-default-host' 513 HOST is the LDAP host, defaulting to `ldap-default-host'.
514 BINDDN is the DN to bind as to the server 514 BINDDN is the DN to bind as to the server.
515 PASSWD is the corresponding password" 515 PASSWD is the corresponding password."
516 (or host 516 (or host
517 (setq host ldap-default-host) 517 (setq host ldap-default-host)
518 (error "No LDAP host specified")) 518 (error "No LDAP host specified"))
519 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) 519 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist)))
520 ldap 520 ldap
540 (ldap-close ldap))) 540 (ldap-close ldap)))
541 541
542 542
543 (defun ldap-modify-entries (entry-mods &optional host binddn passwd) 543 (defun ldap-modify-entries (entry-mods &optional host binddn passwd)
544 "Modify entries of an LDAP directory. 544 "Modify entries of an LDAP directory.
545 ENTRY_MODS is a list of entry modifications of the form 545 ENTRY_MODS is a list of entry modifications of the form
546 (DN MOD-SPEC1 MOD-SPEC2 ...) where DN is the distinguished name of 546 (DN MOD-SPEC1 MOD-SPEC2 ...) where DN is the distinguished name of
547 the entry to modify, the following are modification specifications. 547 the entry to modify, the following are modification specifications.
548 A modification specification is itself a list of the form 548 A modification specification is itself a list of the form
549 (MOD-OP ATTR VALUE1 VALUE2 ...) MOD-OP and ATTR are mandatory, 549 (MOD-OP ATTR VALUE1 VALUE2 ...) MOD-OP and ATTR are mandatory,
550 VALUEs are optional depending on MOD-OP. 550 VALUEs are optional depending on MOD-OP.
551 MOD-OP is the type of modification, one of the symbols `add', `delete' 551 MOD-OP is the type of modification, one of the symbols `add', `delete'
552 or `replace'. ATTR is the LDAP attribute type to modify. 552 or `replace'. ATTR is the LDAP attribute type to modify.
553 HOST is the LDAP host, defaulting to `ldap-default-host' 553 HOST is the LDAP host, defaulting to `ldap-default-host'.
554 BINDDN is the DN to bind as to the server 554 BINDDN is the DN to bind as to the server.
555 PASSWD is the corresponding password" 555 PASSWD is the corresponding password."
556 (or host 556 (or host
557 (setq host ldap-default-host) 557 (setq host ldap-default-host)
558 (error "No LDAP host specified")) 558 (error "No LDAP host specified"))
559 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) 559 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist)))
560 ldap 560 ldap
580 (ldap-close ldap))) 580 (ldap-close ldap)))
581 581
582 582
583 (defun ldap-delete-entries (dn &optional host binddn passwd) 583 (defun ldap-delete-entries (dn &optional host binddn passwd)
584 "Delete an entry from an LDAP directory. 584 "Delete an entry from an LDAP directory.
585 DN is the distinguished name of an entry to delete or 585 DN is the distinguished name of an entry to delete or
586 a list of those. 586 a list of those.
587 HOST is the LDAP host, defaulting to `ldap-default-host' 587 HOST is the LDAP host, defaulting to `ldap-default-host'.
588 BINDDN is the DN to bind as to the server 588 BINDDN is the DN to bind as to the server.
589 PASSWD is the corresponding password." 589 PASSWD is the corresponding password."
590 (or host 590 (or host
591 (setq host ldap-default-host) 591 (setq host ldap-default-host)
592 (error "No LDAP host specified")) 592 (error "No LDAP host specified"))
593 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) 593 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist)))
617 (ldap-delete ldap dn)) 617 (ldap-delete ldap dn))
618 (ldap-close ldap))) 618 (ldap-close ldap)))
619 619
620 620
621 (provide 'ldap) 621 (provide 'ldap)
622 622
623 ;;; ldap.el ends here 623 ;;; ldap.el ends here