Mercurial > emacs
annotate lisp/net/ldap.el @ 42621:33aa22b1c9c0
Remove Preface from the `Invariant Section' listing of the License,
since it specifies `how the book is arranged'.
author | Robert J. Chassell <bob@rattlesnake.com> |
---|---|
date | Tue, 08 Jan 2002 23:41:37 +0000 |
parents | 033986c328d5 |
children | c1bb3d3c9621 |
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 |
42551
19b398fd9146
(ldap-search-internal): Make the buffer unibyte.
Pavel Janík <Pavel@Janik.cz>
parents:
42517
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. |
27313 | 4 |
42607
033986c328d5
New maintainer. New e-mail address of the author.
Pavel Janík <Pavel@Janik.cz>
parents:
42579
diff
changeset
|
5 ;; Author: Oscar Figueiredo <oscar@cpe.fr> |
033986c328d5
New maintainer. New e-mail address of the author.
Pavel Janík <Pavel@Janik.cz>
parents:
42579
diff
changeset
|
6 ;; Maintainer: Pavel Janík <Pavel@Janik.cz> |
27313 | 7 ;; Created: April 1998 |
8 ;; Keywords: comm | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; 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 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; 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
|
30 ;; 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
|
31 ;; `ldapsearch' to actually perform the searches. That program can be |
27313 | 32 ;; found in all LDAP developer kits such as: |
33 ;; - UM-LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/) | |
34 ;; - OpenLDAP (http://www.openldap.org/) | |
35 | |
36 ;;; Code: | |
37 | |
38 (require 'custom) | |
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 | |
155 (defcustom ldap-ldapsearch-args '("-B") | |
156 "*A list of additional arguments to pass to `ldapsearch'. | |
157 It is recommended to use the `-T' switch with Netscape's | |
158 implementation to avoid line wrapping. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
159 The `-B' switch should be used to enable the retrieval of |
27313 | 160 binary values." |
161 :type '(repeat :tag "`ldapsearch' Arguments" | |
162 (string :tag "Argument")) | |
163 :group 'ldap) | |
164 | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
165 (defcustom ldap-ignore-attribute-codings nil |
27313 | 166 "*If non-nil, do not encode/decode LDAP attribute values." |
167 :type 'boolean | |
168 :group 'ldap) | |
169 | |
170 (defcustom ldap-default-attribute-decoder nil | |
171 "*Decoder function to use for attributes whose syntax is unknown." | |
172 :type 'symbol | |
173 :group 'ldap) | |
174 | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
175 (defcustom ldap-coding-system 'utf-8 |
27313 | 176 "*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
|
177 LDAP v3 specifies the coding system of strings to be UTF-8." |
27313 | 178 :type 'symbol |
179 :group 'ldap) | |
180 | |
181 (defvar ldap-attribute-syntax-encoders | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
182 [nil ; 1 ACI Item N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
183 nil ; 2 Access Point Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
184 nil ; 3 Attribute Type Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
185 nil ; 4 Audio N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
186 nil ; 5 Binary N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
187 nil ; 6 Bit String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
188 ldap-encode-boolean ; 7 Boolean Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
189 nil ; 8 Certificate N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
190 nil ; 9 Certificate List N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
191 nil ; 10 Certificate Pair N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
192 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
|
193 ldap-encode-string ; 12 DN Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
194 nil ; 13 Data Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
195 nil ; 14 Delivery Method Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 nil ; 18 DL Submit Permission Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
200 nil ; 19 DSA Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
201 nil ; 20 DSE Type Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
202 nil ; 21 Enhanced Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
203 nil ; 22 Facsimile Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
204 nil ; 23 Fax N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
205 nil ; 24 Generalized Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
206 nil ; 25 Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
207 nil ; 26 IA5 String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
208 number-to-string ; 27 INTEGER Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
209 nil ; 28 JPEG N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
210 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
|
211 nil ; 30 Matching Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
212 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
|
213 nil ; 32 Mail Preference Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
214 nil ; 33 MHS OR Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
215 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
|
216 nil ; 35 Name Form Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
217 nil ; 36 Numeric String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
218 nil ; 37 Object Class Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
219 nil ; 38 OID Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
220 nil ; 39 Other Mailbox Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
221 nil ; 40 Octet String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
222 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
|
223 nil ; 42 Protocol Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
224 nil ; 43 Presentation Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
225 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
|
226 nil ; 45 Subtree Specification Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
227 nil ; 46 Supplier Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
228 nil ; 47 Supplier Or Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
229 nil ; 48 Supplier And Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
230 nil ; 49 Supported Algorithm N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
231 nil ; 50 Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
232 nil ; 51 Teletex Terminal Identifier Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
233 nil ; 52 Telex Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
234 nil ; 53 UTC Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
235 nil ; 54 LDAP Syntax Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
236 nil ; 55 Modify Rights Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
237 nil ; 56 LDAP Schema Definition Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
238 nil ; 57 LDAP Schema Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
239 nil ; 58 Substring Assertion Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
240 ] |
27313 | 241 "A vector of functions used to encode LDAP attribute values. |
242 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
|
243 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in |
27313 | 244 RFC2252 section 4.3.2") |
245 | |
246 (defvar ldap-attribute-syntax-decoders | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
247 [nil ; 1 ACI Item N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
248 nil ; 2 Access Point Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
249 nil ; 3 Attribute Type Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
250 nil ; 4 Audio N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
251 nil ; 5 Binary N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
252 nil ; 6 Bit String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
253 ldap-decode-boolean ; 7 Boolean Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
254 nil ; 8 Certificate N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
255 nil ; 9 Certificate List N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
256 nil ; 10 Certificate Pair N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
257 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
|
258 ldap-decode-string ; 12 DN Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
259 nil ; 13 Data Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
260 nil ; 14 Delivery Method Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 nil ; 18 DL Submit Permission Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
265 nil ; 19 DSA Quality Syntax Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
266 nil ; 20 DSE Type Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
267 nil ; 21 Enhanced Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
268 nil ; 22 Facsimile Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
269 nil ; 23 Fax N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
270 nil ; 24 Generalized Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
271 nil ; 25 Guide Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
272 nil ; 26 IA5 String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
273 string-to-number ; 27 INTEGER Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
274 nil ; 28 JPEG N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
275 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
|
276 nil ; 30 Matching Rule Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
277 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
|
278 nil ; 32 Mail Preference Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
279 nil ; 33 MHS OR Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
280 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
|
281 nil ; 35 Name Form Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
282 nil ; 36 Numeric String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
283 nil ; 37 Object Class Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
284 nil ; 38 OID Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
285 nil ; 39 Other Mailbox Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
286 nil ; 40 Octet String Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
287 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
|
288 nil ; 42 Protocol Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
289 nil ; 43 Presentation Address Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
290 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
|
291 nil ; 45 Subtree Specification Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
292 nil ; 46 Supplier Information Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
293 nil ; 47 Supplier Or Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
294 nil ; 48 Supplier And Consumer Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
295 nil ; 49 Supported Algorithm N |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
296 nil ; 50 Telephone Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
297 nil ; 51 Teletex Terminal Identifier Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
298 nil ; 52 Telex Number Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
299 nil ; 53 UTC Time Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
300 nil ; 54 LDAP Syntax Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
301 nil ; 55 Modify Rights Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
302 nil ; 56 LDAP Schema Definition Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
303 nil ; 57 LDAP Schema Description Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
304 nil ; 58 Substring Assertion Y |
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
305 ] |
27313 | 306 "A vector of functions used to decode LDAP attribute values. |
307 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
|
308 object identifiers of the form 1.3.6.1.4.1.1466.1115.121.1.* as defined in |
27313 | 309 RFC2252 section 4.3.2") |
310 | |
311 | |
312 (defvar ldap-attribute-syntaxes-alist | |
313 '((createtimestamp . 24) | |
314 (modifytimestamp . 24) | |
315 (creatorsname . 12) | |
316 (modifiersname . 12) | |
317 (subschemasubentry . 12) | |
318 (attributetypes . 3) | |
319 (objectclasses . 37) | |
320 (matchingrules . 30) | |
321 (matchingruleuse . 31) | |
322 (namingcontexts . 12) | |
323 (altserver . 26) | |
324 (supportedextension . 38) | |
325 (supportedcontrol . 38) | |
326 (supportedsaslmechanisms . 15) | |
327 (supportedldapversion . 27) | |
328 (ldapsyntaxes . 16) | |
329 (ditstructurerules . 17) | |
330 (nameforms . 35) | |
331 (ditcontentrules . 16) | |
332 (objectclass . 38) | |
333 (aliasedobjectname . 12) | |
334 (cn . 15) | |
335 (sn . 15) | |
336 (serialnumber . 44) | |
337 (c . 15) | |
338 (l . 15) | |
339 (st . 15) | |
340 (street . 15) | |
341 (o . 15) | |
342 (ou . 15) | |
343 (title . 15) | |
344 (description . 15) | |
345 (searchguide . 25) | |
346 (businesscategory . 15) | |
347 (postaladdress . 41) | |
348 (postalcode . 15) | |
349 (postofficebox . 15) | |
350 (physicaldeliveryofficename . 15) | |
351 (telephonenumber . 50) | |
352 (telexnumber . 52) | |
353 (telexterminalidentifier . 51) | |
354 (facsimiletelephonenumber . 22) | |
355 (x121address . 36) | |
356 (internationalisdnnumber . 36) | |
357 (registeredaddress . 41) | |
358 (destinationindicator . 44) | |
359 (preferreddeliverymethod . 14) | |
360 (presentationaddress . 43) | |
361 (supportedapplicationcontext . 38) | |
362 (member . 12) | |
363 (owner . 12) | |
364 (roleoccupant . 12) | |
365 (seealso . 12) | |
366 (userpassword . 40) | |
367 (usercertificate . 8) | |
368 (cacertificate . 8) | |
369 (authorityrevocationlist . 9) | |
370 (certificaterevocationlist . 9) | |
371 (crosscertificatepair . 10) | |
372 (name . 15) | |
373 (givenname . 15) | |
374 (initials . 15) | |
375 (generationqualifier . 15) | |
376 (x500uniqueidentifier . 6) | |
377 (dnqualifier . 44) | |
378 (enhancedsearchguide . 21) | |
379 (protocolinformation . 42) | |
380 (distinguishedname . 12) | |
381 (uniquemember . 34) | |
382 (houseidentifier . 15) | |
383 (supportedalgorithms . 49) | |
384 (deltarevocationlist . 9) | |
385 (dmdname . 15)) | |
386 "A map of LDAP attribute names to their type object id minor number. | |
387 This table is built from RFC2252 Section 5 and RFC2256 Section 5") | |
388 | |
389 | |
390 ;; Coding/decoding functions | |
391 | |
392 (defun ldap-encode-boolean (bool) | |
393 (if bool | |
394 "TRUE" | |
395 "FALSE")) | |
396 | |
397 (defun ldap-decode-boolean (str) | |
398 (cond | |
399 ((string-equal str "TRUE") | |
400 t) | |
401 ((string-equal str "FALSE") | |
402 nil) | |
403 (t | |
404 (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
|
405 |
27313 | 406 (defun ldap-encode-country-string (str) |
407 ;; We should do something useful here... | |
408 (if (not (= 2 (length str))) | |
409 (error "Invalid country string: %s" str))) | |
410 | |
411 (defun ldap-decode-string (str) | |
412 (decode-coding-string str ldap-coding-system)) | |
413 | |
414 (defun ldap-encode-string (str) | |
415 (encode-coding-string str ldap-coding-system)) | |
416 | |
417 (defun ldap-decode-address (str) | |
418 (mapconcat 'ldap-decode-string | |
419 (split-string str "\\$") | |
420 "\n")) | |
421 | |
422 (defun ldap-encode-address (str) | |
423 (mapconcat 'ldap-encode-string | |
424 (split-string str "\n") | |
425 "$")) | |
426 | |
427 | |
428 ;; LDAP protocol functions | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
429 |
27313 | 430 (defun ldap-get-host-parameter (host parameter) |
431 "Get the value of PARAMETER for HOST in `ldap-host-parameters-alist'." | |
432 (plist-get (cdr (assoc host ldap-host-parameters-alist)) | |
433 parameter)) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
434 |
27313 | 435 (defun ldap-decode-attribute (attr) |
436 "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
|
437 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
|
438 and the corresponding decoder is then retrieved from |
27313 | 439 `ldap-attribute-syntax-decoders' and applied on the value(s)." |
440 (let* ((name (car attr)) | |
441 (values (cdr attr)) | |
442 (syntax-id (cdr (assq (intern (downcase name)) | |
443 ldap-attribute-syntaxes-alist))) | |
444 decoder) | |
445 (if syntax-id | |
446 (setq decoder (aref ldap-attribute-syntax-decoders | |
447 (1- syntax-id))) | |
448 (setq decoder ldap-default-attribute-decoder)) | |
449 (if decoder | |
450 (cons name (mapcar decoder values)) | |
451 attr))) | |
452 | |
453 (defun ldap-search (filter &optional host attributes attrsonly withdn) | |
454 "Perform an LDAP search. | |
455 FILTER is the search filter in RFC1558 syntax. | |
456 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
|
457 ATTRIBUTES are the specific attributes to retrieve, nil means |
27313 | 458 retrieve all. |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
459 ATTRSONLY, if non-nil, retrieves the attributes only, without |
27313 | 460 the associated values. |
461 If WITHDN is non-nil, each entry in the result will be prepended with | |
462 its distinguished name WITHDN. | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
463 Additional search parameters can be specified through |
27313 | 464 `ldap-host-parameters-alist', which see." |
465 (interactive "sFilter:") | |
466 (or host | |
467 (setq host ldap-default-host) | |
468 (error "No LDAP host specified")) | |
469 (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) | |
470 result) | |
471 (setq result (ldap-search-internal (append host-plist | |
472 (list 'host host | |
473 'filter filter | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
474 'attributes attributes |
27313 | 475 'attrsonly attrsonly |
476 'withdn withdn)))) | |
477 (if ldap-ignore-attribute-codings | |
478 result | |
479 (mapcar (function | |
480 (lambda (record) | |
481 (mapcar 'ldap-decode-attribute record))) | |
482 result)))) | |
483 | |
484 | |
485 (defun ldap-search-internal (search-plist) | |
486 "Perform a search on a LDAP server. | |
487 SEARCH-PLIST is a property list describing the search request. | |
488 Valid keys in that list are: | |
489 `host' is a string naming one or more (blank-separated) LDAP servers to | |
490 to try to connect to. Each host name may optionally be of the form HOST:PORT. | |
491 `filter' is a filter string for the search as described in RFC 1558. | |
492 `attributes' is a list of strings indicating which attributes to retrieve | |
493 for each matching entry. If nil, return all available attributes. | |
494 `attrsonly', if non-nil, indicates that only attributes are retrieved, | |
495 not their associated values. | |
496 `base' is the base for the search as described in RFC 1779. | |
497 `scope' is one of the three symbols `sub', `base' or `one'. | |
498 `binddn' is the distinguished name of the user to bind as (in RFC 1779 syntax). | |
499 `passwd' is the password to use for simple authentication. | |
500 `deref' is one of the symbols `never', `always', `search' or `find'. | |
501 `timelimit' is the timeout limit for the connection in seconds. | |
502 `sizelimit' is the maximum number of matches to return. | |
503 `withdn' if non-nil each entry in the result will be prepended with | |
504 its distinguished name DN. | |
505 The function returns a list of matching entries. Each entry is itself | |
506 an alist of attribute/value pairs." | |
507 (let ((buf (get-buffer-create " *ldap-search*")) | |
508 (bufval (get-buffer-create " *ldap-value*")) | |
509 (host (or (plist-get search-plist 'host) | |
510 ldap-default-host)) | |
511 (filter (plist-get search-plist 'filter)) | |
512 (attributes (plist-get search-plist 'attributes)) | |
513 (attrsonly (plist-get search-plist 'attrsonly)) | |
514 (base (or (plist-get search-plist 'base) | |
515 ldap-default-base)) | |
516 (scope (plist-get search-plist 'scope)) | |
517 (binddn (plist-get search-plist 'binddn)) | |
518 (passwd (plist-get search-plist 'passwd)) | |
519 (deref (plist-get search-plist 'deref)) | |
520 (timelimit (plist-get search-plist 'timelimit)) | |
521 (sizelimit (plist-get search-plist 'sizelimit)) | |
522 (withdn (plist-get search-plist 'withdn)) | |
523 (numres 0) | |
524 arglist dn name value record result) | |
525 (if (or (null filter) | |
526 (equal "" filter)) | |
527 (error "No search filter")) | |
528 (setq filter (cons filter attributes)) | |
529 (save-excursion | |
530 (set-buffer buf) | |
531 (erase-buffer) | |
532 (if (and host | |
533 (not (equal "" host))) | |
534 (setq arglist (nconc arglist (list (format "-h%s" host))))) | |
535 (if (and attrsonly | |
536 (not (equal "" attrsonly))) | |
537 (setq arglist (nconc arglist (list "-A")))) | |
538 (if (and base | |
539 (not (equal "" base))) | |
540 (setq arglist (nconc arglist (list (format "-b%s" base))))) | |
541 (if (and scope | |
542 (not (equal "" scope))) | |
543 (setq arglist (nconc arglist (list (format "-s%s" scope))))) | |
544 (if (and binddn | |
545 (not (equal "" binddn))) | |
546 (setq arglist (nconc arglist (list (format "-D%s" binddn))))) | |
547 (if (and passwd | |
548 (not (equal "" passwd))) | |
549 (setq arglist (nconc arglist (list (format "-w%s" passwd))))) | |
550 (if (and deref | |
551 (not (equal "" deref))) | |
552 (setq arglist (nconc arglist (list (format "-a%s" deref))))) | |
553 (if (and timelimit | |
554 (not (equal "" timelimit))) | |
555 (setq arglist (nconc arglist (list (format "-l%s" timelimit))))) | |
556 (if (and sizelimit | |
557 (not (equal "" sizelimit))) | |
558 (setq arglist (nconc arglist (list (format "-z%s" sizelimit))))) | |
559 (eval `(call-process ldap-ldapsearch-prog | |
560 nil | |
561 buf | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
562 nil |
27313 | 563 ,@arglist |
564 "-t" ; Write values to temp files | |
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 |
27313 | 570 (if (looking-at "usage") |
571 (error "Incorrect ldapsearch invocation") | |
572 (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
|
573 ;; 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
|
574 (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
|
575 (forward-line 1)) |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
576 (while (progn |
27313 | 577 (skip-chars-forward " \t\n") |
578 (not (eobp))) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
579 (setq dn (buffer-substring (point) (save-excursion |
27313 | 580 (end-of-line) |
581 (point)))) | |
582 (forward-line 1) | |
42368
fc1e8b9795d0
(ldap-search-internal): Handle <file://...> in results.
Richard M. Stallman <rms@gnu.org>
parents:
38422
diff
changeset
|
583 (while (looking-at "^\\(\\w*\\)[=:\t ]+\\(<[\t ]*file://\\)?\\(.*\\)$") |
27313 | 584 (setq name (match-string 1) |
42368
fc1e8b9795d0
(ldap-search-internal): Handle <file://...> in results.
Richard M. Stallman <rms@gnu.org>
parents:
38422
diff
changeset
|
585 value (match-string 3)) |
42579
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
586 ;; 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
|
587 (if (equal value "") |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
588 (setq value " ") |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
589 (save-excursion |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
590 (set-buffer bufval) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
591 (erase-buffer) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
592 (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
|
593 (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
|
594 (delete-file value) |
c914fba3811b
(ldap-search-internal): Skip error message from ldapsearch. Allow listing
Pavel Janík <Pavel@Janik.cz>
parents:
42573
diff
changeset
|
595 (setq value (buffer-string)))) |
27313 | 596 (setq record (cons (list name value) |
597 record)) | |
598 (forward-line 1)) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
599 (setq result (cons (if withdn |
27313 | 600 (cons dn (nreverse record)) |
601 (nreverse record)) result)) | |
602 (setq record nil) | |
42517
400e6bda5a0d
(ldap-host-parameters-alist): Remove duplicated entry.
Pavel Janík <Pavel@Janik.cz>
parents:
42368
diff
changeset
|
603 (skip-chars-forward " \t\n") |
27313 | 604 (message "Parsing results... %d" numres) |
605 (1+ numres)) | |
606 (message "Parsing results... done") | |
607 (nreverse result))))) | |
608 | |
609 (provide 'ldap) | |
610 | |
611 ;;; ldap.el ends here |