Mercurial > hg > xemacs-beta
comparison src/eldap.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | aabb7f5b1c81 |
children | a86b2b5e0111 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
24 | 24 |
25 /* This file provides lisp primitives for access to an LDAP library | 25 /* This file provides lisp primitives for access to an LDAP library |
26 conforming to the API defined in RFC 1823. | 26 conforming to the API defined in RFC 1823. |
27 It has been tested with: | 27 It has been tested with: |
28 - UMich LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/) | 28 - UMich LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/) |
29 - OpenLDAP 1.0.3 (http://www.openldap.org/) | 29 - OpenLDAP 1.2 (http://www.openldap.org/) |
30 - Netscape's LDAP SDK 1.0 (http://developer.netscape.com/) */ | 30 - Netscape's LDAP SDK (http://developer.netscape.com/) */ |
31 | 31 |
32 | 32 |
33 #include <config.h> | 33 #include <config.h> |
34 #include "lisp.h" | 34 #include "lisp.h" |
35 #include "opaque.h" | 35 #include "opaque.h" |
38 | 38 |
39 #include <errno.h> | 39 #include <errno.h> |
40 | 40 |
41 #include "eldap.h" | 41 #include "eldap.h" |
42 | 42 |
43 #ifdef HAVE_NS_LDAP | |
44 # define HAVE_LDAP_SET_OPTION 1 | |
45 # define HAVE_LDAP_GET_ERRNO 1 | |
46 #else | |
47 # undef HAVE_LDAP_SET_OPTION | |
48 # undef HAVE_LDAP_GET_ERRNO | |
49 #endif | |
50 | |
51 static int ldap_default_port; | 43 static int ldap_default_port; |
52 static Lisp_Object Vldap_default_base; | 44 static Lisp_Object Vldap_default_base; |
53 | 45 |
54 /* Needed by the lrecord definition */ | 46 /* Needed by the lrecord definition */ |
55 Lisp_Object Qldapp; | 47 Lisp_Object Qldapp; |
56 | 48 |
57 /* ldap-open plist keywords */ | 49 /* ldap-open plist keywords */ |
58 extern Lisp_Object Qport, Qauth, Qbinddn, Qpasswd, Qderef, Qtimelimit, | 50 static Lisp_Object Qport, Qauth, Qbinddn, Qpasswd, Qderef, Qtimelimit, Qsizelimit; |
59 Qsizelimit; | |
60 /* Search scope limits */ | 51 /* Search scope limits */ |
61 extern Lisp_Object Qbase, Qonelevel, Qsubtree; | 52 static Lisp_Object Qbase, Qonelevel, Qsubtree; |
62 /* Authentication methods */ | 53 /* Authentication methods */ |
63 extern Lisp_Object Qkrbv41, Qkrbv42; | 54 static Lisp_Object Qkrbv41, Qkrbv42; |
64 /* Deref policy */ | 55 /* Deref policy */ |
65 extern Lisp_Object Qnever, Qalways, Qfind; | 56 static Lisp_Object Qnever, Qalways, Qfind; |
66 | 57 |
67 /************************************************************************/ | 58 /************************************************************************/ |
68 /* Utility Functions */ | 59 /* Utility Functions */ |
69 /************************************************************************/ | 60 /************************************************************************/ |
70 | 61 |
71 static void | 62 static void |
72 signal_ldap_error (LDAP *ld) | 63 signal_ldap_error (LDAP *ld, LDAPMessage *res, int ldap_err) |
73 { | 64 { |
74 #ifdef HAVE_LDAP_GET_ERRNO | 65 if (ldap_err <= 0) |
75 signal_simple_error | 66 { |
76 ("LDAP error", | 67 #if defined HAVE_LDAP_PARSE_RESULT |
77 build_string (ldap_err2string (ldap_get_lderrno (ld, NULL, NULL)))); | 68 int err; |
69 ldap_err = ldap_parse_result (ld, res, | |
70 &err, | |
71 NULL, NULL, NULL, NULL, 0); | |
72 if (ldap_err == LDAP_SUCCESS) | |
73 ldap_err = err; | |
74 #elif defined HAVE_LDAP_GET_LDERRNO | |
75 ldap_err = ldap_get_lderrno (ld, NULL, NULL); | |
76 #elif defined HAVE_LDAP_RESULT2ERROR | |
77 ldap_err = ldap_result2error (ld, res, 0); | |
78 #else | 78 #else |
79 ldap_err = ld->ld_errno; | |
80 #endif | |
81 } | |
79 signal_simple_error ("LDAP error", | 82 signal_simple_error ("LDAP error", |
80 build_string (ldap_err2string (ld->ld_errno))); | 83 build_string (ldap_err2string (ldap_err))); |
81 #endif | |
82 } | 84 } |
83 | 85 |
84 | 86 |
85 /************************************************************************/ | 87 /************************************************************************/ |
86 /* ldap lrecord basic functions */ | 88 /* ldap lrecord basic functions */ |
87 /************************************************************************/ | 89 /************************************************************************/ |
88 | 90 |
89 static Lisp_Object | 91 static Lisp_Object |
90 make_ldap (struct Lisp_LDAP *ldap) | 92 make_ldap (Lisp_LDAP *ldap) |
91 { | 93 { |
92 Lisp_Object lisp_ldap; | 94 Lisp_Object lisp_ldap; |
93 XSETLDAP (lisp_ldap, ldap); | 95 XSETLDAP (lisp_ldap, ldap); |
94 return lisp_ldap; | 96 return lisp_ldap; |
95 } | 97 } |
96 | 98 |
97 static Lisp_Object | 99 static Lisp_Object |
98 mark_ldap (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 100 mark_ldap (Lisp_Object obj) |
99 { | 101 { |
100 return XLDAP (obj)->host; | 102 return XLDAP (obj)->host; |
101 } | 103 } |
102 | 104 |
103 static void | 105 static void |
104 print_ldap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 106 print_ldap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
105 { | 107 { |
106 char buf[32]; | 108 char buf[32]; |
107 | 109 |
108 struct Lisp_LDAP *ldap = XLDAP (obj); | 110 Lisp_LDAP *ldap = XLDAP (obj); |
109 | 111 |
110 if (print_readably) | 112 if (print_readably) |
111 error ("printing unreadable object #<ldap %s>", | 113 error ("printing unreadable object #<ldap %s>", |
112 XSTRING_DATA (ldap->host)); | 114 XSTRING_DATA (ldap->host)); |
113 | 115 |
114 write_c_string ("#<ldap ", printcharfun); | 116 write_c_string ("#<ldap ", printcharfun); |
115 print_internal (ldap->host, printcharfun, 1); | 117 print_internal (ldap->host, printcharfun, 1); |
116 if (!ldap->livep) | 118 if (!ldap->ld) |
117 write_c_string ("(dead) ",printcharfun); | 119 write_c_string ("(dead) ",printcharfun); |
118 sprintf (buf, " 0x%x>", (unsigned int)ldap); | 120 sprintf (buf, " 0x%x>", (unsigned int)ldap); |
119 write_c_string (buf, printcharfun); | 121 write_c_string (buf, printcharfun); |
120 } | 122 } |
121 | 123 |
122 static struct Lisp_LDAP * | 124 static Lisp_LDAP * |
123 allocate_ldap (void) | 125 allocate_ldap (void) |
124 { | 126 { |
125 struct Lisp_LDAP *ldap = | 127 Lisp_LDAP *ldap = alloc_lcrecord_type (Lisp_LDAP, &lrecord_ldap); |
126 alloc_lcrecord_type (struct Lisp_LDAP, lrecord_ldap); | |
127 | 128 |
128 ldap->ld = NULL; | 129 ldap->ld = NULL; |
129 ldap->host = Qnil; | 130 ldap->host = Qnil; |
130 ldap->livep = 0; | |
131 return ldap; | 131 return ldap; |
132 } | 132 } |
133 | 133 |
134 static void | 134 static void |
135 finalize_ldap (void *header, int for_disksave) | 135 finalize_ldap (void *header, int for_disksave) |
136 { | 136 { |
137 struct Lisp_LDAP *ldap = (struct Lisp_LDAP *) header; | 137 Lisp_LDAP *ldap = (Lisp_LDAP *) header; |
138 | 138 |
139 if (for_disksave) | 139 if (for_disksave) |
140 signal_simple_error ("Can't dump an emacs containing LDAP objects", | 140 signal_simple_error ("Can't dump an emacs containing LDAP objects", |
141 make_ldap (ldap)); | 141 make_ldap (ldap)); |
142 | 142 |
143 if (ldap->livep) | 143 if (ldap->ld) |
144 ldap_unbind (ldap->ld); | 144 ldap_unbind (ldap->ld); |
145 ldap->ld = NULL; | |
145 } | 146 } |
146 | 147 |
147 DEFINE_LRECORD_IMPLEMENTATION ("ldap", ldap, | 148 DEFINE_LRECORD_IMPLEMENTATION ("ldap", ldap, |
148 mark_ldap, print_ldap, finalize_ldap, | 149 mark_ldap, print_ldap, finalize_ldap, |
149 NULL, NULL, struct Lisp_LDAP); | 150 NULL, NULL, 0, Lisp_LDAP); |
150 | 151 |
151 | 152 |
152 | 153 |
153 | 154 |
154 /************************************************************************/ | 155 /************************************************************************/ |
176 Return t if LDAP is an active LDAP connection. | 177 Return t if LDAP is an active LDAP connection. |
177 */ | 178 */ |
178 (ldap)) | 179 (ldap)) |
179 { | 180 { |
180 CHECK_LDAP (ldap); | 181 CHECK_LDAP (ldap); |
181 return (XLDAP (ldap))->livep ? Qt : Qnil; | 182 return (XLDAP (ldap))->ld ? Qt : Qnil; |
182 } | 183 } |
183 | 184 |
184 /************************************************************************/ | 185 /************************************************************************/ |
185 /* Opening/Closing a LDAP connection */ | 186 /* Opening/Closing a LDAP connection */ |
186 /************************************************************************/ | 187 /************************************************************************/ |
201 `sizelimit' is the maximum number of matches to return. | 202 `sizelimit' is the maximum number of matches to return. |
202 */ | 203 */ |
203 (host, plist)) | 204 (host, plist)) |
204 { | 205 { |
205 /* This function can GC */ | 206 /* This function can GC */ |
206 struct Lisp_LDAP *ldap; | 207 Lisp_LDAP *ldap; |
207 LDAP *ld; | 208 LDAP *ld; |
208 int ldap_port = 0; | 209 int ldap_port = 0; |
209 int ldap_auth = LDAP_AUTH_SIMPLE; | 210 int ldap_auth = LDAP_AUTH_SIMPLE; |
210 char *ldap_binddn = NULL; | 211 char *ldap_binddn = NULL; |
211 char *ldap_passwd = NULL; | 212 char *ldap_passwd = NULL; |
244 } | 245 } |
245 /* Bind DN */ | 246 /* Bind DN */ |
246 else if (EQ (keyword, Qbinddn)) | 247 else if (EQ (keyword, Qbinddn)) |
247 { | 248 { |
248 CHECK_STRING (value); | 249 CHECK_STRING (value); |
249 GET_C_STRING_OS_DATA_ALLOCA (value, ldap_binddn); | 250 TO_EXTERNAL_FORMAT (LISP_STRING, value, |
251 C_STRING_ALLOCA, ldap_binddn, | |
252 Qnative); | |
250 } | 253 } |
251 /* Password */ | 254 /* Password */ |
252 else if (EQ (keyword, Qpasswd)) | 255 else if (EQ (keyword, Qpasswd)) |
253 { | 256 { |
254 CHECK_STRING (value); | 257 CHECK_STRING (value); |
255 GET_C_STRING_OS_DATA_ALLOCA (value, ldap_passwd); | 258 TO_EXTERNAL_FORMAT (LISP_STRING, value, |
259 C_STRING_ALLOCA, ldap_passwd, | |
260 Qnative); | |
256 } | 261 } |
257 /* Deref */ | 262 /* Deref */ |
258 else if (EQ (keyword, Qderef)) | 263 else if (EQ (keyword, Qderef)) |
259 { | 264 { |
260 if (EQ (value, Qnever)) | 265 if (EQ (value, Qnever)) |
297 host, | 302 host, |
298 lisp_strerror (errno)); | 303 lisp_strerror (errno)); |
299 | 304 |
300 | 305 |
301 #ifdef HAVE_LDAP_SET_OPTION | 306 #ifdef HAVE_LDAP_SET_OPTION |
302 if (ldap_set_option (ld, LDAP_OPT_DEREF, (void *)&ldap_deref) != LDAP_SUCCESS) | 307 if ((err = ldap_set_option (ld, LDAP_OPT_DEREF, |
303 signal_ldap_error (ld); | 308 (void *)&ldap_deref)) != LDAP_SUCCESS) |
304 if (ldap_set_option (ld, LDAP_OPT_TIMELIMIT, | 309 signal_ldap_error (ld, NULL, err); |
305 (void *)&ldap_timelimit) != LDAP_SUCCESS) | 310 if ((err = ldap_set_option (ld, LDAP_OPT_TIMELIMIT, |
306 signal_ldap_error (ld); | 311 (void *)&ldap_timelimit)) != LDAP_SUCCESS) |
307 if (ldap_set_option (ld, LDAP_OPT_SIZELIMIT, | 312 signal_ldap_error (ld, NULL, err); |
308 (void *)&ldap_sizelimit) != LDAP_SUCCESS) | 313 if ((err = ldap_set_option (ld, LDAP_OPT_SIZELIMIT, |
309 signal_ldap_error (ld); | 314 (void *)&ldap_sizelimit)) != LDAP_SUCCESS) |
310 if (ldap_set_option (ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON) != LDAP_SUCCESS) | 315 signal_ldap_error (ld, NULL, err); |
311 signal_ldap_error (ld); | 316 if ((err = ldap_set_option (ld, LDAP_OPT_REFERRALS, |
317 LDAP_OPT_ON)) != LDAP_SUCCESS) | |
318 signal_ldap_error (ld, NULL, err); | |
312 #else /* not HAVE_LDAP_SET_OPTION */ | 319 #else /* not HAVE_LDAP_SET_OPTION */ |
313 ld->ld_deref = ldap_deref; | 320 ld->ld_deref = ldap_deref; |
314 ld->ld_timelimit = ldap_timelimit; | 321 ld->ld_timelimit = ldap_timelimit; |
315 ld->ld_sizelimit = ldap_sizelimit; | 322 ld->ld_sizelimit = ldap_sizelimit; |
316 #ifdef LDAP_REFERRALS | 323 #ifdef LDAP_REFERRALS |
329 build_string (ldap_err2string (err))); | 336 build_string (ldap_err2string (err))); |
330 | 337 |
331 ldap = allocate_ldap (); | 338 ldap = allocate_ldap (); |
332 ldap->ld = ld; | 339 ldap->ld = ld; |
333 ldap->host = host; | 340 ldap->host = host; |
334 ldap->livep = 1; | |
335 | 341 |
336 return make_ldap (ldap); | 342 return make_ldap (ldap); |
337 } | 343 } |
338 | 344 |
339 | 345 |
341 DEFUN ("ldap-close", Fldap_close, 1, 1, 0, /* | 347 DEFUN ("ldap-close", Fldap_close, 1, 1, 0, /* |
342 Close an LDAP connection. | 348 Close an LDAP connection. |
343 */ | 349 */ |
344 (ldap)) | 350 (ldap)) |
345 { | 351 { |
346 struct Lisp_LDAP *lldap; | 352 Lisp_LDAP *lldap; |
347 CHECK_LIVE_LDAP (ldap); | 353 CHECK_LIVE_LDAP (ldap); |
348 lldap = XLDAP (ldap); | 354 lldap = XLDAP (ldap); |
349 ldap_unbind (lldap->ld); | 355 ldap_unbind (lldap->ld); |
350 lldap->livep = 0; | 356 lldap->ld = NULL; |
351 return Qnil; | 357 return Qnil; |
352 } | 358 } |
353 | 359 |
354 | 360 |
355 | 361 |
357 /* Working on a LDAP connection */ | 363 /* Working on a LDAP connection */ |
358 /************************************************************************/ | 364 /************************************************************************/ |
359 struct ldap_unwind_struct | 365 struct ldap_unwind_struct |
360 { | 366 { |
361 LDAPMessage *res; | 367 LDAPMessage *res; |
362 char **vals; | 368 struct berval **vals; |
363 }; | 369 }; |
364 | 370 |
365 | 371 |
366 static Lisp_Object | 372 static Lisp_Object |
367 ldap_search_unwind (Lisp_Object unwind_obj) | 373 ldap_search_unwind (Lisp_Object unwind_obj) |
369 struct ldap_unwind_struct *unwind = | 375 struct ldap_unwind_struct *unwind = |
370 (struct ldap_unwind_struct *) get_opaque_ptr (unwind_obj); | 376 (struct ldap_unwind_struct *) get_opaque_ptr (unwind_obj); |
371 if (unwind->res) | 377 if (unwind->res) |
372 ldap_msgfree (unwind->res); | 378 ldap_msgfree (unwind->res); |
373 if (unwind->vals) | 379 if (unwind->vals) |
374 ldap_value_free (unwind->vals); | 380 ldap_value_free_len (unwind->vals); |
375 return Qnil; | 381 return Qnil; |
376 } | 382 } |
377 | 383 |
378 DEFUN ("ldap-search-internal", Fldap_search_internal, 2, 6, 0, /* | 384 DEFUN ("ldap-search-internal", Fldap_search_internal, 2, 7, 0, /* |
379 Perform a search on an open LDAP connection. | 385 Perform a search on an open LDAP connection. |
380 LDAP is an LDAP connection object created with `ldap-open'. | 386 LDAP is an LDAP connection object created with `ldap-open'. |
381 FILTER is a filter string for the search as described in RFC 1558. | 387 FILTER is a filter string for the search as described in RFC 1558. |
382 BASE is the distinguished name at which to start the search. | 388 BASE is the distinguished name at which to start the search. |
383 SCOPE is one of the symbols `base', `onelevel' or `subtree' indicating | 389 SCOPE is one of the symbols `base', `onelevel' or `subtree' indicating |
384 the scope of the search. | 390 the scope of the search. |
385 ATTRS is a list of strings indicating which attributes to retrieve | 391 ATTRS is a list of strings indicating which attributes to retrieve |
386 for each matching entry. If nil return all available attributes. | 392 for each matching entry. If nil return all available attributes. |
387 If ATTRSONLY is non-nil then only the attributes are retrieved, not | 393 If ATTRSONLY is non-nil then only the attributes are retrieved, not |
388 the associated values. | 394 the associated values. |
395 If WITHDN is non-nil each entry in the result will be prepennded with | |
396 its distinguished name DN. | |
389 The function returns a list of matching entries. Each entry is itself | 397 The function returns a list of matching entries. Each entry is itself |
390 an alist of attribute/values. | 398 an alist of attribute/value pairs optionally preceded by the DN of the |
399 entry according to the value of WITHDN. | |
391 */ | 400 */ |
392 (ldap, filter, base, scope, attrs, attrsonly)) | 401 (ldap, filter, base, scope, attrs, attrsonly, withdn)) |
393 { | 402 { |
394 /* This function can GC */ | 403 /* This function can GC */ |
395 | 404 |
396 /* Vars for query */ | 405 /* Vars for query */ |
397 LDAP *ld; | 406 LDAP *ld; |
398 LDAPMessage *e; | 407 LDAPMessage *e; |
399 BerElement *ptr; | 408 BerElement *ptr; |
400 char *a; | 409 char *a, *dn; |
401 int i, rc; | 410 int i, rc, rc2; |
402 int matches; | 411 int matches; |
403 struct ldap_unwind_struct unwind; | 412 struct ldap_unwind_struct unwind; |
404 | 413 |
405 int ldap_scope = LDAP_SCOPE_SUBTREE; | 414 int ldap_scope = LDAP_SCOPE_SUBTREE; |
406 char **ldap_attributes = NULL; | 415 char **ldap_attributes = NULL; |
455 i = 0; | 464 i = 0; |
456 EXTERNAL_LIST_LOOP (attrs, attrs) | 465 EXTERNAL_LIST_LOOP (attrs, attrs) |
457 { | 466 { |
458 Lisp_Object current = XCAR (attrs); | 467 Lisp_Object current = XCAR (attrs); |
459 CHECK_STRING (current); | 468 CHECK_STRING (current); |
460 GET_C_STRING_OS_DATA_ALLOCA (current, ldap_attributes[i]); | 469 TO_EXTERNAL_FORMAT (LISP_STRING, current, |
470 C_STRING_ALLOCA, ldap_attributes[i], | |
471 Qnative); | |
461 ++i; | 472 ++i; |
462 } | 473 } |
463 ldap_attributes[i] = NULL; | 474 ldap_attributes[i] = NULL; |
464 } | 475 } |
465 | 476 |
471 NILP (base) ? "" : (char *) XSTRING_DATA (base), | 482 NILP (base) ? "" : (char *) XSTRING_DATA (base), |
472 ldap_scope, | 483 ldap_scope, |
473 NILP (filter) ? "" : (char *) XSTRING_DATA (filter), | 484 NILP (filter) ? "" : (char *) XSTRING_DATA (filter), |
474 ldap_attributes, | 485 ldap_attributes, |
475 NILP (attrsonly) ? 0 : 1) | 486 NILP (attrsonly) ? 0 : 1) |
476 == -1) | 487 == -1) |
477 { | 488 { |
478 signal_ldap_error (ld); | 489 signal_ldap_error (ld, NULL, 0); |
479 } | 490 } |
480 | 491 |
481 /* Ensure we don't exit without cleaning up */ | 492 /* Ensure we don't exit without cleaning up */ |
482 record_unwind_protect (ldap_search_unwind, | 493 record_unwind_protect (ldap_search_unwind, |
483 make_opaque_ptr (&unwind)); | 494 make_opaque_ptr (&unwind)); |
498 destroys the current echo area contents, even when invoked | 509 destroys the current echo area contents, even when invoked |
499 from Lisp. It should use echo_area_message() instead, and | 510 from Lisp. It should use echo_area_message() instead, and |
500 restore the old echo area contents later. */ | 511 restore the old echo area contents later. */ |
501 message ("Parsing ldap results... %d", matches); | 512 message ("Parsing ldap results... %d", matches); |
502 entry = Qnil; | 513 entry = Qnil; |
514 /* Get the DN if required */ | |
515 if (! NILP (withdn)) | |
516 { | |
517 dn = ldap_get_dn (ld, e); | |
518 if (dn == NULL) | |
519 signal_ldap_error (ld, e, 0); | |
520 entry = Fcons (build_ext_string (dn, Qnative), Qnil); | |
521 } | |
503 for (a= ldap_first_attribute (ld, e, &ptr); | 522 for (a= ldap_first_attribute (ld, e, &ptr); |
504 a != NULL; | 523 a != NULL; |
505 a= ldap_next_attribute (ld, e, ptr) ) | 524 a = ldap_next_attribute (ld, e, ptr) ) |
506 { | 525 { |
507 list = Fcons (build_ext_string (a, FORMAT_OS), Qnil); | 526 list = Fcons (build_ext_string (a, Qnative), Qnil); |
508 unwind.vals = ldap_get_values (ld, e, a); | 527 unwind.vals = ldap_get_values_len (ld, e, a); |
509 if (unwind.vals != NULL) | 528 if (unwind.vals != NULL) |
510 { | 529 { |
511 for (i = 0; unwind.vals[i] != NULL; i++) | 530 for (i = 0; unwind.vals[i] != NULL; i++) |
512 { | 531 { |
513 list = Fcons (build_ext_string (unwind.vals[i], FORMAT_OS), | 532 list = Fcons (make_ext_string (unwind.vals[i]->bv_val, |
533 unwind.vals[i]->bv_len, | |
534 Qnative), | |
514 list); | 535 list); |
515 } | 536 } |
516 } | 537 } |
517 entry = Fcons (Fnreverse (list), | 538 entry = Fcons (Fnreverse (list), |
518 entry); | 539 entry); |
519 ldap_value_free (unwind.vals); | 540 ldap_value_free_len (unwind.vals); |
520 unwind.vals = NULL; | 541 unwind.vals = NULL; |
521 } | 542 } |
522 result = Fcons (Fnreverse (entry), | 543 result = Fcons (Fnreverse (entry), |
523 result); | 544 result); |
524 ldap_msgfree (unwind.res); | 545 ldap_msgfree (unwind.res); |
528 rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &(unwind.res)); | 549 rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &(unwind.res)); |
529 speed_up_interrupts (); | 550 speed_up_interrupts (); |
530 } | 551 } |
531 | 552 |
532 if (rc == -1) | 553 if (rc == -1) |
533 { | 554 signal_ldap_error (ld, unwind.res, 0); |
534 signal_ldap_error (ld); | 555 |
535 } | 556 if (rc == 0) |
557 signal_ldap_error (ld, NULL, LDAP_TIMELIMIT_EXCEEDED); | |
558 | |
559 #if defined HAVE_LDAP_PARSE_RESULT | |
560 rc2 = ldap_parse_result (ld, unwind.res, | |
561 &rc, | |
562 NULL, NULL, NULL, NULL, 0); | |
563 if (rc2 != LDAP_SUCCESS) | |
564 rc = rc2; | |
565 #elif defined HAVE_LDAP_RESULT2ERROR | |
536 rc = ldap_result2error (ld, unwind.res, 0); | 566 rc = ldap_result2error (ld, unwind.res, 0); |
537 if ((rc != LDAP_SUCCESS) && | 567 #endif |
538 (rc != LDAP_SIZELIMIT_EXCEEDED)) | 568 if ((rc != LDAP_SUCCESS) && (rc != LDAP_SIZELIMIT_EXCEEDED)) |
539 { | 569 signal_ldap_error (ld, NULL, rc); |
540 signal_ldap_error (ld); | |
541 } | |
542 | 570 |
543 ldap_msgfree (unwind.res); | 571 ldap_msgfree (unwind.res); |
544 unwind.res = (LDAPMessage *)NULL; | 572 unwind.res = (LDAPMessage *)NULL; |
545 /* #### See above for calling message(). */ | 573 /* #### See above for calling message(). */ |
546 message ("Parsing ldap results... done"); | 574 message ("Parsing ldap results... done"); |
553 | 581 |
554 void | 582 void |
555 syms_of_eldap (void) | 583 syms_of_eldap (void) |
556 { | 584 { |
557 defsymbol (&Qldapp, "ldapp"); | 585 defsymbol (&Qldapp, "ldapp"); |
586 defsymbol (&Qport, "port"); | |
587 defsymbol (&Qauth, "auth"); | |
588 defsymbol (&Qbinddn, "binddn"); | |
589 defsymbol (&Qpasswd, "passwd"); | |
590 defsymbol (&Qderef, "deref"); | |
591 defsymbol (&Qtimelimit, "timelimit"); | |
592 defsymbol (&Qsizelimit, "sizelimit"); | |
593 defsymbol (&Qbase, "base"); | |
594 defsymbol (&Qonelevel, "onelevel"); | |
595 defsymbol (&Qsubtree, "subtree"); | |
596 defsymbol (&Qkrbv41, "krbv41"); | |
597 defsymbol (&Qkrbv42, "krbv42"); | |
598 defsymbol (&Qnever, "never"); | |
599 defsymbol (&Qalways, "always"); | |
600 defsymbol (&Qfind, "find"); | |
601 | |
558 DEFSUBR (Fldapp); | 602 DEFSUBR (Fldapp); |
559 DEFSUBR (Fldap_host); | 603 DEFSUBR (Fldap_host); |
560 DEFSUBR (Fldap_status); | 604 DEFSUBR (Fldap_status); |
561 DEFSUBR (Fldap_open); | 605 DEFSUBR (Fldap_open); |
562 DEFSUBR (Fldap_close); | 606 DEFSUBR (Fldap_close); |