ruby-ldap 0.9.17 → 0.9.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3a89e98ee493dd192900110043609702f6acab9
4
- data.tar.gz: 4988a7cd01236d6c918f9d3dd3780a7325f12232
3
+ metadata.gz: b6924c44fe913f0e2f2886a6d867e315a4c4d1d2
4
+ data.tar.gz: 78eb5ced76910731afc0ef06aed0f47440f5e943
5
5
  SHA512:
6
- metadata.gz: 013aa48ccd94301e1660376edd04230cf548de15e6d5f5a2b11f04d388304bb45cfb53fb824a649e844e2c9ba1769ae981aa0a041719b280ca75168f96a86865
7
- data.tar.gz: 2d45dfb14d1913b0ecf26af6365397ebc3c1a1deb8187fed75b802f25a278a719b0582404c55ae2c34cc0c099b797f4e56bce3704c795a3e733b7e65bb7e527a
6
+ metadata.gz: e8550110a3097ed2c36dc787dfe392de3c6b7bec9de5887729cff903ca390e82d34a3dd403098684d61f0db056ce637837a968ae1507f91467e705221daa3858
7
+ data.tar.gz: 3bff7856fbeec9d8b091d94571b9b396f110dfcfa8ed931fd26ef6e24d3db2ff4daa3bc43591b9221e0fbce3bdc582ee67dfab52b5baa0d8375b250b9a43d835
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Fri Mar 4 11:17:21 UTC 2016 Alexey Chebotar <alexey.chebotar@gmail.com>
2
+ * Version 0.9.18
3
+ * backout issue32 to compile for ruby-1.8.x.
4
+ Thanks to SUENAGA Hiroki.
5
+
1
6
  Fri Feb 6 08:51:09 UTC 2015 Alexey Chebotar <alexey.chebotar@gmail.com>
2
7
  * Version 0.9.17
3
8
  * Use ruby object to keep LDAP search result instead of libldap's data structure.
data/NOTES CHANGED
@@ -1,3 +1,9 @@
1
+ 0.9.18
2
+ -----
3
+ * backout issue32 to compile for ruby-1.8.x.
4
+ Thanks to SUENAGA Hiroki.
5
+
6
+
1
7
  0.9.17
2
8
  -----
3
9
 
data/README CHANGED
@@ -228,7 +228,7 @@ Here are some URLs that contain useful information about LDAP:
228
228
  * Netscape Communications
229
229
  http://developer.netscape.com/docs/manuals/communicator/ldap45.htm
230
230
  * Netscape Directory SDK
231
- http://www.mozilla.org/directory/
231
+ https://wiki.mozilla.org/Directory
232
232
  * Active Directory Service Interfaces Overview
233
233
  http://www.microsoft.com/windows2000/techinfo/howitworks/activedirectory/
234
234
  adsilinks.asp
data/TODO CHANGED
@@ -3,6 +3,9 @@
3
3
  To-do list
4
4
  ----------
5
5
 
6
+ - Running tests:
7
+ ./test/test.sh /Users/bearded/.rvm/rubies/ruby-1.8.7-head/bin/ruby openldap2 /usr/libexec/slapd /etc/openldap/schema/
8
+
6
9
  - Support for more LDAPv3 controls and extensions.
7
10
 
8
11
  - DSML support.
data/entry.c CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  VALUE rb_cLDAP_Entry;
10
10
 
11
+ #if RUBY_VERSION_CODE >= 190
11
12
  static void
12
13
  rb_ldap_entry_mark(RB_LDAPENTRY_DATA *edata)
13
14
  {
@@ -72,6 +73,7 @@ rb_ldap_entry_load_attr(LDAP *ldap, LDAPMessage *msg)
72
73
 
73
74
  return hash;
74
75
  }
76
+ #endif
75
77
 
76
78
  void
77
79
  rb_ldap_entry_free (RB_LDAPENTRY_DATA * edata)
@@ -86,13 +88,21 @@ rb_ldap_entry_new (LDAP * ldap, LDAPMessage * msg)
86
88
  {
87
89
  VALUE val;
88
90
  RB_LDAPENTRY_DATA *edata;
91
+ #if RUBY_VERSION_CODE >= 190
89
92
  char *c_dn;
93
+ #endif
90
94
 
95
+ #if RUBY_VERSION_CODE >= 190
91
96
  val = Data_Make_Struct (rb_cLDAP_Entry, RB_LDAPENTRY_DATA,
92
97
  rb_ldap_entry_mark, rb_ldap_entry_free, edata);
98
+ #else
99
+ val = Data_Make_Struct (rb_cLDAP_Entry, RB_LDAPENTRY_DATA,
100
+ 0, rb_ldap_entry_free, edata);
101
+ #endif
93
102
  edata->ldap = ldap;
94
103
  edata->msg = msg;
95
104
 
105
+ #if RUBY_VERSION_CODE >= 190
96
106
  /* get dn */
97
107
  c_dn = ldap_get_dn(ldap, msg);
98
108
  if (c_dn) {
@@ -105,6 +115,7 @@ rb_ldap_entry_new (LDAP * ldap, LDAPMessage * msg)
105
115
 
106
116
  /* get attributes */
107
117
  edata->attr = rb_ldap_entry_load_attr(ldap, msg);
118
+ #endif
108
119
  return val;
109
120
  }
110
121
 
@@ -117,10 +128,29 @@ VALUE
117
128
  rb_ldap_entry_get_dn (VALUE self)
118
129
  {
119
130
  RB_LDAPENTRY_DATA *edata;
131
+ #if RUBY_VERSION_CODE < 190
132
+ char *cdn;
133
+ VALUE dn;
134
+ #endif
120
135
 
121
136
  GET_LDAPENTRY_DATA (self, edata);
122
137
 
138
+ #if RUBY_VERSION_CODE < 190
139
+ cdn = ldap_get_dn (edata->ldap, edata->msg);
140
+ if (cdn)
141
+ {
142
+ dn = rb_tainted_str_new2 (cdn);
143
+ ldap_memfree (cdn);
144
+ }
145
+ else
146
+ {
147
+ dn = Qnil;
148
+ }
149
+
150
+ return dn;
151
+ #else
123
152
  return edata->dn;
153
+ #endif
124
154
  }
125
155
 
126
156
  /*
@@ -136,10 +166,40 @@ VALUE
136
166
  rb_ldap_entry_get_values (VALUE self, VALUE attr)
137
167
  {
138
168
  RB_LDAPENTRY_DATA *edata;
169
+ #if RUBY_VERSION_CODE < 190
170
+ char *c_attr;
171
+ struct berval **c_vals;
172
+ int i;
173
+ int count;
174
+ VALUE vals;
175
+ #endif
139
176
 
140
177
  GET_LDAPENTRY_DATA (self, edata);
178
+ #if RUBY_VERSION_CODE < 190
179
+ c_attr = StringValueCStr (attr);
180
+
181
+ c_vals = ldap_get_values_len (edata->ldap, edata->msg, c_attr);
182
+ if (c_vals)
183
+ {
184
+ vals = rb_ary_new ();
185
+ count = ldap_count_values_len (c_vals);
186
+ for (i = 0; i < count; i++)
187
+ {
188
+ VALUE str;
189
+ str = rb_tainted_str_new (c_vals[i]->bv_val, c_vals[i]->bv_len);
190
+ rb_ary_push (vals, str);
191
+ }
192
+ ldap_value_free_len (c_vals);
193
+ }
194
+ else
195
+ {
196
+ vals = Qnil;
197
+ }
141
198
 
199
+ return vals;
200
+ #else
142
201
  return rb_hash_aref(edata->attr, attr);
202
+ #endif
143
203
  }
144
204
 
145
205
  /*
@@ -153,16 +213,41 @@ VALUE
153
213
  rb_ldap_entry_get_attributes (VALUE self)
154
214
  {
155
215
  RB_LDAPENTRY_DATA *edata;
216
+ #if RUBY_VERSION_CODE < 190
217
+ VALUE vals;
218
+ char *attr;
219
+ BerElement *ber = NULL;
220
+ #else
156
221
  VALUE attrs;
222
+ #endif
157
223
 
158
224
  GET_LDAPENTRY_DATA (self, edata);
159
225
 
226
+ #if RUBY_VERSION_CODE < 190
227
+ vals = rb_ary_new ();
228
+ for (attr = ldap_first_attribute (edata->ldap, edata->msg, &ber);
229
+ attr != NULL;
230
+ attr = ldap_next_attribute (edata->ldap, edata->msg, ber))
231
+ {
232
+ rb_ary_push (vals, rb_tainted_str_new2 (attr));
233
+ ldap_memfree(attr);
234
+ }
235
+
236
+ #if !defined(USE_OPENLDAP1)
237
+ if( ber != NULL ){
238
+ ber_free(ber, 0);
239
+ }
240
+ #endif
241
+
242
+ return vals;
243
+ #else
160
244
  attrs = rb_funcall(edata->attr, rb_intern("keys"), 0);
161
245
  if (TYPE(attrs) != T_ARRAY) {
162
246
  return Qnil;
163
247
  }
164
248
 
165
249
  return attrs;
250
+ #endif
166
251
  }
167
252
 
168
253
  /*
@@ -174,13 +259,33 @@ rb_ldap_entry_get_attributes (VALUE self)
174
259
  VALUE
175
260
  rb_ldap_entry_to_hash (VALUE self)
176
261
  {
262
+ #if RUBY_VERSION_CODE < 190
263
+ VALUE attrs = rb_ldap_entry_get_attributes (self);
264
+ VALUE hash = rb_hash_new ();
265
+ VALUE attr, vals;
266
+ int i;
267
+ #else
177
268
  RB_LDAPENTRY_DATA *edata;
178
269
  VALUE hash, dn_ary;
270
+ #endif
179
271
 
272
+ #if RUBY_VERSION_CODE < 190
273
+ Check_Type (attrs, T_ARRAY);
274
+ rb_hash_aset (hash, rb_tainted_str_new2 ("dn"),
275
+ rb_ary_new3 (1, rb_ldap_entry_get_dn (self)));
276
+ for (i = 0; i < RARRAY_LEN (attrs); i++)
277
+ {
278
+ attr = rb_ary_entry (attrs, i);
279
+ vals = rb_ldap_entry_get_values (self, attr);
280
+ rb_hash_aset (hash, attr, vals);
281
+ }
282
+ #else
180
283
  GET_LDAPENTRY_DATA (self, edata);
181
284
  hash = rb_hash_dup(edata->attr);
182
285
  dn_ary = rb_ary_new3(1, edata->dn);
183
286
  rb_hash_aset(hash, rb_tainted_str_new2("dn"), dn_ary);
287
+ #endif
288
+
184
289
  return hash;
185
290
  }
186
291
 
data/extconf.rb CHANGED
@@ -235,6 +235,7 @@ for l in [$libcrypto, $libssl, $libnsl, $libpthread, $libresolv,
235
235
  end
236
236
 
237
237
  have_func("ldap_init", 'ldap.h')
238
+ have_func('rb_hash_dup')
238
239
  have_func("ldap_set_option")
239
240
  have_func("ldap_get_option")
240
241
  have_func("ldap_start_tls_s") if $use_openldap2
@@ -260,12 +261,12 @@ $defs << "-DRUBY_VERSION_CODE=#{RUBY_VERSION.gsub(/\D/, '')}"
260
261
  create_makefile("ldap")
261
262
 
262
263
 
263
- $slapd = ldap_with_config("slapd") || File.join($ldap_dir,"libexec","slapd")
264
+ $slapd = ldap_with_config("slapd") || File.join("/usr","libexec","slapd")
264
265
  $schema_dir = ldap_with_config("schema-dir")
265
266
  if( !$schema_dir )
266
- $schema_dir = File.join($ldap_dir,"etc","openldap","schema")
267
+ $schema_dir = File.join("/etc","openldap","schema")
267
268
  if( !File.exist?($schema_dir) )
268
- $schema_dir = File.join($ldap_dir,"etc","openldap")
269
+ $schema_dir = File.join("/etc","openldap")
269
270
  end
270
271
  end
271
272
 
data/rbldap.h CHANGED
@@ -27,8 +27,8 @@
27
27
 
28
28
  #define RB_LDAP_MAJOR_VERSION 0
29
29
  #define RB_LDAP_MINOR_VERSION 9
30
- #define RB_LDAP_PATCH_VERSION 17
31
- #define RB_LDAP_VERSION "0.9.17"
30
+ #define RB_LDAP_PATCH_VERSION 18
31
+ #define RB_LDAP_VERSION "0.9.18"
32
32
 
33
33
  #define LDAP_GET_OPT_MAX_BUFFER_SIZE (1024) /* >= sizeof(LDAPAPIInfo) */
34
34
 
@@ -55,8 +55,10 @@ typedef struct rb_ldapentry_data
55
55
  {
56
56
  LDAP *ldap;
57
57
  LDAPMessage *msg;
58
+ #if RUBY_VERSION_CODE >= 190
58
59
  VALUE dn;
59
60
  VALUE attr;
61
+ #endif
60
62
  } RB_LDAPENTRY_DATA;
61
63
 
62
64
  typedef struct rb_ldapmod_data
@@ -171,9 +173,20 @@ VALUE rb_ldap_mod_vals (VALUE);
171
173
  }; \
172
174
  }
173
175
 
176
+ #if RUBY_VERSION_CODE < 190
174
177
  #define GET_LDAPENTRY_DATA(obj,ptr) { \
175
178
  Data_Get_Struct(obj, struct rb_ldapentry_data, ptr); \
179
+ if( ! ptr->msg ){ \
180
+ VALUE value = rb_inspect(obj); \
181
+ rb_raise(rb_eLDAP_InvalidEntryError, "%s is not a valid entry", \
182
+ StringValuePtr(value)); \
183
+ }; \
176
184
  }
185
+ #else
186
+ #define GET_LDAPENTRY_DATA(obj,ptr) { \
187
+ Data_Get_Struct(obj, struct rb_ldapentry_data, ptr); \
188
+ }
189
+ #endif
177
190
 
178
191
  #define GET_LDAPMOD_DATA(obj,ptr) {\
179
192
  Data_Get_Struct(obj, struct rb_ldapmod_data, ptr); \
@@ -1,9 +1,8 @@
1
1
  # -*- ruby -*-
2
2
  # This file is a part of test scripts of LDAP extension module.
3
3
 
4
- $test = File.dirname($0)
5
- require "#{$test}/conf"
6
- require "./ldap"
4
+ require './ldap'
5
+ require './test/conf'
7
6
 
8
7
  conn = LDAP::Conn.new($HOST, $PORT)
9
8
  conn.bind('cn=root, dc=localhost, dc=localdomain','secret'){
@@ -1,9 +1,8 @@
1
1
  # -*- ruby -*-
2
2
  # This file is a part of test scripts of LDAP extension module.
3
3
 
4
- $test = File.dirname($0)
5
- require "#{$test}/conf"
6
- require "./ldap"
4
+ require './ldap'
5
+ require './test/conf'
7
6
 
8
7
  conn = LDAP::Conn.new($HOST, $PORT)
9
8
  conn.bind('cn=root, dc=localhost, dc=localdomain','secret'){
@@ -1,9 +1,8 @@
1
1
  # -*- ruby -*-
2
2
  # This file is a part of test scripts of LDAP extension module.
3
3
 
4
- $test = File.dirname($0)
5
- require "#{$test}/conf"
6
- require "./ldap"
4
+ require './ldap'
5
+ require './test/conf'
7
6
 
8
7
  $KCODE = "UTF8"
9
8
 
@@ -1,15 +1,13 @@
1
1
  # -*- ruby -*-
2
2
  # This file is a part of test scripts of LDAP extension module.
3
3
 
4
- $test = File.dirname($0)
5
- require "#{$test}/conf"
6
- require "./ldap"
4
+ require './ldap'
5
+ require './test/conf'
7
6
 
8
7
  LDAP::Conn.new($HOST, $PORT).bind{|conn|
9
8
  conn.perror("bind")
10
9
  begin
11
- conn.compare("cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
12
- "cn", "Takaaki Tateishi")
10
+ conn.compare("cn=Takaaki Tateishi, dc=localhost, dc=localdomain", "cn", "Takaaki Tateishi")
13
11
  rescue LDAP::ResultError
14
12
  exit(0)
15
13
  end
@@ -1,7 +1,5 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require './ldap'
4
-
5
3
  $HOST = 'localhost'
6
4
  begin
7
5
  $PORT = ARGV[0].to_i || LDAP::LDAP_PORT
@@ -5,16 +5,18 @@ $test = File.dirname($0)
5
5
  require "#{$test}/conf"
6
6
  require "./ldap"
7
7
 
8
- LDAP::Conn.new($HOST, $PORT).bind{|conn|
8
+ LDAP::Conn.new($HOST, $PORT).bind do |conn|
9
9
  conn.perror("bind")
10
10
  begin
11
- conn.search("dc=localhost, dc=localdomain",
12
- LDAP::LDAP_SCOPE_SUBTREE,
13
- "(objectclass=*)"){|e|
11
+ conn.search(
12
+ "dc=localhost, dc=localdomain",
13
+ LDAP::LDAP_SCOPE_SUBTREE,
14
+ "(objectclass=*)"
15
+ ) do |e|
14
16
  p e.vals("cn")
15
17
  p e.to_hash()
16
- }
18
+ end
17
19
  rescue LDAP::ResultError => msg
18
20
  $stderr.print(msg)
19
21
  end
20
- }
22
+ end
metadata CHANGED
@@ -1,17 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.17
4
+ version: 0.9.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Chebotar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- It provides the interface to some LDAP libraries (e.g. OpenLDAP, Netscape SDK and Active Directory). The common API for application development is described in RFC1823 and is supported by Ruby/LDAP.
13
+ description: 'It provides the interface to some LDAP libraries (e.g. OpenLDAP, Netscape
14
+ SDK and Active Directory). The common API for application development is described
15
+ in RFC1823 and is supported by Ruby/LDAP.
16
+
17
+ '
15
18
  email: alexey.chebotar@gmail.com
16
19
  executables: []
17
20
  extensions:
@@ -84,9 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
87
  version: '0'
85
88
  requirements: []
86
89
  rubyforge_project: ruby-ldap
87
- rubygems_version: 2.4.5
90
+ rubygems_version: 2.5.1
88
91
  signing_key:
89
92
  specification_version: 4
90
93
  summary: Ruby/LDAP is an extension module for Ruby
91
94
  test_files: []
92
- has_rdoc: true