annotate src/eldap.c @ 283:fa3d41851a08

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