259
|
1 /* LDAP client interface for XEmacs.
|
265
|
2 Copyright (C) 1998 Free Software Foundation, Inc.
|
259
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Not in FSF. */
|
|
22
|
|
23 /* Author: Oscar Figueiredo */
|
|
24
|
|
25 /* This file provides lisp primitives for access to an LDAP library
|
|
26 conforming to the API defined in RFC 1823.
|
|
27 It has been tested with:
|
|
28 - UMich LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/)
|
|
29 - Netscape's LDAP SDK 1.0 (http://developer.netscape.com) */
|
|
30
|
|
31
|
|
32 #include <config.h>
|
|
33 #include "lisp.h"
|
278
|
34 #include "opaque.h"
|
259
|
35
|
265
|
36 #include <errno.h>
|
259
|
37 #include <lber.h>
|
|
38 #include <ldap.h>
|
|
39
|
276
|
40 #include "eldap.h"
|
|
41
|
259
|
42 #ifdef HAVE_NS_LDAP
|
|
43 #define HAVE_LDAP_SET_OPTION 1
|
|
44 #define HAVE_LDAP_GET_ERRNO 1
|
|
45 #else
|
|
46 #undef HAVE_LDAP_SET_OPTION
|
|
47 #undef HAVE_LDAP_GET_ERRNO
|
|
48 #endif
|
|
49
|
276
|
50
|
259
|
51
|
276
|
52 static int ldap_default_port;
|
|
53 static Lisp_Object Vldap_default_base;
|
|
54
|
|
55 /* ldap-open plist keywords */
|
|
56 static Lisp_Object Qport, Qauth, Qbinddn, Qpasswd, Qderef, Qtimelimit,
|
|
57 Qsizelimit;
|
259
|
58 /* Search scope limits */
|
|
59 static Lisp_Object Qbase, Qonelevel, Qsubtree;
|
|
60 /* Authentication methods */
|
|
61 #ifdef LDAP_AUTH_KRBV41
|
|
62 static Lisp_Object Qkrbv41;
|
|
63 #endif
|
|
64 #ifdef LDAP_AUTH_KRBV42
|
|
65 static Lisp_Object Qkrbv42;
|
|
66 #endif
|
|
67 /* Deref policy */
|
261
|
68 static Lisp_Object Qnever, Qalways, Qfind;
|
259
|
69
|
276
|
70 static Lisp_Object Qldapp;
|
|
71
|
|
72
|
|
73 /************************************************************************/
|
|
74 /* Utility Functions */
|
|
75 /************************************************************************/
|
|
76
|
|
77 static void
|
|
78 signal_ldap_error (LDAP *ld)
|
|
79 {
|
|
80 #if HAVE_LDAP_GET_ERRNO
|
|
81 signal_simple_error
|
|
82 ("LDAP error",
|
|
83 build_string (ldap_err2string (ldap_get_lderrno (ld, NULL, NULL))));
|
|
84 #else
|
|
85 signal_simple_error ("LDAP error",
|
|
86 build_string (ldap_err2string (ld->ld_errno)));
|
|
87 #endif
|
|
88 }
|
|
89
|
|
90
|
|
91 /************************************************************************/
|
|
92 /* The ldap Lisp object */
|
|
93 /************************************************************************/
|
|
94
|
|
95 /*
|
|
96 * Structure records pertinent information about an open LDAP connection.
|
|
97 */
|
|
98
|
|
99 struct Lisp_LDAP
|
|
100 {
|
|
101 /* lcrecord header */
|
|
102 struct lcrecord_header header;
|
|
103 /* The LDAP connection handle used by the LDAP API */
|
|
104 LDAP *ld;
|
|
105 /* Name of the host we connected to */
|
|
106 Lisp_Object host;
|
|
107 /* Status of the LDAP connection.
|
|
108 This is a symbol: open or closed */
|
|
109 Lisp_Object status_symbol;
|
|
110 };
|
|
111
|
|
112
|
|
113
|
|
114 static Lisp_Object
|
|
115 mark_ldap (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
116 {
|
|
117 struct Lisp_LDAP *ldap = XLDAP (obj);
|
|
118 ((markobj) (ldap->host));
|
|
119 return ldap->status_symbol;
|
|
120 }
|
|
121
|
|
122 static void
|
|
123 print_ldap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
124 {
|
|
125 char buf[16];
|
|
126
|
|
127 struct Lisp_LDAP *ldap = XLDAP (obj);
|
|
128
|
|
129 if (print_readably)
|
|
130 error ("printing unreadable object #<ldap %s>",
|
|
131 XSTRING_DATA (ldap->host));
|
|
132
|
278
|
133 write_c_string ("#<ldap ", printcharfun);
|
|
134 print_internal (ldap->host, printcharfun, 1);
|
|
135 write_c_string (" state:",printcharfun);
|
|
136 print_internal (ldap->status_symbol, printcharfun, 1);
|
|
137 sprintf (buf, " 0x%x>", ldap);
|
|
138 write_c_string (buf, printcharfun);
|
276
|
139 }
|
|
140
|
|
141 static struct Lisp_LDAP *
|
|
142 allocate_ldap (void)
|
|
143 {
|
|
144 struct Lisp_LDAP *ldap =
|
|
145 alloc_lcrecord_type (struct Lisp_LDAP, lrecord_ldap);
|
|
146
|
|
147 ldap->ld = (LDAP *) NULL;
|
|
148 ldap->host = Qnil;
|
|
149 ldap->status_symbol = Qnil;
|
|
150 return ldap;
|
|
151 }
|
|
152
|
|
153 DEFINE_LRECORD_IMPLEMENTATION ("ldap", ldap,
|
|
154 mark_ldap, print_ldap, NULL,
|
|
155 NULL, NULL, struct Lisp_LDAP);
|
|
156
|
|
157
|
|
158
|
|
159
|
|
160 /************************************************************************/
|
|
161 /* Basic ldap accessors */
|
|
162 /************************************************************************/
|
|
163
|
|
164 DEFUN ("ldapp", Fldapp, 1, 1, 0, /*
|
|
165 Return t if OBJECT is a LDAP connection.
|
|
166 */
|
|
167 (object))
|
|
168 {
|
|
169 return LDAPP (object) ? Qt : Qnil;
|
|
170 }
|
|
171
|
|
172
|
|
173 DEFUN ("ldap-host", Fldap_host, 1, 1, 0, /*
|
|
174 Return the server host of the connection LDAP, as a string.
|
|
175 */
|
|
176 (ldap))
|
|
177 {
|
|
178 CHECK_LDAP (ldap);
|
|
179 return (XLDAP (ldap))->host;
|
|
180 }
|
|
181
|
|
182
|
|
183
|
|
184 DEFUN ("ldap-status", Fldap_status, 1, 1, 0, /*
|
|
185 Return the status of the connection LDAP.
|
|
186 This is a symbol, one of these:
|
|
187
|
|
188 open -- for a LDAP connection that is open.
|
|
189 closed -- for a LDAP connection that is closed.
|
|
190 */
|
|
191 (ldap))
|
|
192 {
|
|
193 CHECK_LDAP (ldap);
|
|
194 return (XLDAP (ldap))->status_symbol;
|
|
195 }
|
|
196
|
|
197
|
|
198
|
|
199 /************************************************************************/
|
|
200 /* Opening/Closing a LDAP connection */
|
|
201 /************************************************************************/
|
|
202
|
|
203
|
|
204 DEFUN ("ldap-open", Fldap_open, 1, 2, 0, /*
|
|
205 Open a LDAP connection to HOST.
|
|
206 PLIST is a plist containing additional parameters for the connection.
|
259
|
207 Valid keys in that list are:
|
276
|
208 `port' the TCP port to use for the connection if different from
|
|
209 `ldap-default-port'.
|
259
|
210 `auth' is the authentication method to use, possible values depend on
|
|
211 the LDAP library XEmacs was compiled with: `simple', `krbv41' and `krbv42'.
|
|
212 `binddn' is the distinguished name of the user to bind as (in RFC 1779 syntax).
|
|
213 `passwd' is the password to use for simple authentication.
|
|
214 `deref' is one of the symbols `never', `always', `search' or `find'.
|
|
215 `timelimit' is the timeout limit for the connection in seconds.
|
|
216 `sizelimit' is the maximum number of matches to return.
|
|
217 */
|
276
|
218 (host, plist))
|
259
|
219 {
|
276
|
220 /* This function can call lisp */
|
259
|
221
|
276
|
222 struct Lisp_LDAP *lisp_ldap;
|
259
|
223 LDAP *ld;
|
278
|
224 int ldap_port = 0;
|
259
|
225 int ldap_auth = LDAP_AUTH_SIMPLE;
|
|
226 char *ldap_binddn = NULL;
|
|
227 char *ldap_passwd = NULL;
|
|
228 int ldap_deref = LDAP_DEREF_NEVER;
|
|
229 int ldap_timelimit = 0;
|
|
230 int ldap_sizelimit = 0;
|
278
|
231 int err;
|
259
|
232
|
276
|
233 Lisp_Object ldap, list, keyword, value;
|
|
234 struct gcpro gcpro1;
|
259
|
235
|
276
|
236 ldap = Qnil;
|
|
237 GCPRO1 (ldap);
|
259
|
238
|
276
|
239 CHECK_STRING (host);
|
|
240
|
|
241 EXTERNAL_PROPERTY_LIST_LOOP(list, keyword, value, plist)
|
|
242 {
|
|
243 /* TCP Port */
|
|
244 if (EQ (keyword, Qport))
|
259
|
245 {
|
276
|
246 CHECK_INT (value);
|
|
247 ldap_port = XINT (value);
|
259
|
248 }
|
|
249 /* Authentication method */
|
276
|
250 if (EQ (keyword, Qauth))
|
259
|
251 {
|
|
252 CHECK_SYMBOL (value);
|
|
253
|
|
254 if (EQ (value, Qsimple))
|
|
255 ldap_auth = LDAP_AUTH_SIMPLE;
|
|
256 #ifdef LDAP_AUTH_KRBV41
|
|
257 else if (EQ (value, Qkrbv41))
|
|
258 ldap_auth = LDAP_AUTH_KRBV41;
|
|
259 #endif
|
|
260 #ifdef LDAP_AUTH_KRBV42
|
|
261 else if (EQ (value, Qkrbv42))
|
|
262 ldap_auth = LDAP_AUTH_KRBV42;
|
|
263 #endif
|
|
264 else
|
|
265 signal_simple_error ("Invalid authentication method", value);
|
|
266 }
|
|
267 /* Bind DN */
|
|
268 else if (EQ (keyword, Qbinddn))
|
|
269 {
|
276
|
270 CHECK_STRING (value);
|
|
271 ldap_binddn = alloca (XSTRING_LENGTH (value) + 1);
|
|
272 strcpy (ldap_binddn, (char *)XSTRING_DATA (value));
|
259
|
273 }
|
|
274 /* Password */
|
|
275 else if (EQ (keyword, Qpasswd))
|
|
276 {
|
276
|
277 CHECK_STRING (value);
|
|
278 ldap_passwd = alloca (XSTRING_LENGTH (value) + 1);
|
|
279 strcpy (ldap_passwd, (char *)XSTRING_DATA (value));
|
259
|
280 }
|
|
281 /* Deref */
|
|
282 else if (EQ (keyword, Qderef))
|
|
283 {
|
|
284 CHECK_SYMBOL (value);
|
|
285 if (EQ (value, Qnever))
|
|
286 ldap_deref = LDAP_DEREF_NEVER;
|
|
287 else if (EQ (value, Qsearch))
|
|
288 ldap_deref = LDAP_DEREF_SEARCHING;
|
|
289 else if (EQ (value, Qfind))
|
|
290 ldap_deref = LDAP_DEREF_FINDING;
|
|
291 else if (EQ (value, Qalways))
|
|
292 ldap_deref = LDAP_DEREF_ALWAYS;
|
|
293 else
|
|
294 signal_simple_error ("Invalid deref value", value);
|
|
295 }
|
|
296 /* Timelimit */
|
|
297 else if (EQ (keyword, Qtimelimit))
|
|
298 {
|
276
|
299 CHECK_INT (value);
|
|
300 ldap_timelimit = XINT (value);
|
259
|
301 }
|
|
302 /* Sizelimit */
|
|
303 else if (EQ (keyword, Qsizelimit))
|
|
304 {
|
276
|
305 CHECK_INT (value);
|
|
306 ldap_sizelimit = XINT (value);
|
259
|
307 }
|
|
308 }
|
|
309
|
276
|
310 if (ldap_port == 0)
|
259
|
311 {
|
276
|
312 ldap_port = ldap_default_port;
|
259
|
313 }
|
|
314
|
276
|
315 /* Connect to the server and bind */
|
|
316 ld = ldap_open ((char *)XSTRING_DATA (host), ldap_port);
|
|
317 if (ld == NULL )
|
|
318 signal_simple_error_2 ("Failed connecting to host",
|
|
319 host,
|
|
320 lisp_strerror (errno));
|
259
|
321
|
|
322
|
|
323 #if HAVE_LDAP_SET_OPTION
|
|
324 if (ldap_set_option (ld, LDAP_OPT_DEREF, (void *)&ldap_deref) != LDAP_SUCCESS)
|
276
|
325 signal_ldap_error (ld);
|
|
326 if (ldap_set_option (ld, LDAP_OPT_TIMELIMIT,
|
|
327 (void *)&ldap_timelimit) != LDAP_SUCCESS)
|
|
328 signal_ldap_error (ld);
|
|
329 if (ldap_set_option (ld, LDAP_OPT_SIZELIMIT,
|
|
330 (void *)&ldap_sizelimit) != LDAP_SUCCESS)
|
|
331 signal_ldap_error (ld);
|
259
|
332 if (ldap_set_option (ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON) != LDAP_SUCCESS)
|
276
|
333 signal_ldap_error (ld);
|
259
|
334 #else /* HAVE_LDAP_SET_OPTION */
|
|
335 ld->ld_deref = ldap_deref;
|
|
336 ld->ld_timelimit = ldap_timelimit;
|
|
337 ld->ld_sizelimit = ldap_sizelimit;
|
|
338 #ifdef LDAP_REFERRALS
|
|
339 ld->ld_options = LDAP_OPT_REFERRALS;
|
|
340 #else /* LDAP_REFERRALS */
|
|
341 ld->ld_options = 0;
|
|
342 #endif /* LDAP_REFERRALS */
|
|
343 #endif /* HAVE_LDAP_SET_OPTION */
|
|
344
|
276
|
345 /* ldap_bind_s calls select and may be wedged by spurious signals */
|
|
346 slow_down_interrupts ();
|
|
347 err = ldap_bind_s (ld, ldap_binddn, ldap_passwd, ldap_auth);
|
|
348 speed_up_interrupts ();
|
|
349 if (err != LDAP_SUCCESS)
|
259
|
350 signal_simple_error ("Failed binding to the server",
|
|
351 build_string (ldap_err2string (err)));
|
|
352
|
276
|
353 lisp_ldap = allocate_ldap ();
|
|
354 lisp_ldap->ld = ld;
|
|
355 lisp_ldap->host = host;
|
|
356 lisp_ldap->status_symbol = Qopen;
|
|
357 XSETLDAP (ldap,lisp_ldap);
|
|
358
|
|
359 UNGCPRO;
|
|
360 return ldap;
|
|
361 }
|
|
362
|
|
363
|
|
364
|
|
365 DEFUN ("ldap-close", Fldap_close, 1, 1, 0, /*
|
|
366 Close an LDAP connection.
|
|
367 Return t if the connection was actually closed or nil if
|
|
368 it was already closed before the call
|
|
369 */
|
|
370 (ldap))
|
|
371 {
|
|
372 CHECK_LDAP (ldap);
|
|
373 if ( EQ ((XLDAP (ldap))->status_symbol, Qopen) )
|
259
|
374 {
|
276
|
375 ldap_unbind ((XLDAP (ldap))->ld);
|
|
376 (XLDAP (ldap))->status_symbol = Qclosed;
|
|
377 return Qt;
|
|
378 }
|
|
379 return Qnil;
|
|
380 }
|
|
381
|
|
382
|
|
383
|
|
384 /************************************************************************/
|
|
385 /* Working on a LDAP connection */
|
|
386 /************************************************************************/
|
278
|
387 struct ldap_unwind_struct
|
|
388 {
|
|
389 LDAPMessage *res;
|
|
390 char **vals;
|
|
391 };
|
|
392
|
|
393
|
|
394 static Lisp_Object
|
|
395 ldap_search_unwind (Lisp_Object unwind_obj)
|
|
396 {
|
|
397 struct ldap_unwind_struct *unwind =
|
|
398 (struct ldap_unwind_struct *) get_opaque_ptr (unwind_obj);
|
|
399 if (unwind->res != (LDAPMessage *)NULL)
|
|
400 ldap_msgfree (unwind->res);
|
|
401 if (unwind->vals != (char **)NULL)
|
|
402 ldap_value_free (unwind->vals);
|
|
403 }
|
276
|
404
|
|
405 DEFUN ("ldap-search-internal", Fldap_search_internal, 2, 6, 0, /*
|
|
406 Perform a search on an open LDAP connection.
|
|
407 LDAP is an LDAP connection object created with `ldap-open'.
|
|
408 FILTER is a filter string for the search as described in RFC 1558
|
|
409 BASE is the distinguished name at which to start the search
|
|
410 SCOPE is an integer or a symbol indicating the scope of the search
|
|
411 Possible values are `ldap-scope-base', `ldap-scope-onelevel' or
|
|
412 `ldap-scope-subtree'
|
|
413 ATTRS is a list of strings indicating which attributes to retrieve
|
|
414 for each matching entry. If nil return all available attributes.
|
|
415 If ATTRSONLY is non-nil then only the attributes are retrieved, not
|
|
416 the associated values
|
|
417 The function returns a list of matching entries. Each entry is itself
|
|
418 an alist of attribute/values.
|
|
419 */
|
|
420 (ldap, filter, base, scope, attrs, attrsonly))
|
|
421 {
|
|
422 /* This function can call lisp */
|
|
423
|
|
424 /* Vars for query */
|
|
425 LDAP *ld;
|
278
|
426 LDAPMessage *e;
|
276
|
427 BerElement *ptr;
|
|
428 char *a;
|
|
429 int i, rc, err;
|
|
430 int matches;
|
278
|
431 struct ldap_unwind_struct unwind;
|
276
|
432
|
|
433 int ldap_scope = LDAP_SCOPE_SUBTREE;
|
|
434 char **ldap_attributes = NULL;
|
|
435
|
278
|
436 int speccount = specpdl_depth ();
|
|
437
|
276
|
438 Lisp_Object list, entry, result;
|
|
439 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
440
|
|
441 list = entry = result = Qnil;
|
|
442 GCPRO3(list, entry, result);
|
|
443
|
278
|
444 unwind.res = (LDAPMessage *)NULL;
|
|
445 unwind.vals = (char **)NULL;
|
|
446
|
276
|
447 /* Do all the parameter checking */
|
|
448 CHECK_LIVE_LDAP (ldap);
|
|
449 ld = (XLDAP (ldap))->ld;
|
|
450
|
|
451 /* Filter */
|
|
452 CHECK_STRING (filter);
|
|
453
|
|
454 /* Search base */
|
|
455 if (NILP (base))
|
|
456 {
|
|
457 base = Vldap_default_base;
|
|
458 }
|
|
459 if (!NILP (base))
|
|
460 {
|
|
461 CHECK_STRING (Vldap_default_base);
|
|
462 }
|
|
463
|
|
464 /* Search scope */
|
|
465 if (!NILP (scope))
|
|
466 {
|
|
467 CHECK_SYMBOL (scope);
|
|
468 if (EQ (scope, Qbase))
|
|
469 ldap_scope = LDAP_SCOPE_BASE;
|
|
470 else if (EQ (scope, Qonelevel))
|
|
471 ldap_scope = LDAP_SCOPE_ONELEVEL;
|
|
472 else if (EQ (scope, Qsubtree))
|
|
473 ldap_scope = LDAP_SCOPE_SUBTREE;
|
|
474 else
|
|
475 signal_simple_error ("Invalid scope", scope);
|
|
476 }
|
|
477
|
|
478 /* Attributes to search */
|
|
479 if (!NILP (attrs))
|
|
480 {
|
|
481 CHECK_CONS (attrs);
|
278
|
482 ldap_attributes = alloca_array (char *, 1 + XINT (Flength (attrs)));
|
276
|
483
|
278
|
484 i = 0;
|
|
485 EXTERNAL_LIST_LOOP (attrs, attrs)
|
|
486 {
|
|
487 Lisp_Object current = XCAR (attrs);
|
|
488 CHECK_STRING (current);
|
|
489 ldap_attributes[i] =
|
|
490 alloca_array (char, 1 + XSTRING_LENGTH (current));
|
|
491 memcpy (ldap_attributes[i],
|
|
492 XSTRING_DATA (current), XSTRING_LENGTH (current));
|
|
493 ++i;
|
|
494 }
|
276
|
495 ldap_attributes[i] = NULL;
|
|
496 }
|
|
497
|
|
498 /* Attributes only ? */
|
|
499 CHECK_SYMBOL (attrsonly);
|
|
500
|
|
501
|
|
502 /* Perform the search */
|
|
503 if (ldap_search (ld,
|
|
504 NILP (base) ? "" : (char *) XSTRING_DATA (base),
|
|
505 ldap_scope,
|
|
506 NILP (filter) ? "" : (char *) XSTRING_DATA (filter),
|
|
507 ldap_attributes,
|
|
508 NILP (attrsonly) ? 0 : 1)
|
|
509 == -1)
|
|
510 {
|
|
511 signal_ldap_error (ld);
|
259
|
512 }
|
|
513
|
278
|
514 /* Ensure we don't exit without cleaning up */
|
|
515 record_unwind_protect (ldap_search_unwind,
|
|
516 make_opaque_ptr (&unwind));
|
|
517
|
259
|
518 /* Build the results list */
|
|
519 matches = 0;
|
|
520
|
276
|
521 /* ldap_result calls select() and can get wedged by EINTR signals */
|
|
522 slow_down_interrupts ();
|
278
|
523 rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &(unwind.res));
|
276
|
524 speed_up_interrupts ();
|
|
525 while ( rc == LDAP_RES_SEARCH_ENTRY )
|
259
|
526 {
|
278
|
527 QUIT;
|
259
|
528 matches ++;
|
278
|
529 e = ldap_first_entry (ld, unwind.res);
|
259
|
530 message ("Parsing results... %d", matches);
|
|
531 entry = Qnil;
|
|
532 for (a= ldap_first_attribute (ld, e, &ptr);
|
|
533 a != NULL;
|
|
534 a= ldap_next_attribute (ld, e, ptr) )
|
|
535 {
|
|
536 list = Fcons (build_string (a), Qnil);
|
278
|
537 unwind.vals = ldap_get_values (ld, e, a);
|
|
538 if (unwind.vals != NULL)
|
259
|
539 {
|
278
|
540 for (i=0; unwind.vals[i]!=NULL; i++)
|
259
|
541 {
|
278
|
542 list = Fcons (build_string (unwind.vals[i]),
|
259
|
543 list);
|
|
544 }
|
|
545 }
|
|
546 entry = Fcons (Fnreverse (list),
|
|
547 entry);
|
278
|
548 ldap_value_free (unwind.vals);
|
|
549 unwind.vals = (char **)NULL;
|
259
|
550 }
|
|
551 result = Fcons (Fnreverse (entry),
|
|
552 result);
|
278
|
553 ldap_msgfree (unwind.res);
|
|
554 unwind.res = (LDAPMessage *)NULL;
|
276
|
555
|
|
556 slow_down_interrupts ();
|
278
|
557 rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &(unwind.res));
|
276
|
558 speed_up_interrupts ();
|
259
|
559 }
|
|
560
|
|
561 if (rc == -1)
|
|
562 {
|
276
|
563 signal_ldap_error (ld);
|
259
|
564 }
|
|
565
|
278
|
566 if ((rc = ldap_result2error (ld, unwind.res, 0)) != LDAP_SUCCESS)
|
259
|
567 {
|
276
|
568 signal_ldap_error (ld);
|
259
|
569 }
|
|
570
|
278
|
571 ldap_msgfree (unwind.res);
|
|
572 unwind.res = (LDAPMessage *)NULL;
|
259
|
573 message ("Done.");
|
|
574
|
|
575 result = Fnreverse (result);
|
|
576 clear_message ();
|
|
577
|
278
|
578 unbind_to (speccount, Qnil);
|
259
|
579 UNGCPRO;
|
|
580 return result;
|
|
581 }
|
|
582
|
|
583
|
|
584 void
|
|
585 syms_of_eldap (void)
|
|
586 {
|
276
|
587 defsymbol (&Qldapp, "ldapp");
|
259
|
588
|
276
|
589 DEFSUBR (Fldapp);
|
|
590 DEFSUBR (Fldap_host);
|
|
591 DEFSUBR (Fldap_status);
|
|
592 DEFSUBR (Fldap_open);
|
|
593 DEFSUBR (Fldap_close);
|
|
594 DEFSUBR (Fldap_search_internal);
|
259
|
595 }
|
|
596
|
|
597 void
|
|
598 vars_of_eldap (void)
|
|
599 {
|
276
|
600 Fprovide (intern ("ldap"));
|
259
|
601
|
276
|
602 ldap_default_port = LDAP_PORT;
|
|
603 Vldap_default_base = Qnil;
|
|
604
|
|
605 DEFVAR_INT ("ldap-default-port", &ldap_default_port /*
|
|
606 Default TCP port for LDAP connections.
|
|
607 Initialized from the LDAP library. Default value is 389.
|
259
|
608 */ );
|
|
609
|
|
610 DEFVAR_LISP ("ldap-default-base", &Vldap_default_base /*
|
|
611 Default base for LDAP searches.
|
|
612 This is a string using the syntax of RFC 1779.
|
|
613 For instance, "o=ACME, c=US" limits the search to the
|
|
614 Acme organization in the United States.
|
|
615 */ );
|
|
616
|
|
617 }
|
276
|
618
|
|
619
|