ruby-ldap 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +24 -0
- data/ChangeLog +762 -0
- data/FAQ +62 -0
- data/NOTES +77 -0
- data/README +266 -0
- data/TODO +15 -0
- data/conn.c +1810 -0
- data/entry.c +215 -0
- data/extconf.rb +268 -0
- data/ldap.c +577 -0
- data/lib/ldap/control.rb +50 -0
- data/lib/ldap/ldif.rb +569 -0
- data/lib/ldap/schema.rb +129 -0
- data/misc.c +512 -0
- data/mod.c +355 -0
- data/rbldap.h +194 -0
- data/saslconn.c +176 -0
- data/sslconn.c +377 -0
- data/test/add.rb +31 -0
- data/test/add2.rb +31 -0
- data/test/add3.rb +33 -0
- data/test/bind-ldaps.rb +25 -0
- data/test/bind-sasl.rb +17 -0
- data/test/bind-ssl.rb +25 -0
- data/test/bind.rb +34 -0
- data/test/compare.rb +17 -0
- data/test/conf.rb +12 -0
- data/test/delete.rb +13 -0
- data/test/ext.rb +49 -0
- data/test/misc1.rb +49 -0
- data/test/misc2.rb +40 -0
- data/test/modrdn.rb +23 -0
- data/test/search.rb +20 -0
- data/test/search2.rb +34 -0
- data/test/search3.rb +23 -0
- data/test/setup.rb +38 -0
- data/test/subschema.rb +21 -0
- data/test/tc_conn.rb +124 -0
- data/test/tc_ldif.rb +174 -0
- data/test/tc_schema.rb +32 -0
- data/test/tc_search.rb +137 -0
- data/test/ts_ldap.rb +8 -0
- data/win/winlber.h +21 -0
- data/win/winldap.h +324 -0
- metadata +100 -0
data/ldap.c
ADDED
@@ -0,0 +1,577 @@
|
|
1
|
+
/* -*- C -*-
|
2
|
+
*
|
3
|
+
* ldap.c
|
4
|
+
* $Id: ldap.c,v 1.14 2005/03/15 10:07:48 ianmacd Exp $
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include "ruby.h"
|
8
|
+
#include "rbldap.h"
|
9
|
+
|
10
|
+
VALUE rb_mLDAP;
|
11
|
+
VALUE rb_eLDAP_Error;
|
12
|
+
VALUE rb_eLDAP_ResultError;
|
13
|
+
VALUE rb_eLDAP_InvalidDataError;
|
14
|
+
VALUE rb_eLDAP_InvalidEntryError;
|
15
|
+
|
16
|
+
VALUE
|
17
|
+
rb_ldap_class_new (int argc, VALUE argv[], VALUE klass)
|
18
|
+
{
|
19
|
+
VALUE obj;
|
20
|
+
|
21
|
+
obj = rb_funcall (klass, rb_intern ("allocate"), 0);
|
22
|
+
rb_obj_call_init (obj, argc, argv);
|
23
|
+
|
24
|
+
return obj;
|
25
|
+
}
|
26
|
+
|
27
|
+
VALUE
|
28
|
+
rb_ldap_dummy_method (int argc, VALUE argv[], VALUE self)
|
29
|
+
{
|
30
|
+
/* do nothing */
|
31
|
+
return Qnil;
|
32
|
+
}
|
33
|
+
|
34
|
+
/*
|
35
|
+
* call-seq:
|
36
|
+
* LDAP.err2string(err) => String
|
37
|
+
*
|
38
|
+
* Return the text string associated with the LDAP error, +err+.
|
39
|
+
*/
|
40
|
+
VALUE
|
41
|
+
rb_ldap_err2string (VALUE self, VALUE err)
|
42
|
+
{
|
43
|
+
char *cmsg;
|
44
|
+
VALUE msg;
|
45
|
+
|
46
|
+
cmsg = ldap_err2string (NUM2INT (err));
|
47
|
+
msg = rb_tainted_str_new2 (cmsg);
|
48
|
+
|
49
|
+
return msg;
|
50
|
+
}
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* LDAP.dn2ufn(dn) => String or nil
|
55
|
+
*
|
56
|
+
* Translate the DN, +dn+, to a more User-Friendly Name (UFN).
|
57
|
+
*
|
58
|
+
* For example:
|
59
|
+
*
|
60
|
+
* <code>LDAP.dn2ufn('uid=ianmacd,ou=People,dc=google,dc=com')</code>
|
61
|
+
*
|
62
|
+
* produces:
|
63
|
+
*
|
64
|
+
* ianmacd, People, google.com
|
65
|
+
*
|
66
|
+
* The UFN format is described in
|
67
|
+
* RFC1781[http://www.faqs.org/rfcs/rfc1781.html].
|
68
|
+
*/
|
69
|
+
VALUE
|
70
|
+
rb_ldap_dn2ufn (VALUE self, VALUE dn)
|
71
|
+
{
|
72
|
+
char *c_dn;
|
73
|
+
char *c_ufn;
|
74
|
+
|
75
|
+
if (dn == Qnil)
|
76
|
+
{
|
77
|
+
return Qnil;
|
78
|
+
}
|
79
|
+
|
80
|
+
c_dn = StringValueCStr (dn);
|
81
|
+
if ((c_ufn = ldap_dn2ufn (c_dn)))
|
82
|
+
{
|
83
|
+
return rb_tainted_str_new2 (c_ufn);
|
84
|
+
}
|
85
|
+
else
|
86
|
+
{
|
87
|
+
return Qnil;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
/*
|
92
|
+
* call-seq:
|
93
|
+
* LDAP.mod(mod_type, attr, vals) => LDAP::Mod
|
94
|
+
*
|
95
|
+
* Create a new LDAP::Mod object of type, +mod_type+. This is most commonly
|
96
|
+
* *LDAP_MOD_ADD*, *LDAP_MOD_REPLACE* or *LDAP_MOD_DELETE*, although some LDAP
|
97
|
+
* servers may offer extension types.
|
98
|
+
*
|
99
|
+
* +attr+ should be the name of the attribute on which to operate, whilst
|
100
|
+
* +vals+ is an array of values pertaining to +attr+. If +vals+ contains
|
101
|
+
* binary data, +mod_type+ should be logically OR'ed (|) with
|
102
|
+
* *LDAP_MOD_BVALUES*.
|
103
|
+
*
|
104
|
+
* LDAP::Mod objects can be passed to methods in the LDAP::Conn class, such as
|
105
|
+
* Conn#add, Conn#add_ext, Conn#modify and Conn#modify_ext.
|
106
|
+
*/
|
107
|
+
static VALUE
|
108
|
+
rb_ldap_mod_s_new (int argc, VALUE argv[], VALUE klass)
|
109
|
+
{
|
110
|
+
return rb_ldap_class_new (argc, argv, rb_cLDAP_Mod);
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
rb_ldap_hash2mods_i (VALUE type_vals, VALUE tmp)
|
115
|
+
{
|
116
|
+
VALUE type, vals, op, result;
|
117
|
+
VALUE args[3];
|
118
|
+
|
119
|
+
op = rb_ary_entry (tmp, 0);
|
120
|
+
result = rb_ary_entry (tmp, 1);
|
121
|
+
|
122
|
+
type = rb_ary_entry (type_vals, 0);
|
123
|
+
vals = rb_ary_entry (type_vals, 1);
|
124
|
+
|
125
|
+
args[0] = op, args[1] = type, args[2] = vals;
|
126
|
+
rb_ary_push (result, rb_ldap_mod_s_new (3, args, rb_cLDAP_Mod));
|
127
|
+
return Qnil;
|
128
|
+
}
|
129
|
+
|
130
|
+
/*
|
131
|
+
* call-seq:
|
132
|
+
* LDAP.hash2mods(mod_type, hash) => Array of LDAP::Mod
|
133
|
+
*
|
134
|
+
* Convert a hash into an array of LDAP::Mod objects. +mod_type+ should
|
135
|
+
* contain the mod type, which is most commonly *LDAP_MOD_ADD*,
|
136
|
+
* *LDAP_MOD_REPLACE* or *LDAP_MOD_DELETE*, although some LDAP servers may
|
137
|
+
* offer extension types.
|
138
|
+
*/
|
139
|
+
VALUE
|
140
|
+
rb_ldap_hash2mods (VALUE self, VALUE op, VALUE hash)
|
141
|
+
{
|
142
|
+
VALUE tmp;
|
143
|
+
|
144
|
+
tmp = rb_assoc_new (op, rb_ary_new ());
|
145
|
+
rb_iterate (rb_each, hash, rb_ldap_hash2mods_i, tmp);
|
146
|
+
|
147
|
+
return rb_ary_entry (tmp, 1);
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
* call-seq:
|
152
|
+
* LDAP.entry2hash(entry) => Hash
|
153
|
+
*
|
154
|
+
* Convert the entry, +entry+, to a hash.
|
155
|
+
*/
|
156
|
+
VALUE
|
157
|
+
rb_ldap_entry2hash (VALUE self, VALUE entry)
|
158
|
+
{
|
159
|
+
return rb_ldap_entry_to_hash (entry);
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
extern void Init_ldap_entry ();
|
165
|
+
extern void Init_ldap_conn ();
|
166
|
+
extern void Init_ldap_sslconn ();
|
167
|
+
extern void Init_ldap_saslconn ();
|
168
|
+
extern void Init_ldap_mod ();
|
169
|
+
extern void Init_ldap_misc ();
|
170
|
+
|
171
|
+
/* Document-class: LDAP
|
172
|
+
*
|
173
|
+
* Container module for LDAP-related classes.
|
174
|
+
*/
|
175
|
+
void
|
176
|
+
Init_ldap ()
|
177
|
+
{
|
178
|
+
rb_mLDAP = rb_define_module ("LDAP");
|
179
|
+
|
180
|
+
rb_define_const (rb_mLDAP, "LDAP_VERSION", INT2NUM (LDAP_VERSION));
|
181
|
+
|
182
|
+
#ifdef LDAP_VERSION1
|
183
|
+
rb_define_const (rb_mLDAP, "LDAP_VERSION1", INT2NUM (LDAP_VERSION1));
|
184
|
+
#endif
|
185
|
+
|
186
|
+
#ifdef LDAP_VERSION2
|
187
|
+
rb_define_const (rb_mLDAP, "LDAP_VERSION2", INT2NUM (LDAP_VERSION2));
|
188
|
+
#endif
|
189
|
+
|
190
|
+
#ifdef LDAP_VERSION3
|
191
|
+
rb_define_const (rb_mLDAP, "LDAP_VERSION3", INT2NUM (LDAP_VERSION3));
|
192
|
+
#endif
|
193
|
+
|
194
|
+
#ifdef LDAP_VERSION_MAX
|
195
|
+
rb_define_const (rb_mLDAP, "LDAP_VERSION_MAX", INT2NUM (LDAP_VERSION_MAX));
|
196
|
+
#else
|
197
|
+
rb_define_const (rb_mLDAP, "LDAP_VERSION_MAX", INT2NUM (LDAP_VERSION));
|
198
|
+
#endif
|
199
|
+
|
200
|
+
rb_define_const (rb_mLDAP, "VERSION",
|
201
|
+
rb_tainted_str_new2 (RB_LDAP_VERSION));
|
202
|
+
rb_define_const (rb_mLDAP, "MAJOR_VERSION",
|
203
|
+
INT2NUM (RB_LDAP_MAJOR_VERSION));
|
204
|
+
rb_define_const (rb_mLDAP, "MINOR_VERSION",
|
205
|
+
INT2NUM (RB_LDAP_MINOR_VERSION));
|
206
|
+
rb_define_const (rb_mLDAP, "PATCH_VERSION",
|
207
|
+
INT2NUM (RB_LDAP_PATCH_VERSION));
|
208
|
+
|
209
|
+
#ifdef LDAP_API_INFO_VERSION
|
210
|
+
rb_define_const (rb_mLDAP, "LDAP_API_INFO_VERSION",
|
211
|
+
INT2NUM (LDAP_API_INFO_VERSION));
|
212
|
+
#else
|
213
|
+
rb_define_const (rb_mLDAP, "LDAP_API_INFO_VERSION", Qnil);
|
214
|
+
#endif
|
215
|
+
|
216
|
+
#ifdef LDAP_VENDOR_VERSION
|
217
|
+
rb_define_const (rb_mLDAP, "LDAP_VENDOR_VERSION",
|
218
|
+
INT2NUM (LDAP_VENDOR_VERSION));
|
219
|
+
#else
|
220
|
+
rb_define_const (rb_mLDAP, "LDAP_VENDOR_VERSION", Qnil);
|
221
|
+
#endif
|
222
|
+
#ifdef LDAP_VENDOR_NAME
|
223
|
+
rb_define_const (rb_mLDAP, "LDAP_VENDOR_NAME",
|
224
|
+
rb_tainted_str_new2 (LDAP_VENDOR_NAME));
|
225
|
+
#else
|
226
|
+
rb_define_const (rb_mLDAP, "LDAP_VENDOR_NAME", Qnil);
|
227
|
+
#endif
|
228
|
+
|
229
|
+
#ifdef LDAP_API_VERSION
|
230
|
+
rb_define_const (rb_mLDAP, "LDAP_API_VERSION", INT2NUM (LDAP_API_VERSION));
|
231
|
+
#else
|
232
|
+
rb_define_const (rb_mLDAP, "LDAP_API_VERSION", Qnil);
|
233
|
+
#endif
|
234
|
+
|
235
|
+
rb_define_const (rb_mLDAP, "LDAP_PORT", INT2NUM (389));
|
236
|
+
rb_define_const (rb_mLDAP, "LDAPS_PORT", INT2NUM (636));
|
237
|
+
rb_eLDAP_Error =
|
238
|
+
rb_define_class_under (rb_mLDAP, "Error", rb_eStandardError);
|
239
|
+
rb_eLDAP_ResultError =
|
240
|
+
rb_define_class_under (rb_mLDAP, "ResultError", rb_eLDAP_Error);
|
241
|
+
rb_eLDAP_InvalidDataError =
|
242
|
+
rb_define_class_under (rb_mLDAP, "InvalidDataError", rb_eLDAP_Error);
|
243
|
+
rb_eLDAP_InvalidEntryError =
|
244
|
+
rb_define_class_under (rb_mLDAP, "InvalidEntryError",
|
245
|
+
rb_eLDAP_InvalidDataError);
|
246
|
+
|
247
|
+
|
248
|
+
rb_define_module_function (rb_mLDAP, "err2string", rb_ldap_err2string, 1);
|
249
|
+
rb_define_module_function (rb_mLDAP, "dn2ufn", rb_ldap_dn2ufn, 1);
|
250
|
+
rb_define_module_function (rb_mLDAP, "mod", rb_ldap_mod_s_new, -1);
|
251
|
+
rb_define_module_function (rb_mLDAP, "hash2mods", rb_ldap_hash2mods, 2);
|
252
|
+
rb_define_module_function (rb_mLDAP, "entry2hash", rb_ldap_entry2hash, 1);
|
253
|
+
|
254
|
+
/* the following error code must be defined in ldap.h */
|
255
|
+
#define rb_ldap_define_err_code(code) rb_define_const(rb_mLDAP,#code,INT2NUM(code))
|
256
|
+
rb_ldap_define_err_code (LDAP_SUCCESS);
|
257
|
+
rb_ldap_define_err_code (LDAP_OPERATIONS_ERROR);
|
258
|
+
rb_ldap_define_err_code (LDAP_PROTOCOL_ERROR);
|
259
|
+
rb_ldap_define_err_code (LDAP_TIMELIMIT_EXCEEDED);
|
260
|
+
rb_ldap_define_err_code (LDAP_SIZELIMIT_EXCEEDED);
|
261
|
+
rb_ldap_define_err_code (LDAP_COMPARE_FALSE);
|
262
|
+
rb_ldap_define_err_code (LDAP_COMPARE_TRUE);
|
263
|
+
#ifdef LDAP_STRONG_AUTH_NOT_SUPPORTED
|
264
|
+
rb_ldap_define_err_code (LDAP_STRONG_AUTH_NOT_SUPPORTED);
|
265
|
+
#endif
|
266
|
+
#ifdef LDAP_AUTH_METHOD_NOT_SUPPORTED
|
267
|
+
rb_ldap_define_err_code (LDAP_AUTH_METHOD_NOT_SUPPORTED);
|
268
|
+
#endif
|
269
|
+
rb_ldap_define_err_code (LDAP_STRONG_AUTH_REQUIRED);
|
270
|
+
#ifdef LDAP_REFERRAL
|
271
|
+
rb_ldap_define_err_code (LDAP_REFERRAL);
|
272
|
+
#endif
|
273
|
+
#ifdef LDAP_ADMINLIMIT_EXCEEDED
|
274
|
+
rb_ldap_define_err_code (LDAP_ADMINLIMIT_EXCEEDED);
|
275
|
+
#endif
|
276
|
+
#ifdef LDAP_UNAVAILABLE_CRITICAL_EXTENSION
|
277
|
+
rb_ldap_define_err_code (LDAP_UNAVAILABLE_CRITICAL_EXTENSION);
|
278
|
+
#endif
|
279
|
+
#ifdef LDAP_CONFIDENTIALITY_REQUIRED
|
280
|
+
rb_ldap_define_err_code (LDAP_CONFIDENTIALITY_REQUIRED);
|
281
|
+
#endif
|
282
|
+
#ifdef LDAP_SASL_BIND_IN_PROGRESS
|
283
|
+
rb_ldap_define_err_code (LDAP_SASL_BIND_IN_PROGRESS);
|
284
|
+
#endif
|
285
|
+
#ifdef LDAP_PARTIAL_RESULTS
|
286
|
+
rb_ldap_define_err_code (LDAP_PARTIAL_RESULTS);
|
287
|
+
#endif
|
288
|
+
rb_ldap_define_err_code (LDAP_NO_SUCH_ATTRIBUTE);
|
289
|
+
rb_ldap_define_err_code (LDAP_UNDEFINED_TYPE);
|
290
|
+
rb_ldap_define_err_code (LDAP_INAPPROPRIATE_MATCHING);
|
291
|
+
rb_ldap_define_err_code (LDAP_CONSTRAINT_VIOLATION);
|
292
|
+
rb_ldap_define_err_code (LDAP_TYPE_OR_VALUE_EXISTS);
|
293
|
+
rb_ldap_define_err_code (LDAP_INVALID_SYNTAX);
|
294
|
+
rb_ldap_define_err_code (LDAP_NO_SUCH_OBJECT);
|
295
|
+
rb_ldap_define_err_code (LDAP_ALIAS_PROBLEM);
|
296
|
+
rb_ldap_define_err_code (LDAP_INVALID_DN_SYNTAX);
|
297
|
+
rb_ldap_define_err_code (LDAP_IS_LEAF);
|
298
|
+
rb_ldap_define_err_code (LDAP_ALIAS_DEREF_PROBLEM);
|
299
|
+
rb_ldap_define_err_code (LDAP_INAPPROPRIATE_AUTH);
|
300
|
+
rb_ldap_define_err_code (LDAP_INVALID_CREDENTIALS);
|
301
|
+
rb_ldap_define_err_code (LDAP_INSUFFICIENT_ACCESS);
|
302
|
+
rb_ldap_define_err_code (LDAP_BUSY);
|
303
|
+
rb_ldap_define_err_code (LDAP_UNAVAILABLE);
|
304
|
+
rb_ldap_define_err_code (LDAP_UNWILLING_TO_PERFORM);
|
305
|
+
rb_ldap_define_err_code (LDAP_LOOP_DETECT);
|
306
|
+
rb_ldap_define_err_code (LDAP_NAMING_VIOLATION);
|
307
|
+
rb_ldap_define_err_code (LDAP_OBJECT_CLASS_VIOLATION);
|
308
|
+
rb_ldap_define_err_code (LDAP_NOT_ALLOWED_ON_NONLEAF);
|
309
|
+
rb_ldap_define_err_code (LDAP_NOT_ALLOWED_ON_RDN);
|
310
|
+
rb_ldap_define_err_code (LDAP_ALREADY_EXISTS);
|
311
|
+
rb_ldap_define_err_code (LDAP_NO_OBJECT_CLASS_MODS);
|
312
|
+
rb_ldap_define_err_code (LDAP_RESULTS_TOO_LARGE);
|
313
|
+
rb_ldap_define_err_code (LDAP_OTHER);
|
314
|
+
rb_ldap_define_err_code (LDAP_SERVER_DOWN);
|
315
|
+
rb_ldap_define_err_code (LDAP_LOCAL_ERROR);
|
316
|
+
rb_ldap_define_err_code (LDAP_ENCODING_ERROR);
|
317
|
+
rb_ldap_define_err_code (LDAP_DECODING_ERROR);
|
318
|
+
rb_ldap_define_err_code (LDAP_TIMEOUT);
|
319
|
+
rb_ldap_define_err_code (LDAP_AUTH_UNKNOWN);
|
320
|
+
rb_ldap_define_err_code (LDAP_FILTER_ERROR);
|
321
|
+
rb_ldap_define_err_code (LDAP_USER_CANCELLED);
|
322
|
+
rb_ldap_define_err_code (LDAP_PARAM_ERROR);
|
323
|
+
rb_ldap_define_err_code (LDAP_NO_MEMORY);
|
324
|
+
/* rb_ldap_define_err_code(LDAP_CONNECT_ERROR); */
|
325
|
+
#undef rb_ldap_define_err_code
|
326
|
+
|
327
|
+
#define rb_ldap_define_opt(code) rb_define_const(rb_mLDAP,#code,INT2NUM((int)code))
|
328
|
+
#ifdef LDAP_OPT_ON
|
329
|
+
rb_ldap_define_opt (LDAP_OPT_ON);
|
330
|
+
#endif
|
331
|
+
#ifdef LDAP_OPT_OFF
|
332
|
+
rb_ldap_define_opt (LDAP_OPT_OFF);
|
333
|
+
#endif
|
334
|
+
#ifdef LDAP_OPT_DESC
|
335
|
+
rb_ldap_define_opt (LDAP_OPT_DESC);
|
336
|
+
#endif
|
337
|
+
#ifdef LDAP_OPT_DEREF
|
338
|
+
rb_ldap_define_opt (LDAP_OPT_DEREF);
|
339
|
+
#endif
|
340
|
+
#ifdef LDAP_OPT_SIZELIMIT
|
341
|
+
rb_ldap_define_opt (LDAP_OPT_SIZELIMIT);
|
342
|
+
#endif
|
343
|
+
#ifdef LDAP_OPT_TIMELIMIT
|
344
|
+
rb_ldap_define_opt (LDAP_OPT_TIMELIMIT);
|
345
|
+
#endif
|
346
|
+
#ifdef LDAP_OPT_THREAD_FN_PTRS
|
347
|
+
rb_ldap_define_opt (LDAP_OPT_THREAD_FN_PTRS);
|
348
|
+
#endif
|
349
|
+
#ifdef LDAP_OPT_REBIND_FN
|
350
|
+
rb_ldap_define_opt (LDAP_OPT_REBIND_FN);
|
351
|
+
#endif
|
352
|
+
#ifdef LDAP_OPT_REBIND_ARG
|
353
|
+
rb_ldap_define_opt (LDAP_OPT_REBIND_ARG);
|
354
|
+
#endif
|
355
|
+
#ifdef LDAP_OPT_REFERRALS
|
356
|
+
rb_ldap_define_opt (LDAP_OPT_REFERRALS);
|
357
|
+
#endif
|
358
|
+
#ifdef LDAP_OPT_RESTART
|
359
|
+
rb_ldap_define_opt (LDAP_OPT_RESTART);
|
360
|
+
#endif
|
361
|
+
#ifdef LDAP_OPT_SSL
|
362
|
+
rb_ldap_define_opt (LDAP_OPT_SSL);
|
363
|
+
#endif
|
364
|
+
#ifdef LDAP_OPT_IO_FN_PTRS
|
365
|
+
rb_ldap_define_opt (LDAP_OPT_IO_FN_PTRS);
|
366
|
+
#endif
|
367
|
+
#ifdef LDAP_OPT_CACHE_FN_PTRS
|
368
|
+
rb_ldap_define_opt (LDAP_OPT_CACHE_FN_PTRS);
|
369
|
+
#endif
|
370
|
+
#ifdef LDAP_OPT_CACHE_STRATEGY
|
371
|
+
rb_ldap_define_opt (LDAP_OPT_CACHE_STRATEGY);
|
372
|
+
#endif
|
373
|
+
#ifdef LDAP_OPT_CACHE_ENABLE
|
374
|
+
rb_ldap_define_opt (LDAP_OPT_CACHE_ENABLE);
|
375
|
+
#endif
|
376
|
+
#ifdef LDAP_OPT_REFERRAL_HOP_LIMIT
|
377
|
+
rb_ldap_define_opt (LDAP_OPT_REFERRAL_HOP_LIMIT);
|
378
|
+
#endif
|
379
|
+
#ifdef LDAP_OPT_PROTOCOL_VERSION
|
380
|
+
rb_ldap_define_opt (LDAP_OPT_PROTOCOL_VERSION);
|
381
|
+
#endif
|
382
|
+
#ifdef LDAP_OPT_SERVER_CONTROLS
|
383
|
+
rb_ldap_define_opt (LDAP_OPT_SERVER_CONTROLS);
|
384
|
+
#endif
|
385
|
+
#ifdef LDAP_OPT_CLIENT_CONTROLS
|
386
|
+
rb_ldap_define_opt (LDAP_OPT_CLIENT_CONTROLS);
|
387
|
+
#endif
|
388
|
+
#ifdef LDAP_OPT_PREFERRED_LANGUAGE
|
389
|
+
rb_ldap_define_opt (LDAP_OPT_PREFERRED_LANGUAGE);
|
390
|
+
#endif
|
391
|
+
#ifdef LDAP_OPT_API_INFO
|
392
|
+
rb_ldap_define_opt (LDAP_OPT_API_INFO);
|
393
|
+
#endif
|
394
|
+
#ifdef LDAP_OPT_API_FEATURE_INFO
|
395
|
+
rb_ldap_define_opt (LDAP_OPT_API_FEATURE_INFO);
|
396
|
+
#endif
|
397
|
+
#ifdef LDAP_OPT_HOST_NAME
|
398
|
+
rb_ldap_define_opt (LDAP_OPT_HOST_NAME);
|
399
|
+
#endif
|
400
|
+
|
401
|
+
#ifdef USE_OPENLDAP2 /* OpenLDAP TLS,SASL options */
|
402
|
+
#ifdef LDAP_OPT_X_TLS_CACERTFILE
|
403
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_CACERTFILE);
|
404
|
+
#endif
|
405
|
+
#ifdef LDAP_OPT_X_TLS_CACERTDIR
|
406
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_CACERTDIR);
|
407
|
+
#endif
|
408
|
+
#ifdef LDAP_OPT_X_TLS_CERT
|
409
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_CERT);
|
410
|
+
#endif
|
411
|
+
#ifdef LDAP_OPT_X_TLS_CERTFILE
|
412
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_CERTFILE);
|
413
|
+
#endif
|
414
|
+
#ifdef LDAP_OPT_X_TLS_KEYFILE
|
415
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_KEYFILE);
|
416
|
+
#endif
|
417
|
+
#ifdef LDAP_OPT_X_TLS_REQUIRE_CERT
|
418
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_REQUIRE_CERT);
|
419
|
+
#endif
|
420
|
+
#ifdef LDAP_OPT_X_TLS
|
421
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS);
|
422
|
+
#endif
|
423
|
+
#ifdef LDAP_OPT_X_TLS_PROTOCOL_MIN
|
424
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_PROTOCOL_MIN);
|
425
|
+
#endif
|
426
|
+
#ifdef LDAP_OPT_X_TLS_CIPHER_SUITE
|
427
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_CIPHER_SUITE);
|
428
|
+
#endif
|
429
|
+
#ifdef LDAP_OPT_X_TLS_RANDOM_FILE
|
430
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_RANDOM_FILE);
|
431
|
+
#endif
|
432
|
+
#ifdef LDAP_OPT_X_TLS_NEVER
|
433
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_NEVER);
|
434
|
+
#endif
|
435
|
+
#ifdef LDAP_OPT_X_TLS_HARD
|
436
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_HARD);
|
437
|
+
#endif
|
438
|
+
#ifdef LDAP_OPT_X_TLS_DEMAND
|
439
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_DEMAND);
|
440
|
+
#endif
|
441
|
+
#ifdef LDAP_OPT_X_TLS_ALLOW
|
442
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_ALLOW);
|
443
|
+
#endif
|
444
|
+
#ifdef LDAP_OPT_X_TLS_TRY
|
445
|
+
rb_ldap_define_opt (LDAP_OPT_X_TLS_TRY);
|
446
|
+
#endif
|
447
|
+
#ifdef LDAP_OPT_X_SASL_MECH
|
448
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_MECH);
|
449
|
+
#endif
|
450
|
+
#ifdef LDAP_OPT_X_SASL_REALM
|
451
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_REALM);
|
452
|
+
#endif
|
453
|
+
#ifdef LDAP_OPT_X_SASL_AUTHCID
|
454
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_AUTHCID);
|
455
|
+
#endif
|
456
|
+
#ifdef LDAP_OPT_X_SASL_AUTHZID
|
457
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_AUTHZID);
|
458
|
+
#endif
|
459
|
+
#ifdef LDAP_OPT_X_SASL_SSF
|
460
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_SSF);
|
461
|
+
#endif
|
462
|
+
#ifdef LDAP_OPT_X_SASL_SSF_EXTERNAL
|
463
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_SSF_EXTERNAL);
|
464
|
+
#endif
|
465
|
+
#ifdef LDAP_OPT_X_SASL_SECPROPS
|
466
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_SECPROPS);
|
467
|
+
#endif
|
468
|
+
#ifdef LDAP_OPT_X_SASL_SSF_MIN
|
469
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_SSF_MIN);
|
470
|
+
#endif
|
471
|
+
#ifdef LDAP_OPT_X_SASL_SSF_MAX
|
472
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_SSF_MAX);
|
473
|
+
#endif
|
474
|
+
#ifdef LDAP_OPT_X_SASL_MAXBUFSIZE
|
475
|
+
rb_ldap_define_opt (LDAP_OPT_X_SASL_MAXBUFSIZE);
|
476
|
+
#endif
|
477
|
+
#endif /* USE_OPENLDAP2 */
|
478
|
+
|
479
|
+
|
480
|
+
#undef rb_ldap_define_opt
|
481
|
+
|
482
|
+
/* these constants indicate search scopes */
|
483
|
+
#define rb_ldap_define_scope(scope) rb_define_const(rb_mLDAP,#scope,INT2NUM(scope))
|
484
|
+
rb_ldap_define_scope (LDAP_SCOPE_BASE);
|
485
|
+
rb_ldap_define_scope (LDAP_SCOPE_SUBTREE);
|
486
|
+
rb_ldap_define_scope (LDAP_SCOPE_ONELEVEL);
|
487
|
+
#undef rb_ldap_define_scope
|
488
|
+
|
489
|
+
#define rb_ldap_define_deref(x) rb_define_const(rb_mLDAP,#x,INT2NUM(x))
|
490
|
+
#ifdef LDAP_DEREF_NEVER
|
491
|
+
rb_ldap_define_deref (LDAP_DEREF_NEVER);
|
492
|
+
#endif
|
493
|
+
#ifdef LDAP_DEREF_SEARCHING
|
494
|
+
rb_ldap_define_deref (LDAP_DEREF_SEARCHING);
|
495
|
+
#endif
|
496
|
+
#ifdef LDAP_DEREF_FINDING
|
497
|
+
rb_ldap_define_deref (LDAP_DEREF_FINDING);
|
498
|
+
#endif
|
499
|
+
#ifdef LDAP_DEREF_ALWAYS
|
500
|
+
rb_ldap_define_deref (LDAP_DEREF_ALWAYS);
|
501
|
+
#endif
|
502
|
+
#undef rb_ldap_define_deref
|
503
|
+
|
504
|
+
#define rb_ldap_define_sasl_mech(c) \
|
505
|
+
(c ? rb_define_const(rb_mLDAP,#c,rb_str_new2(c)) : rb_define_const(rb_mLDAP,#c,Qnil))
|
506
|
+
#ifdef LDAP_SASL_SIMPLE
|
507
|
+
rb_ldap_define_sasl_mech (LDAP_SASL_SIMPLE);
|
508
|
+
#endif
|
509
|
+
#undef rb_ldap_define_sasl_mech
|
510
|
+
|
511
|
+
#define rb_ldap_define_auth_method(c) rb_define_const(rb_mLDAP,#c,INT2NUM(c))
|
512
|
+
rb_ldap_define_auth_method (LDAP_AUTH_NONE);
|
513
|
+
rb_ldap_define_auth_method (LDAP_AUTH_SIMPLE);
|
514
|
+
#ifdef LDAP_AUTH_KRBV41
|
515
|
+
rb_ldap_define_auth_method (LDAP_AUTH_KRBV41);
|
516
|
+
#endif
|
517
|
+
#ifdef LDAP_AUTH_KRBV42
|
518
|
+
rb_ldap_define_auth_method (LDAP_AUTH_KRBV42);
|
519
|
+
#endif
|
520
|
+
#ifdef LDAP_AUTH_SASL
|
521
|
+
rb_ldap_define_auth_method (LDAP_AUTH_SASL);
|
522
|
+
#endif
|
523
|
+
#ifdef LDAP_KRBV4
|
524
|
+
rb_ldap_define_auth_method (LDAP_KRBV4);
|
525
|
+
#endif
|
526
|
+
/* wldap32.h */
|
527
|
+
#ifdef LDAP_AUTH_OTHERKIND
|
528
|
+
rb_ldap_define_auth_method (LDAP_AUTH_OTHERKIND);
|
529
|
+
#endif
|
530
|
+
#ifdef LDAP_AUTH_DPA
|
531
|
+
rb_ldap_define_auth_method (LDAP_AUTH_DPA);
|
532
|
+
#endif
|
533
|
+
#ifdef LDAP_AUTH_MSN
|
534
|
+
rb_ldap_define_auth_method (LDAP_AUTH_MSN);
|
535
|
+
#endif
|
536
|
+
#ifdef LDAP_AUTH_NEGOTIATE
|
537
|
+
rb_ldap_define_auth_method (LDAP_AUTH_NEGOTIATE);
|
538
|
+
#endif
|
539
|
+
#ifdef LDAP_AUTH_NTLM
|
540
|
+
rb_ldap_define_auth_method (LDAP_AUTH_NTLM);
|
541
|
+
#endif
|
542
|
+
#ifdef LDAP_AUTH_SICILY
|
543
|
+
rb_ldap_define_auth_method (LDAP_AUTH_SICILY);
|
544
|
+
#endif
|
545
|
+
#ifdef LDAP_AUTH_SSPI
|
546
|
+
rb_ldap_define_auth_method (LDAP_AUTH_SSPI);
|
547
|
+
#endif
|
548
|
+
#undef rb_ldap_define_auth_method
|
549
|
+
|
550
|
+
#ifdef LDAP_CONTROL_PAGEDRESULTS
|
551
|
+
rb_define_const (rb_mLDAP, "LDAP_CONTROL_PAGEDRESULTS",
|
552
|
+
rb_str_new2 (LDAP_CONTROL_PAGEDRESULTS));
|
553
|
+
#endif
|
554
|
+
|
555
|
+
#define rb_ldap_define_const(c) rb_define_const(rb_mLDAP,#c,INT2NUM(c))
|
556
|
+
rb_ldap_define_const (LDAP_MOD_ADD);
|
557
|
+
rb_ldap_define_const (LDAP_MOD_DELETE);
|
558
|
+
rb_ldap_define_const (LDAP_MOD_REPLACE);
|
559
|
+
rb_ldap_define_const (LDAP_MOD_BVALUES);
|
560
|
+
#ifdef LDAP_MOD_INCREMENT
|
561
|
+
/*
|
562
|
+
* See http://www.ietf.org/internet-drafts/draft-zeilenga-ldap-incr-00.txt
|
563
|
+
*/
|
564
|
+
rb_ldap_define_const (LDAP_MOD_INCREMENT);
|
565
|
+
#endif
|
566
|
+
#ifdef LDAP_MOD_OP
|
567
|
+
rb_ldap_define_const (LDAP_MOD_OP);
|
568
|
+
#endif
|
569
|
+
#undef rb_ldap_define_const
|
570
|
+
|
571
|
+
Init_ldap_conn ();
|
572
|
+
Init_ldap_sslconn ();
|
573
|
+
Init_ldap_saslconn ();
|
574
|
+
Init_ldap_entry ();
|
575
|
+
Init_ldap_mod ();
|
576
|
+
Init_ldap_misc ();
|
577
|
+
}
|