net-ldap 0.16.2 → 0.17.1
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 +46 -0
- data/README.rdoc +10 -3
- data/lib/net/ber/core_ext.rb +6 -6
- data/lib/net/ber.rb +2 -2
- data/lib/net/ldap/auth_adapter/gss_spnego.rb +2 -2
- data/lib/net/ldap/auth_adapter/sasl.rb +1 -1
- data/lib/net/ldap/auth_adapter/simple.rb +1 -1
- data/lib/net/ldap/connection.rb +7 -6
- data/lib/net/ldap/dataset.rb +1 -3
- data/lib/net/ldap/dn.rb +10 -10
- data/lib/net/ldap/entry.rb +11 -2
- data/lib/net/ldap/error.rb +2 -26
- data/lib/net/ldap/filter.rb +3 -3
- data/lib/net/ldap/instrumentation.rb +2 -2
- data/lib/net/ldap/password.rb +7 -5
- data/lib/net/ldap/pdu.rb +1 -1
- data/lib/net/ldap/version.rb +1 -1
- data/lib/net/ldap.rb +39 -16
- data/lib/net/snmp.rb +1 -1
- data/lib/net-ldap.rb +1 -1
- metadata +19 -95
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -20
- data/.rubocop_todo.yml +0 -753
- data/.travis.yml +0 -55
- 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 -222
- 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 -44
- data/test/test_entry.rb +0 -65
- data/test/test_filter.rb +0 -223
- data/test/test_filter_parser.rb +0 -24
- data/test/test_helper.rb +0 -73
- data/test/test_ldap.rb +0 -114
- data/test/test_ldap_connection.rb +0 -491
- 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 -119
- data/test/test_ssl_ber.rb +0 -40
- data/test/testdata.ldif +0 -101
- data/testserver/ldapserver.rb +0 -209
- 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: 55f2964276a686be8ca816c32c499383b0085f0f20c9af76fb039ce0df9bc3c0
|
4
|
+
data.tar.gz: fd9caa7e812f4de283cc07aefc56707f47215924a50f524beda08b72cc7bd9a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 827e26be88d21d2a46b4912cf77c86cd523e3267cf7a6db62eb2a841ef655dd885a979f79479895a65eabe37e54d980b7abb16d134c7c73b4cf73ade9a7c01b6
|
7
|
+
data.tar.gz: a796f5aebdf10570f0b762b603bcc9668a8a5b6a592866dc8af4e19ec92e01fb0def0c4e3d2199955b68ead95ec3cd09d2602ac2e27bfa02fc292bfe284486b6
|
data/History.rdoc
CHANGED
@@ -1,3 +1,49 @@
|
|
1
|
+
=== Net::LDAP 0.17.1
|
2
|
+
* Fixed shebang of bash #385
|
3
|
+
* Omit some tests for now until we update our CA cert #386
|
4
|
+
* Add Ruby 3.0 support #388
|
5
|
+
* Add TruffleRuby 21.0.0 to CI #389
|
6
|
+
* Correct a typo in an error message #391
|
7
|
+
* Enable bundler caching for travis #390
|
8
|
+
* Fix circular require while loading lib/net/ldap/entry.rb and lib/net/ldap/dataset.rb #392
|
9
|
+
* Handle nil value in GetbyteForSSLSocket::getbyte #306
|
10
|
+
|
11
|
+
=== Net::LDAP 0.17.0
|
12
|
+
* Added private recursive_delete as alternative to DELETE_TREE #268
|
13
|
+
* Test suite updates #373 #376 #377
|
14
|
+
* Use Base64.strict_encode64 and SSHA256 #303
|
15
|
+
* Remove deprecated ConnectionRefusedError #366
|
16
|
+
* Added method to get a duplicate of the internal Hash #286
|
17
|
+
* remove a circular require #380
|
18
|
+
* fix LdapServerAsnSyntax compile #379
|
19
|
+
* Implement '==' operator for entries #381
|
20
|
+
* fix for undefined method for write exception #383
|
21
|
+
|
22
|
+
=== Net::LDAP 0.16.3
|
23
|
+
|
24
|
+
* Add Net::LDAP::InvalidDNError #371
|
25
|
+
* Use require_relative instead of require #360
|
26
|
+
* Address some warnings and fix JRuby test omissions #365
|
27
|
+
* Bump rake dev dependency to 12.3 #359
|
28
|
+
* Enable rubocop in ci #251
|
29
|
+
* Enhance rubocop configuration and test syntax #344
|
30
|
+
* CI: Drop rbx-2, uninstallable #364
|
31
|
+
* Fix RuboCop warnings #312
|
32
|
+
* Fix wrong error class #305
|
33
|
+
* CONTRIBUTING.md: Repair link to Issues #309
|
34
|
+
* Make the generate() method more idiomatic... #326
|
35
|
+
* Make encode_sort_controls() more idiomatic... #327
|
36
|
+
* Make the instrument() method more idiomatic... #328
|
37
|
+
* Fix uninitialised Net::LDAP::LdapPduError #338
|
38
|
+
* README.rdoc: Use SVG build badge #310
|
39
|
+
* Update TravisCI config to inclue Ruby 2.7 #346
|
40
|
+
* add explicit ** to silence Ruby 2.7 warning #342
|
41
|
+
* Support parsing filters with attribute tags #345
|
42
|
+
* Bump rubocop development dependency version #336
|
43
|
+
* Add link to generated and hosted documentation on rubydoc #319
|
44
|
+
* Fix 'uninitialized constant Net::LDAP::PDU::LdapPduError' error #317
|
45
|
+
* simplify encoding logic: no more chomping required #362
|
46
|
+
|
1
47
|
=== Net::LDAP 0.16.2
|
2
48
|
|
3
49
|
* 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 for documentation and usage samples.
|
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/ber/core_ext.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
|
-
|
2
|
+
require_relative 'ber_parser'
|
3
3
|
# :stopdoc:
|
4
4
|
class IO
|
5
5
|
include Net::BER::BERParser
|
@@ -19,35 +19,35 @@ end
|
|
19
19
|
module Net::BER::Extensions # :nodoc:
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
require_relative 'core_ext/string'
|
23
23
|
# :stopdoc:
|
24
24
|
class String
|
25
25
|
include Net::BER::BERParser
|
26
26
|
include Net::BER::Extensions::String
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
require_relative 'core_ext/array'
|
30
30
|
# :stopdoc:
|
31
31
|
class Array
|
32
32
|
include Net::BER::Extensions::Array
|
33
33
|
end
|
34
34
|
# :startdoc:
|
35
35
|
|
36
|
-
|
36
|
+
require_relative 'core_ext/integer'
|
37
37
|
# :stopdoc:
|
38
38
|
class Integer
|
39
39
|
include Net::BER::Extensions::Integer
|
40
40
|
end
|
41
41
|
# :startdoc:
|
42
42
|
|
43
|
-
|
43
|
+
require_relative 'core_ext/true_class'
|
44
44
|
# :stopdoc:
|
45
45
|
class TrueClass
|
46
46
|
include Net::BER::Extensions::TrueClass
|
47
47
|
end
|
48
48
|
# :startdoc:
|
49
49
|
|
50
|
-
|
50
|
+
require_relative 'core_ext/false_class'
|
51
51
|
# :stopdoc:
|
52
52
|
class FalseClass
|
53
53
|
include Net::BER::Extensions::FalseClass
|
data/lib/net/ber.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
|
-
|
2
|
+
require_relative 'ldap/version'
|
3
3
|
|
4
4
|
module Net # :nodoc:
|
5
5
|
##
|
@@ -349,4 +349,4 @@ module Net::BER
|
|
349
349
|
Null = Net::BER::BerIdentifiedNull.new
|
350
350
|
end
|
351
351
|
|
352
|
-
|
352
|
+
require_relative 'ber/core_ext'
|
data/lib/net/ldap/connection.rb
CHANGED
@@ -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
|
|
@@ -181,7 +182,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
181
182
|
# have to call it, but perhaps it will come in handy someday.
|
182
183
|
#++
|
183
184
|
def close
|
184
|
-
return if @conn.nil?
|
185
|
+
return if !defined?(@conn) || @conn.nil?
|
185
186
|
@conn.close
|
186
187
|
@conn = nil
|
187
188
|
end
|
@@ -300,7 +301,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
300
301
|
control[2] = (control[2] == true).to_ber
|
301
302
|
control.to_ber_sequence
|
302
303
|
end
|
303
|
-
|
304
|
+
[
|
304
305
|
Net::LDAP::LDAPControls::SORT_REQUEST.to_ber,
|
305
306
|
false.to_ber,
|
306
307
|
sort_control_values.to_ber_sequence.to_s.to_ber,
|
@@ -610,7 +611,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
610
611
|
pdu = queued_read(message_id)
|
611
612
|
|
612
613
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::ExtendedResponse
|
613
|
-
raise Net::LDAP::
|
614
|
+
raise Net::LDAP::ResponseMissingOrInvalidError, "response missing or invalid"
|
614
615
|
end
|
615
616
|
|
616
617
|
pdu
|
@@ -690,7 +691,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
690
691
|
#
|
691
692
|
# Typically a TCPSocket, but can be a OpenSSL::SSL::SSLSocket
|
692
693
|
def socket
|
693
|
-
return @conn if defined?
|
694
|
+
return @conn if defined?(@conn) && !@conn.nil?
|
694
695
|
|
695
696
|
# First refactoring uses the existing methods open_connection and
|
696
697
|
# prepare_socket to set @conn. Next cleanup would centralize connection
|
@@ -710,7 +711,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
710
711
|
# Wrap around Socket.tcp to normalize with other Socket initializers
|
711
712
|
class DefaultSocket
|
712
713
|
def self.new(host, port, socket_opts = {})
|
713
|
-
Socket.tcp(host, port, socket_opts)
|
714
|
+
Socket.tcp(host, port, **socket_opts)
|
714
715
|
end
|
715
716
|
end
|
716
717
|
end # class Connection
|
data/lib/net/ldap/dataset.rb
CHANGED
@@ -103,7 +103,7 @@ class Net::LDAP::Dataset < Hash
|
|
103
103
|
# with the conversion of
|
104
104
|
def from_entry(entry)
|
105
105
|
dataset = Net::LDAP::Dataset.new
|
106
|
-
hash = {
|
106
|
+
hash = {}
|
107
107
|
entry.each_attribute do |attribute, value|
|
108
108
|
next if attribute == :dn
|
109
109
|
hash[attribute] = value
|
@@ -164,5 +164,3 @@ class Net::LDAP::Dataset < Hash
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|
167
|
-
|
168
|
-
require 'net/ldap/entry' unless defined? Net::LDAP::Entry
|
data/lib/net/ldap/dn.rb
CHANGED
@@ -57,19 +57,19 @@ class Net::LDAP::DN
|
|
57
57
|
state = :key_oid
|
58
58
|
key << char
|
59
59
|
when ' ' then state = :key
|
60
|
-
else raise "DN badly formed"
|
60
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
61
61
|
end
|
62
62
|
when :key_normal then
|
63
63
|
case char
|
64
64
|
when '=' then state = :value
|
65
65
|
when 'a'..'z', 'A'..'Z', '0'..'9', '-', ' ' then key << char
|
66
|
-
else raise "DN badly formed"
|
66
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
67
67
|
end
|
68
68
|
when :key_oid then
|
69
69
|
case char
|
70
70
|
when '=' then state = :value
|
71
71
|
when '0'..'9', '.', ' ' then key << char
|
72
|
-
else raise "DN badly formed"
|
72
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
73
73
|
end
|
74
74
|
when :value then
|
75
75
|
case char
|
@@ -110,7 +110,7 @@ class Net::LDAP::DN
|
|
110
110
|
when '0'..'9', 'a'..'f', 'A'..'F' then
|
111
111
|
state = :value_normal
|
112
112
|
value << "#{hex_buffer}#{char}".to_i(16).chr
|
113
|
-
else raise "DN badly formed"
|
113
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
114
114
|
end
|
115
115
|
when :value_quoted then
|
116
116
|
case char
|
@@ -132,7 +132,7 @@ class Net::LDAP::DN
|
|
132
132
|
when '0'..'9', 'a'..'f', 'A'..'F' then
|
133
133
|
state = :value_quoted
|
134
134
|
value << "#{hex_buffer}#{char}".to_i(16).chr
|
135
|
-
else raise "DN badly formed"
|
135
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
136
136
|
end
|
137
137
|
when :value_hexstring then
|
138
138
|
case char
|
@@ -145,14 +145,14 @@ class Net::LDAP::DN
|
|
145
145
|
yield key.string.strip, value.string.rstrip
|
146
146
|
key = StringIO.new
|
147
147
|
value = StringIO.new;
|
148
|
-
else raise "DN badly formed"
|
148
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
149
149
|
end
|
150
150
|
when :value_hexstring_hex then
|
151
151
|
case char
|
152
152
|
when '0'..'9', 'a'..'f', 'A'..'F' then
|
153
153
|
state = :value_hexstring
|
154
154
|
value << char
|
155
|
-
else raise "DN badly formed"
|
155
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
156
156
|
end
|
157
157
|
when :value_end then
|
158
158
|
case char
|
@@ -162,14 +162,14 @@ class Net::LDAP::DN
|
|
162
162
|
yield key.string.strip, value.string.rstrip
|
163
163
|
key = StringIO.new
|
164
164
|
value = StringIO.new;
|
165
|
-
else raise "DN badly formed"
|
165
|
+
else raise Net::LDAP::InvalidDNError, "DN badly formed"
|
166
166
|
end
|
167
|
-
else raise "Fell out of state machine"
|
167
|
+
else raise Net::LDAP::InvalidDNError, "Fell out of state machine"
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
171
|
# Last pair
|
172
|
-
raise "DN badly formed" unless
|
172
|
+
raise Net::LDAP::InvalidDNError, "DN badly formed" unless
|
173
173
|
[:value, :value_normal, :value_hexstring, :value_end].include? state
|
174
174
|
|
175
175
|
yield key.string.strip, value.string.rstrip
|
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
|
@@ -60,6 +35,7 @@ class Net::LDAP
|
|
60
35
|
class ResponseTypeInvalidError < Error; end
|
61
36
|
class ResponseMissingOrInvalidError < Error; end
|
62
37
|
class EmptyDNError < Error; end
|
38
|
+
class InvalidDNError < Error; end
|
63
39
|
class HashTypeUnsupportedError < Error; end
|
64
40
|
class OperatorError < Error; end
|
65
41
|
class SubstringFilterError < Error; end
|
data/lib/net/ldap/filter.rb
CHANGED
@@ -490,7 +490,7 @@ class Net::LDAP::Filter
|
|
490
490
|
when :eq
|
491
491
|
if @right == "*" # presence test
|
492
492
|
@left.to_s.to_ber_contextspecific(7)
|
493
|
-
elsif @right =~ /[*]/ # substring
|
493
|
+
elsif @right.to_s =~ /[*]/ # substring
|
494
494
|
# Parsing substrings is a little tricky. We use String#split to
|
495
495
|
# break a string into substrings delimited by the * (star)
|
496
496
|
# character. But we also need to know whether there is a star at the
|
@@ -646,7 +646,7 @@ class Net::LDAP::Filter
|
|
646
646
|
##
|
647
647
|
# Converts escaped characters (e.g., "\\28") to unescaped characters
|
648
648
|
# @note slawson20170317: Don't attempt to unescape 16 byte binary data which we assume are objectGUIDs
|
649
|
-
# The binary form of 5936AE79-664F-44EA-BCCB-5C39399514C6 triggers a BINARY -> UTF-8 conversion error
|
649
|
+
# The binary form of 5936AE79-664F-44EA-BCCB-5C39399514C6 triggers a BINARY -> UTF-8 conversion error
|
650
650
|
def unescape(right)
|
651
651
|
right = right.to_s
|
652
652
|
if right.length == 16 && right.encoding == Encoding::BINARY
|
@@ -755,7 +755,7 @@ class Net::LDAP::Filter
|
|
755
755
|
# This parses a given expression inside of parentheses.
|
756
756
|
def parse_filter_branch(scanner)
|
757
757
|
scanner.scan(/\s*/)
|
758
|
-
if token = scanner.scan(/[-\w
|
758
|
+
if token = scanner.scan(/[-\w:.;]*[\w]/)
|
759
759
|
scanner.scan(/\s*/)
|
760
760
|
if op = scanner.scan(/<=|>=|!=|:=|=/)
|
761
761
|
scanner.scan(/\s*/)
|
@@ -12,8 +12,8 @@ module Net::LDAP::Instrumentation
|
|
12
12
|
def instrument(event, payload = {})
|
13
13
|
payload = (payload || {}).dup
|
14
14
|
if instrumentation_service
|
15
|
-
instrumentation_service.instrument(event, payload) do |
|
16
|
-
|
15
|
+
instrumentation_service.instrument(event, payload) do |instr_payload|
|
16
|
+
instr_payload[:result] = yield(instr_payload) if block_given?
|
17
17
|
end
|
18
18
|
else
|
19
19
|
yield(payload) if block_given?
|
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'
|
@@ -19,20 +20,21 @@ class Net::LDAP::Password
|
|
19
20
|
# * Should we provide sha1 as a synonym for sha1? I vote no because then
|
20
21
|
# should you also provide ssha1 for symmetry?
|
21
22
|
#
|
22
|
-
attribute_value = ""
|
23
23
|
def generate(type, str)
|
24
24
|
case type
|
25
25
|
when :md5
|
26
|
-
|
26
|
+
'{MD5}' + Base64.strict_encode64(Digest::MD5.digest(str))
|
27
27
|
when :sha
|
28
|
-
|
28
|
+
'{SHA}' + Base64.strict_encode64(Digest::SHA1.digest(str))
|
29
29
|
when :ssha
|
30
30
|
salt = SecureRandom.random_bytes(16)
|
31
|
-
|
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)
|
32
35
|
else
|
33
36
|
raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})"
|
34
37
|
end
|
35
|
-
return attribute_value
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
data/lib/net/ldap/pdu.rb
CHANGED
@@ -123,7 +123,7 @@ class Net::LDAP::PDU
|
|
123
123
|
when ExtendedResponse
|
124
124
|
parse_extended_response(ber_object[1])
|
125
125
|
else
|
126
|
-
raise
|
126
|
+
raise Error.new("unknown pdu-type: #{@app_tag}")
|
127
127
|
end
|
128
128
|
|
129
129
|
parse_controls(ber_object[2]) if ber_object[2]
|
data/lib/net/ldap/version.rb
CHANGED
data/lib/net/ldap.rb
CHANGED
@@ -17,19 +17,19 @@ module Net # :nodoc:
|
|
17
17
|
end
|
18
18
|
require 'socket'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
require_relative 'ber'
|
21
|
+
require_relative 'ldap/pdu'
|
22
|
+
require_relative 'ldap/filter'
|
23
|
+
require_relative 'ldap/dataset'
|
24
|
+
require_relative 'ldap/password'
|
25
|
+
require_relative 'ldap/entry'
|
26
|
+
require_relative 'ldap/instrumentation'
|
27
|
+
require_relative 'ldap/connection'
|
28
|
+
require_relative 'ldap/version'
|
29
|
+
require_relative 'ldap/error'
|
30
|
+
require_relative 'ldap/auth_adapter'
|
31
|
+
require_relative 'ldap/auth_adapter/simple'
|
32
|
+
require_relative 'ldap/auth_adapter/sasl'
|
33
33
|
|
34
34
|
Net::LDAP::AuthAdapter.register([:simple, :anon, :anonymous], Net::LDAP::AuthAdapter::Simple)
|
35
35
|
Net::LDAP::AuthAdapter.register(:sasl, Net::LDAP::AuthAdapter::Sasl)
|
@@ -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",
|
@@ -1182,14 +1182,22 @@ class Net::LDAP
|
|
1182
1182
|
# entries. This method sends an extra control code to tell the LDAP server
|
1183
1183
|
# to do a tree delete. ('1.2.840.113556.1.4.805')
|
1184
1184
|
#
|
1185
|
+
# If the LDAP server does not support the DELETE_TREE control code, subordinate
|
1186
|
+
# entries are deleted recursively instead.
|
1187
|
+
#
|
1185
1188
|
# Returns True or False to indicate whether the delete succeeded. Extended
|
1186
1189
|
# status information is available by calling #get_operation_result.
|
1187
1190
|
#
|
1188
1191
|
# dn = "mail=deleteme@example.com, ou=people, dc=example, dc=com"
|
1189
1192
|
# ldap.delete_tree :dn => dn
|
1190
1193
|
def delete_tree(args)
|
1191
|
-
|
1194
|
+
if search_root_dse[:supportedcontrol].include? Net::LDAP::LDAPControls::DELETE_TREE
|
1195
|
+
delete(args.merge(:control_codes => [[Net::LDAP::LDAPControls::DELETE_TREE, true]]))
|
1196
|
+
else
|
1197
|
+
recursive_delete(args)
|
1198
|
+
end
|
1192
1199
|
end
|
1200
|
+
|
1193
1201
|
# This method is experimental and subject to change. Return the rootDSE
|
1194
1202
|
# record from the LDAP server as a Net::LDAP::Entry, or an empty Entry if
|
1195
1203
|
# the server doesn't return the record.
|
@@ -1320,7 +1328,7 @@ class Net::LDAP
|
|
1320
1328
|
# Force connect to see if there's a connection error
|
1321
1329
|
connection.socket
|
1322
1330
|
connection
|
1323
|
-
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT
|
1331
|
+
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
|
1324
1332
|
@result = {
|
1325
1333
|
:resultCode => 52,
|
1326
1334
|
:errorMessage => ResultStrings[ResultCodeUnavailable],
|
@@ -1340,4 +1348,19 @@ class Net::LDAP
|
|
1340
1348
|
end
|
1341
1349
|
end
|
1342
1350
|
|
1351
|
+
# Recursively delete a dn and it's subordinate children.
|
1352
|
+
# This is useful when a server does not support the DELETE_TREE control code.
|
1353
|
+
def recursive_delete(args)
|
1354
|
+
raise EmptyDNError unless args.is_a?(Hash) && args.key?(:dn)
|
1355
|
+
# Delete Children
|
1356
|
+
search(base: args[:dn], scope: Net::LDAP::SearchScope_SingleLevel) do |entry|
|
1357
|
+
recursive_delete(dn: entry.dn)
|
1358
|
+
end
|
1359
|
+
# Delete Self
|
1360
|
+
unless delete(dn: args[:dn])
|
1361
|
+
raise Net::LDAP::Error, get_operation_result[:error_message].to_s
|
1362
|
+
end
|
1363
|
+
true
|
1364
|
+
end
|
1365
|
+
|
1343
1366
|
end # class LDAP
|
data/lib/net/snmp.rb
CHANGED
data/lib/net-ldap.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
|
-
|
2
|
+
require_relative 'net/ldap'
|