net-ldap 0.16.3 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.rdoc +59 -0
- data/README.rdoc +10 -3
- data/lib/net/ldap/connection.rb +18 -10
- data/lib/net/ldap/dataset.rb +0 -2
- data/lib/net/ldap/dn.rb +9 -17
- data/lib/net/ldap/entry.rb +11 -2
- data/lib/net/ldap/error.rb +1 -26
- data/lib/net/ldap/password.rb +4 -0
- data/lib/net/ldap/version.rb +1 -1
- data/lib/net/ldap.rb +28 -3
- metadata +17 -93
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -20
- data/.rubocop_todo.yml +0 -723
- data/.travis.yml +0 -57
- data/CONTRIBUTING.md +0 -54
- data/Gemfile +0 -2
- data/Rakefile +0 -23
- data/net-ldap.gemspec +0 -37
- data/script/changelog +0 -47
- data/script/ldap-docker +0 -12
- data/script/package +0 -7
- data/script/release +0 -16
- data/test/ber/core_ext/test_array.rb +0 -22
- data/test/ber/core_ext/test_string.rb +0 -25
- data/test/ber/test_ber.rb +0 -153
- data/test/fixtures/ca/docker-ca.pem +0 -18
- data/test/fixtures/ldif/06-retcode.ldif +0 -75
- data/test/fixtures/ldif/50-seed.ldif +0 -374
- data/test/integration/test_add.rb +0 -26
- data/test/integration/test_ber.rb +0 -30
- data/test/integration/test_bind.rb +0 -221
- data/test/integration/test_delete.rb +0 -29
- data/test/integration/test_open.rb +0 -87
- data/test/integration/test_password_modify.rb +0 -93
- data/test/integration/test_return_codes.rb +0 -46
- data/test/integration/test_search.rb +0 -77
- data/test/support/vm/openldap/.gitignore +0 -1
- data/test/test_auth_adapter.rb +0 -15
- data/test/test_dn.rb +0 -43
- data/test/test_entry.rb +0 -66
- data/test/test_filter.rb +0 -223
- data/test/test_filter_parser.rb +0 -29
- data/test/test_helper.rb +0 -73
- data/test/test_ldap.rb +0 -114
- data/test/test_ldap_connection.rb +0 -505
- data/test/test_ldif.rb +0 -104
- data/test/test_password.rb +0 -10
- data/test/test_rename.rb +0 -77
- data/test/test_search.rb +0 -39
- data/test/test_snmp.rb +0 -118
- data/test/test_ssl_ber.rb +0 -44
- data/test/testdata.ldif +0 -101
- data/testserver/ldapserver.rb +0 -200
- data/testserver/testdata.ldif +0 -101
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1fdcc1a3fefe3fb2bf1dbb91ec9e00734252fdda634ae0e2344b9dd6e6b86cd2
|
|
4
|
+
data.tar.gz: 8526bd506b632e74193c80119280fd4b333731b1e3d75791427a12e62cab775a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2f9e53240eeedd964463c6bc719cc86e57e5a66c5a769371e16d97005f9b63933797f33384e0192b6e128cc4fec1de46e3cca2886fce963439d86b4b3c0665f
|
|
7
|
+
data.tar.gz: e4af635dce612600ba48a110ebae1d3c30c00f9c5adcfeba1b6eca1d4d760646674d399cac256f96490bcad6d884146cb891ac14d57f8734556ed7e331baac90
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
=== Net::LDAP 0.19.0
|
|
2
|
+
* Net::LDAP::DN - Retain trailing spaces in RDN values in DNs #412
|
|
3
|
+
* Add in ability for users to specify LDAP controls when conducting searches #411
|
|
4
|
+
* Document connect_timeout in Constructor Details #415
|
|
5
|
+
* Fix openssl error when using multiple hosts #417
|
|
6
|
+
|
|
7
|
+
=== Net::LDAP 0.18.0
|
|
8
|
+
* Fix escaping of # and space in attrs #408
|
|
9
|
+
* Add support to use SNI #406
|
|
10
|
+
* Drop Ruby 2.5 and JRuby 9.2 from CI tests
|
|
11
|
+
* Bump rubocop to 1.48.1
|
|
12
|
+
* Update CI for TruffleRuby 22
|
|
13
|
+
|
|
14
|
+
=== Net::LDAP 0.17.1
|
|
15
|
+
* Fixed shebang of bash #385
|
|
16
|
+
* Omit some tests for now until we update our CA cert #386
|
|
17
|
+
* Add Ruby 3.0 support #388
|
|
18
|
+
* Add TruffleRuby 21.0.0 to CI #389
|
|
19
|
+
* Correct a typo in an error message #391
|
|
20
|
+
* Enable bundler caching for travis #390
|
|
21
|
+
* Fix circular require while loading lib/net/ldap/entry.rb and lib/net/ldap/dataset.rb #392
|
|
22
|
+
* Handle nil value in GetbyteForSSLSocket::getbyte #306
|
|
23
|
+
|
|
24
|
+
=== Net::LDAP 0.17.0
|
|
25
|
+
* Added private recursive_delete as alternative to DELETE_TREE #268
|
|
26
|
+
* Test suite updates #373 #376 #377
|
|
27
|
+
* Use Base64.strict_encode64 and SSHA256 #303
|
|
28
|
+
* Remove deprecated ConnectionRefusedError #366
|
|
29
|
+
* Added method to get a duplicate of the internal Hash #286
|
|
30
|
+
* remove a circular require #380
|
|
31
|
+
* fix LdapServerAsnSyntax compile #379
|
|
32
|
+
* Implement '==' operator for entries #381
|
|
33
|
+
* fix for undefined method for write exception #383
|
|
34
|
+
|
|
35
|
+
=== Net::LDAP 0.16.3
|
|
36
|
+
|
|
37
|
+
* Add Net::LDAP::InvalidDNError #371
|
|
38
|
+
* Use require_relative instead of require #360
|
|
39
|
+
* Address some warnings and fix JRuby test omissions #365
|
|
40
|
+
* Bump rake dev dependency to 12.3 #359
|
|
41
|
+
* Enable rubocop in ci #251
|
|
42
|
+
* Enhance rubocop configuration and test syntax #344
|
|
43
|
+
* CI: Drop rbx-2, uninstallable #364
|
|
44
|
+
* Fix RuboCop warnings #312
|
|
45
|
+
* Fix wrong error class #305
|
|
46
|
+
* CONTRIBUTING.md: Repair link to Issues #309
|
|
47
|
+
* Make the generate() method more idiomatic... #326
|
|
48
|
+
* Make encode_sort_controls() more idiomatic... #327
|
|
49
|
+
* Make the instrument() method more idiomatic... #328
|
|
50
|
+
* Fix uninitialised Net::LDAP::LdapPduError #338
|
|
51
|
+
* README.rdoc: Use SVG build badge #310
|
|
52
|
+
* Update TravisCI config to inclue Ruby 2.7 #346
|
|
53
|
+
* add explicit ** to silence Ruby 2.7 warning #342
|
|
54
|
+
* Support parsing filters with attribute tags #345
|
|
55
|
+
* Bump rubocop development dependency version #336
|
|
56
|
+
* Add link to generated and hosted documentation on rubydoc #319
|
|
57
|
+
* Fix 'uninitialized constant Net::LDAP::PDU::LdapPduError' error #317
|
|
58
|
+
* simplify encoding logic: no more chomping required #362
|
|
59
|
+
|
|
1
60
|
=== Net::LDAP 0.16.2
|
|
2
61
|
|
|
3
62
|
* Net::LDAP#open does not cache bind result {#334}[https://github.com/ruby-ldap/ruby-net-ldap/pull/334]
|
data/README.rdoc
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
= Net::LDAP for Ruby
|
|
1
|
+
= Net::LDAP for Ruby
|
|
2
|
+
{<img src="https://badge.fury.io/rb/net-ldap.svg" alt="Gem Version" />}[https://badge.fury.io/rb/net-ldap]
|
|
3
|
+
{<img src="https://travis-ci.org/ruby-ldap/ruby-net-ldap.svg" />}[https://travis-ci.org/ruby-ldap/ruby-net-ldap]
|
|
2
4
|
|
|
3
5
|
== Description
|
|
4
6
|
|
|
@@ -21,7 +23,7 @@ the most recent LDAP RFCs (4510–4519, plus portions of 4520–4532).
|
|
|
21
23
|
|
|
22
24
|
== Synopsis
|
|
23
25
|
|
|
24
|
-
See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/
|
|
26
|
+
See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/github/ruby-ldap/ruby-net-ldap] for documentation and usage samples.
|
|
25
27
|
|
|
26
28
|
== Requirements
|
|
27
29
|
|
|
@@ -58,16 +60,21 @@ Simply run:
|
|
|
58
60
|
|
|
59
61
|
script/ldap-docker
|
|
60
62
|
INTEGRATION=openldap rake test
|
|
63
|
+
|
|
64
|
+
Or, use {Docker Compose}[https://docs.docker.com/compose/]. See docker-compose.yml for available Ruby versions.
|
|
65
|
+
|
|
66
|
+
docker-compose run ci-2.7
|
|
61
67
|
|
|
62
68
|
CAVEAT: you need to add the following line to /etc/hosts
|
|
63
69
|
127.0.0.1 ldap.example.org
|
|
70
|
+
127.0.0.1 cert.mismatch.example.org
|
|
64
71
|
|
|
65
72
|
== Release
|
|
66
73
|
|
|
67
74
|
This section is for gem maintainers to cut a new version of the gem.
|
|
68
75
|
|
|
69
76
|
* Check out a new branch `release-VERSION`
|
|
70
|
-
* Update lib/net/ldap/version.rb to next version number X.X.X following {semver}
|
|
77
|
+
* Update lib/net/ldap/version.rb to next version number X.X.X following {semver}[http://semver.org/].
|
|
71
78
|
* Update `History.rdoc`. Get latest changes with `script/changelog`
|
|
72
79
|
* Open a pull request with these changes for review
|
|
73
80
|
* After merging, on the master branch, run `script/release`
|
data/lib/net/ldap/connection.rb
CHANGED
|
@@ -30,12 +30,12 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
30
30
|
@socket_class = socket_class
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def prepare_socket(server, timeout=nil)
|
|
33
|
+
def prepare_socket(server, timeout=nil, hostname='127.0.0.1')
|
|
34
34
|
socket = server[:socket]
|
|
35
35
|
encryption = server[:encryption]
|
|
36
36
|
|
|
37
37
|
@conn = socket
|
|
38
|
-
setup_encryption(encryption, timeout) if encryption
|
|
38
|
+
setup_encryption(encryption, timeout, hostname) if encryption
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def open_connection(server)
|
|
@@ -50,7 +50,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
50
50
|
errors = []
|
|
51
51
|
hosts.each do |host, port|
|
|
52
52
|
begin
|
|
53
|
-
prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout)
|
|
53
|
+
prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout, host)
|
|
54
54
|
if encryption
|
|
55
55
|
if encryption[:tls_options] &&
|
|
56
56
|
encryption[:tls_options][:verify_mode] &&
|
|
@@ -74,7 +74,8 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
74
74
|
|
|
75
75
|
module GetbyteForSSLSocket
|
|
76
76
|
def getbyte
|
|
77
|
-
getc
|
|
77
|
+
c = getc
|
|
78
|
+
c && c.ord
|
|
78
79
|
end
|
|
79
80
|
end
|
|
80
81
|
|
|
@@ -85,7 +86,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
85
86
|
end
|
|
86
87
|
end
|
|
87
88
|
|
|
88
|
-
def self.wrap_with_ssl(io, tls_options = {}, timeout=nil)
|
|
89
|
+
def self.wrap_with_ssl(io, tls_options = {}, timeout=nil, hostname=nil)
|
|
89
90
|
raise Net::LDAP::NoOpenSSLError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
|
|
90
91
|
|
|
91
92
|
ctx = OpenSSL::SSL::SSLContext.new
|
|
@@ -95,6 +96,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
95
96
|
ctx.set_params(tls_options) unless tls_options.empty?
|
|
96
97
|
|
|
97
98
|
conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
|
|
99
|
+
conn.hostname = hostname
|
|
98
100
|
|
|
99
101
|
begin
|
|
100
102
|
if timeout
|
|
@@ -147,11 +149,11 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
147
149
|
# communications, as with simple_tls. Thanks for Kouhei Sutou for
|
|
148
150
|
# generously contributing the :start_tls path.
|
|
149
151
|
#++
|
|
150
|
-
def setup_encryption(args, timeout=nil)
|
|
152
|
+
def setup_encryption(args, timeout=nil, hostname=nil)
|
|
151
153
|
args[:tls_options] ||= {}
|
|
152
154
|
case args[:method]
|
|
153
155
|
when :simple_tls
|
|
154
|
-
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout)
|
|
156
|
+
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout, hostname)
|
|
155
157
|
# additional branches requiring server validation and peer certs, etc.
|
|
156
158
|
# go here.
|
|
157
159
|
when :start_tls
|
|
@@ -169,7 +171,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
169
171
|
|
|
170
172
|
raise Net::LDAP::StartTLSError,
|
|
171
173
|
"start_tls failed: #{pdu.result_code}" unless pdu.result_code.zero?
|
|
172
|
-
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout)
|
|
174
|
+
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout, hostname)
|
|
173
175
|
else
|
|
174
176
|
raise Net::LDAP::EncMethodUnsupportedError, "unsupported encryption method #{args[:method]}"
|
|
175
177
|
end
|
|
@@ -422,6 +424,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
422
424
|
# this breaks when calling to_ber. (Can't force binary data to UTF-8)
|
|
423
425
|
# we have to disable paging (even though server supports it) to get around this...
|
|
424
426
|
|
|
427
|
+
user_controls = args.fetch(:controls, [])
|
|
425
428
|
controls = []
|
|
426
429
|
controls <<
|
|
427
430
|
[
|
|
@@ -431,7 +434,12 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
431
434
|
rfc2696_cookie.map(&:to_ber).to_ber_sequence.to_s.to_ber,
|
|
432
435
|
].to_ber_sequence if paged
|
|
433
436
|
controls << ber_sort if ber_sort
|
|
434
|
-
|
|
437
|
+
if controls.empty? && user_controls.empty?
|
|
438
|
+
controls = nil
|
|
439
|
+
else
|
|
440
|
+
controls += user_controls
|
|
441
|
+
controls = controls.to_ber_contextspecific(0)
|
|
442
|
+
end
|
|
435
443
|
|
|
436
444
|
write(request, controls, message_id)
|
|
437
445
|
|
|
@@ -690,7 +698,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
|
690
698
|
#
|
|
691
699
|
# Typically a TCPSocket, but can be a OpenSSL::SSL::SSLSocket
|
|
692
700
|
def socket
|
|
693
|
-
return @conn if defined?
|
|
701
|
+
return @conn if defined?(@conn) && !@conn.nil?
|
|
694
702
|
|
|
695
703
|
# First refactoring uses the existing methods open_connection and
|
|
696
704
|
# prepare_socket to set @conn. Next cleanup would centralize connection
|
data/lib/net/ldap/dataset.rb
CHANGED
data/lib/net/ldap/dn.rb
CHANGED
|
@@ -81,7 +81,7 @@ class Net::LDAP::DN
|
|
|
81
81
|
value << char
|
|
82
82
|
when ',' then
|
|
83
83
|
state = :key
|
|
84
|
-
yield key.string.strip, value.string
|
|
84
|
+
yield key.string.strip, value.string
|
|
85
85
|
key = StringIO.new
|
|
86
86
|
value = StringIO.new;
|
|
87
87
|
else
|
|
@@ -93,7 +93,7 @@ class Net::LDAP::DN
|
|
|
93
93
|
when '\\' then state = :value_normal_escape
|
|
94
94
|
when ',' then
|
|
95
95
|
state = :key
|
|
96
|
-
yield key.string.strip, value.string
|
|
96
|
+
yield key.string.strip, value.string
|
|
97
97
|
key = StringIO.new
|
|
98
98
|
value = StringIO.new;
|
|
99
99
|
else value << char
|
|
@@ -142,7 +142,7 @@ class Net::LDAP::DN
|
|
|
142
142
|
when ' ' then state = :value_end
|
|
143
143
|
when ',' then
|
|
144
144
|
state = :key
|
|
145
|
-
yield key.string.strip, value.string
|
|
145
|
+
yield key.string.strip, value.string
|
|
146
146
|
key = StringIO.new
|
|
147
147
|
value = StringIO.new;
|
|
148
148
|
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
|
@@ -159,7 +159,7 @@ class Net::LDAP::DN
|
|
|
159
159
|
when ' ' then state = :value_end
|
|
160
160
|
when ',' then
|
|
161
161
|
state = :key
|
|
162
|
-
yield key.string.strip, value.string
|
|
162
|
+
yield key.string.strip, value.string
|
|
163
163
|
key = StringIO.new
|
|
164
164
|
value = StringIO.new;
|
|
165
165
|
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
|
@@ -172,7 +172,7 @@ class Net::LDAP::DN
|
|
|
172
172
|
raise Net::LDAP::InvalidDNError, "DN badly formed" unless
|
|
173
173
|
[:value, :value_normal, :value_hexstring, :value_end].include? state
|
|
174
174
|
|
|
175
|
-
yield key.string.strip, value.string
|
|
175
|
+
yield key.string.strip, value.string
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
##
|
|
@@ -192,27 +192,19 @@ class Net::LDAP::DN
|
|
|
192
192
|
# http://tools.ietf.org/html/rfc2253 section 2.4 lists these exceptions
|
|
193
193
|
# for dn values. All of the following must be escaped in any normal string
|
|
194
194
|
# using a single backslash ('\') as escape.
|
|
195
|
-
ESCAPES =
|
|
196
|
-
',' => ',',
|
|
197
|
-
'+' => '+',
|
|
198
|
-
'"' => '"',
|
|
199
|
-
'\\' => '\\',
|
|
200
|
-
'<' => '<',
|
|
201
|
-
'>' => '>',
|
|
202
|
-
';' => ';',
|
|
203
|
-
}
|
|
195
|
+
ESCAPES = %w[, + " \\ < > ;]
|
|
204
196
|
|
|
205
|
-
# Compiled character class regexp using the
|
|
197
|
+
# Compiled character class regexp using the values from the above list, and
|
|
206
198
|
# checking for a space or # at the start, or space at the end, of the
|
|
207
199
|
# string.
|
|
208
200
|
ESCAPE_RE = Regexp.new("(^ |^#| $|[" +
|
|
209
|
-
ESCAPES.
|
|
201
|
+
ESCAPES.map { |e| Regexp.escape(e) }.join +
|
|
210
202
|
"])")
|
|
211
203
|
|
|
212
204
|
##
|
|
213
205
|
# Escape a string for use in a DN value
|
|
214
206
|
def self.escape(string)
|
|
215
|
-
string.gsub(ESCAPE_RE) { |char| "\\" +
|
|
207
|
+
string.gsub(ESCAPE_RE) { |char| "\\" + char }
|
|
216
208
|
end
|
|
217
209
|
|
|
218
210
|
##
|
data/lib/net/ldap/entry.rb
CHANGED
|
@@ -133,6 +133,13 @@ class Net::LDAP::Entry
|
|
|
133
133
|
@myhash.keys
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
+
##
|
|
137
|
+
# Creates a duplicate of the internal Hash containing the attributes
|
|
138
|
+
# of the entry.
|
|
139
|
+
def to_h
|
|
140
|
+
@myhash.dup
|
|
141
|
+
end
|
|
142
|
+
|
|
136
143
|
##
|
|
137
144
|
# Accesses each of the attributes present in the Entry.
|
|
138
145
|
#
|
|
@@ -187,6 +194,8 @@ class Net::LDAP::Entry
|
|
|
187
194
|
sym.to_s[-1] == ?=
|
|
188
195
|
end
|
|
189
196
|
private :setter?
|
|
190
|
-
end # class Entry
|
|
191
197
|
|
|
192
|
-
|
|
198
|
+
def ==(other)
|
|
199
|
+
other.instance_of?(self.class) && @myhash == other.to_h
|
|
200
|
+
end
|
|
201
|
+
end # class Entry
|
data/lib/net/ldap/error.rb
CHANGED
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
class Net::LDAP
|
|
2
|
-
class LdapError < StandardError
|
|
3
|
-
def message
|
|
4
|
-
"Deprecation warning: Net::LDAP::LdapError is no longer used. Use Net::LDAP::Error or rescue one of it's subclasses. \n" + super
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
2
|
class Error < StandardError; end
|
|
9
3
|
|
|
10
4
|
class AlreadyOpenedError < Error; end
|
|
11
5
|
class SocketError < Error; end
|
|
12
|
-
class ConnectionRefusedError < Error;
|
|
13
|
-
def initialize(*args)
|
|
14
|
-
warn_deprecation_message
|
|
15
|
-
super
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def message
|
|
19
|
-
warn_deprecation_message
|
|
20
|
-
super
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def warn_deprecation_message
|
|
26
|
-
warn "Deprecation warning: Net::LDAP::ConnectionRefused will be deprecated. Use Errno::ECONNREFUSED instead."
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
6
|
class ConnectionError < Error
|
|
30
7
|
def self.new(errors)
|
|
31
8
|
error = errors.first.first
|
|
32
9
|
if errors.size == 1
|
|
33
|
-
if error.
|
|
34
|
-
return Net::LDAP::ConnectionRefusedError.new(error.message)
|
|
35
|
-
end
|
|
10
|
+
return error if error.is_a? Errno::ECONNREFUSED
|
|
36
11
|
|
|
37
12
|
return Net::LDAP::Error.new(error.message)
|
|
38
13
|
end
|
data/lib/net/ldap/password.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
require 'digest/sha1'
|
|
3
|
+
require 'digest/sha2'
|
|
3
4
|
require 'digest/md5'
|
|
4
5
|
require 'base64'
|
|
5
6
|
require 'securerandom'
|
|
@@ -28,6 +29,9 @@ class Net::LDAP::Password
|
|
|
28
29
|
when :ssha
|
|
29
30
|
salt = SecureRandom.random_bytes(16)
|
|
30
31
|
'{SSHA}' + Base64.strict_encode64(Digest::SHA1.digest(str + salt) + salt)
|
|
32
|
+
when :ssha256
|
|
33
|
+
salt = SecureRandom.random_bytes(16)
|
|
34
|
+
'{SSHA256}' + Base64.strict_encode64(Digest::SHA256.digest(str + salt) + salt)
|
|
31
35
|
else
|
|
32
36
|
raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})"
|
|
33
37
|
end
|
data/lib/net/ldap/version.rb
CHANGED
data/lib/net/ldap.rb
CHANGED
|
@@ -412,7 +412,7 @@ class Net::LDAP
|
|
|
412
412
|
ResultCodeStrongerAuthRequired => "Stronger Auth Needed",
|
|
413
413
|
ResultCodeReferral => "Referral",
|
|
414
414
|
ResultCodeAdminLimitExceeded => "Admin Limit Exceeded",
|
|
415
|
-
ResultCodeUnavailableCriticalExtension => "Unavailable
|
|
415
|
+
ResultCodeUnavailableCriticalExtension => "Unavailable critical extension",
|
|
416
416
|
ResultCodeConfidentialityRequired => "Confidentiality Required",
|
|
417
417
|
ResultCodeSaslBindInProgress => "saslBindInProgress",
|
|
418
418
|
ResultCodeNoSuchAttribute => "No Such Attribute",
|
|
@@ -480,6 +480,8 @@ class Net::LDAP
|
|
|
480
480
|
# server says it supports them. This is a fix for MS Active Directory
|
|
481
481
|
# * :instrumentation_service => An object responsible for instrumenting
|
|
482
482
|
# operations, compatible with ActiveSupport::Notifications' public API.
|
|
483
|
+
# * :connect_timeout => The TCP socket timeout (in seconds) to use when
|
|
484
|
+
# connecting to the LDAP server (default 5 seconds).
|
|
483
485
|
# * :encryption => specifies the encryption to be used in communicating
|
|
484
486
|
# with the LDAP server. The value must be a Hash containing additional
|
|
485
487
|
# parameters, which consists of two keys:
|
|
@@ -1182,14 +1184,22 @@ class Net::LDAP
|
|
|
1182
1184
|
# entries. This method sends an extra control code to tell the LDAP server
|
|
1183
1185
|
# to do a tree delete. ('1.2.840.113556.1.4.805')
|
|
1184
1186
|
#
|
|
1187
|
+
# If the LDAP server does not support the DELETE_TREE control code, subordinate
|
|
1188
|
+
# entries are deleted recursively instead.
|
|
1189
|
+
#
|
|
1185
1190
|
# Returns True or False to indicate whether the delete succeeded. Extended
|
|
1186
1191
|
# status information is available by calling #get_operation_result.
|
|
1187
1192
|
#
|
|
1188
1193
|
# dn = "mail=deleteme@example.com, ou=people, dc=example, dc=com"
|
|
1189
1194
|
# ldap.delete_tree :dn => dn
|
|
1190
1195
|
def delete_tree(args)
|
|
1191
|
-
|
|
1196
|
+
if search_root_dse[:supportedcontrol].include? Net::LDAP::LDAPControls::DELETE_TREE
|
|
1197
|
+
delete(args.merge(:control_codes => [[Net::LDAP::LDAPControls::DELETE_TREE, true]]))
|
|
1198
|
+
else
|
|
1199
|
+
recursive_delete(args)
|
|
1200
|
+
end
|
|
1192
1201
|
end
|
|
1202
|
+
|
|
1193
1203
|
# This method is experimental and subject to change. Return the rootDSE
|
|
1194
1204
|
# record from the LDAP server as a Net::LDAP::Entry, or an empty Entry if
|
|
1195
1205
|
# the server doesn't return the record.
|
|
@@ -1320,7 +1330,7 @@ class Net::LDAP
|
|
|
1320
1330
|
# Force connect to see if there's a connection error
|
|
1321
1331
|
connection.socket
|
|
1322
1332
|
connection
|
|
1323
|
-
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT
|
|
1333
|
+
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
|
|
1324
1334
|
@result = {
|
|
1325
1335
|
:resultCode => 52,
|
|
1326
1336
|
:errorMessage => ResultStrings[ResultCodeUnavailable],
|
|
@@ -1340,4 +1350,19 @@ class Net::LDAP
|
|
|
1340
1350
|
end
|
|
1341
1351
|
end
|
|
1342
1352
|
|
|
1353
|
+
# Recursively delete a dn and it's subordinate children.
|
|
1354
|
+
# This is useful when a server does not support the DELETE_TREE control code.
|
|
1355
|
+
def recursive_delete(args)
|
|
1356
|
+
raise EmptyDNError unless args.is_a?(Hash) && args.key?(:dn)
|
|
1357
|
+
# Delete Children
|
|
1358
|
+
search(base: args[:dn], scope: Net::LDAP::SearchScope_SingleLevel) do |entry|
|
|
1359
|
+
recursive_delete(dn: entry.dn)
|
|
1360
|
+
end
|
|
1361
|
+
# Delete Self
|
|
1362
|
+
unless delete(dn: args[:dn])
|
|
1363
|
+
raise Net::LDAP::Error, get_operation_result[:error_message].to_s
|
|
1364
|
+
end
|
|
1365
|
+
true
|
|
1366
|
+
end
|
|
1367
|
+
|
|
1343
1368
|
end # class LDAP
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: net-ldap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.19.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Francis Cianfrocca
|
|
@@ -10,10 +10,10 @@ authors:
|
|
|
10
10
|
- Kaspar Schiess
|
|
11
11
|
- Austin Ziegler
|
|
12
12
|
- Michael Schaarschmidt
|
|
13
|
-
autorequire:
|
|
13
|
+
autorequire:
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
|
-
date:
|
|
16
|
+
date: 2024-01-03 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: flexmock
|
|
@@ -49,42 +49,42 @@ dependencies:
|
|
|
49
49
|
requirements:
|
|
50
50
|
- - "~>"
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version:
|
|
52
|
+
version: '1.48'
|
|
53
53
|
type: :development
|
|
54
54
|
prerelease: false
|
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version:
|
|
59
|
+
version: '1.48'
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
61
|
name: test-unit
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
|
-
- - "
|
|
64
|
+
- - "~>"
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '
|
|
66
|
+
version: '3.3'
|
|
67
67
|
type: :development
|
|
68
68
|
prerelease: false
|
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
|
-
- - "
|
|
71
|
+
- - "~>"
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '
|
|
73
|
+
version: '3.3'
|
|
74
74
|
- !ruby/object:Gem::Dependency
|
|
75
75
|
name: byebug
|
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
|
77
77
|
requirements:
|
|
78
|
-
- - "
|
|
78
|
+
- - "~>"
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
|
-
version:
|
|
80
|
+
version: 9.0.6
|
|
81
81
|
type: :development
|
|
82
82
|
prerelease: false
|
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
|
85
|
-
- - "
|
|
85
|
+
- - "~>"
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version:
|
|
87
|
+
version: 9.0.6
|
|
88
88
|
description: |-
|
|
89
89
|
Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
|
90
90
|
Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
|
|
@@ -112,18 +112,11 @@ extra_rdoc_files:
|
|
|
112
112
|
- License.rdoc
|
|
113
113
|
- README.rdoc
|
|
114
114
|
files:
|
|
115
|
-
- ".gitignore"
|
|
116
|
-
- ".rubocop.yml"
|
|
117
|
-
- ".rubocop_todo.yml"
|
|
118
|
-
- ".travis.yml"
|
|
119
|
-
- CONTRIBUTING.md
|
|
120
115
|
- Contributors.rdoc
|
|
121
|
-
- Gemfile
|
|
122
116
|
- Hacking.rdoc
|
|
123
117
|
- History.rdoc
|
|
124
118
|
- License.rdoc
|
|
125
119
|
- README.rdoc
|
|
126
|
-
- Rakefile
|
|
127
120
|
- lib/net-ldap.rb
|
|
128
121
|
- lib/net/ber.rb
|
|
129
122
|
- lib/net/ber/ber_parser.rb
|
|
@@ -149,48 +142,11 @@ files:
|
|
|
149
142
|
- lib/net/ldap/pdu.rb
|
|
150
143
|
- lib/net/ldap/version.rb
|
|
151
144
|
- lib/net/snmp.rb
|
|
152
|
-
- net-ldap.gemspec
|
|
153
|
-
- script/changelog
|
|
154
|
-
- script/ldap-docker
|
|
155
|
-
- script/package
|
|
156
|
-
- script/release
|
|
157
|
-
- test/ber/core_ext/test_array.rb
|
|
158
|
-
- test/ber/core_ext/test_string.rb
|
|
159
|
-
- test/ber/test_ber.rb
|
|
160
|
-
- test/fixtures/ca/docker-ca.pem
|
|
161
|
-
- test/fixtures/ldif/06-retcode.ldif
|
|
162
|
-
- test/fixtures/ldif/50-seed.ldif
|
|
163
|
-
- test/integration/test_add.rb
|
|
164
|
-
- test/integration/test_ber.rb
|
|
165
|
-
- test/integration/test_bind.rb
|
|
166
|
-
- test/integration/test_delete.rb
|
|
167
|
-
- test/integration/test_open.rb
|
|
168
|
-
- test/integration/test_password_modify.rb
|
|
169
|
-
- test/integration/test_return_codes.rb
|
|
170
|
-
- test/integration/test_search.rb
|
|
171
|
-
- test/support/vm/openldap/.gitignore
|
|
172
|
-
- test/test_auth_adapter.rb
|
|
173
|
-
- test/test_dn.rb
|
|
174
|
-
- test/test_entry.rb
|
|
175
|
-
- test/test_filter.rb
|
|
176
|
-
- test/test_filter_parser.rb
|
|
177
|
-
- test/test_helper.rb
|
|
178
|
-
- test/test_ldap.rb
|
|
179
|
-
- test/test_ldap_connection.rb
|
|
180
|
-
- test/test_ldif.rb
|
|
181
|
-
- test/test_password.rb
|
|
182
|
-
- test/test_rename.rb
|
|
183
|
-
- test/test_search.rb
|
|
184
|
-
- test/test_snmp.rb
|
|
185
|
-
- test/test_ssl_ber.rb
|
|
186
|
-
- test/testdata.ldif
|
|
187
|
-
- testserver/ldapserver.rb
|
|
188
|
-
- testserver/testdata.ldif
|
|
189
145
|
homepage: http://github.com/ruby-ldap/ruby-net-ldap
|
|
190
146
|
licenses:
|
|
191
147
|
- MIT
|
|
192
148
|
metadata: {}
|
|
193
|
-
post_install_message:
|
|
149
|
+
post_install_message:
|
|
194
150
|
rdoc_options:
|
|
195
151
|
- "--main"
|
|
196
152
|
- README.rdoc
|
|
@@ -207,42 +163,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
207
163
|
- !ruby/object:Gem::Version
|
|
208
164
|
version: '0'
|
|
209
165
|
requirements: []
|
|
210
|
-
rubygems_version: 3.
|
|
211
|
-
signing_key:
|
|
166
|
+
rubygems_version: 3.4.14
|
|
167
|
+
signing_key:
|
|
212
168
|
specification_version: 4
|
|
213
169
|
summary: Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
|
214
170
|
Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing
|
|
215
171
|
distributed directory services
|
|
216
|
-
test_files:
|
|
217
|
-
- test/ber/core_ext/test_array.rb
|
|
218
|
-
- test/ber/core_ext/test_string.rb
|
|
219
|
-
- test/ber/test_ber.rb
|
|
220
|
-
- test/fixtures/ca/docker-ca.pem
|
|
221
|
-
- test/fixtures/ldif/06-retcode.ldif
|
|
222
|
-
- test/fixtures/ldif/50-seed.ldif
|
|
223
|
-
- test/integration/test_add.rb
|
|
224
|
-
- test/integration/test_ber.rb
|
|
225
|
-
- test/integration/test_bind.rb
|
|
226
|
-
- test/integration/test_delete.rb
|
|
227
|
-
- test/integration/test_open.rb
|
|
228
|
-
- test/integration/test_password_modify.rb
|
|
229
|
-
- test/integration/test_return_codes.rb
|
|
230
|
-
- test/integration/test_search.rb
|
|
231
|
-
- test/support/vm/openldap/.gitignore
|
|
232
|
-
- test/test_auth_adapter.rb
|
|
233
|
-
- test/test_dn.rb
|
|
234
|
-
- test/test_entry.rb
|
|
235
|
-
- test/test_filter.rb
|
|
236
|
-
- test/test_filter_parser.rb
|
|
237
|
-
- test/test_helper.rb
|
|
238
|
-
- test/test_ldap.rb
|
|
239
|
-
- test/test_ldap_connection.rb
|
|
240
|
-
- test/test_ldif.rb
|
|
241
|
-
- test/test_password.rb
|
|
242
|
-
- test/test_rename.rb
|
|
243
|
-
- test/test_search.rb
|
|
244
|
-
- test/test_snmp.rb
|
|
245
|
-
- test/test_ssl_ber.rb
|
|
246
|
-
- test/testdata.ldif
|
|
247
|
-
- testserver/ldapserver.rb
|
|
248
|
-
- testserver/testdata.ldif
|
|
172
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
|
2
|
-
|
|
3
|
-
AllCops:
|
|
4
|
-
Exclude:
|
|
5
|
-
- 'pkg/**/*'
|
|
6
|
-
|
|
7
|
-
Layout/ExtraSpacing:
|
|
8
|
-
Enabled: false
|
|
9
|
-
|
|
10
|
-
Lint/AssignmentInCondition:
|
|
11
|
-
Enabled: false
|
|
12
|
-
|
|
13
|
-
Style/ParallelAssignment:
|
|
14
|
-
Enabled: false
|
|
15
|
-
|
|
16
|
-
Style/TrailingCommaInLiteral:
|
|
17
|
-
EnforcedStyleForMultiline: comma
|
|
18
|
-
|
|
19
|
-
Style/TrailingCommaInArguments:
|
|
20
|
-
EnforcedStyleForMultiline: comma
|