net-ldap 0.1.1 → 0.2
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.
Potentially problematic release.
This version of net-ldap might be problematic. Click here for more details.
- data/.autotest +11 -0
- data/.gemtest +0 -0
- data/.rspec +2 -0
- data/Contributors.rdoc +21 -0
- data/Hacking.rdoc +68 -0
- data/{History.txt → History.rdoc} +65 -1
- data/License.rdoc +29 -0
- data/Manifest.txt +25 -14
- data/README.rdoc +52 -0
- data/Rakefile +52 -96
- data/autotest/discover.rb +1 -0
- data/lib/net-ldap.rb +1 -0
- data/lib/net/ber.rb +302 -81
- data/lib/net/ber/ber_parser.rb +153 -97
- data/lib/net/ber/core_ext.rb +62 -0
- data/lib/net/ber/core_ext/array.rb +82 -0
- data/lib/net/ber/core_ext/bignum.rb +22 -0
- data/lib/net/ber/core_ext/false_class.rb +10 -0
- data/lib/net/ber/core_ext/fixnum.rb +66 -0
- data/lib/net/ber/core_ext/string.rb +48 -0
- data/lib/net/ber/core_ext/true_class.rb +12 -0
- data/lib/net/ldap.rb +1455 -1475
- data/lib/net/ldap/dataset.rb +134 -79
- data/lib/net/ldap/dn.rb +225 -0
- data/lib/net/ldap/entry.rb +168 -249
- data/lib/net/ldap/filter.rb +654 -387
- data/lib/net/ldap/password.rb +31 -0
- data/lib/net/ldap/pdu.rb +232 -233
- data/lib/net/snmp.rb +4 -31
- data/net-ldap.gemspec +59 -0
- data/spec/integration/ssl_ber_spec.rb +3 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/ber/ber_spec.rb +82 -6
- data/spec/unit/ber/core_ext/string_spec.rb +51 -0
- data/spec/unit/ldap/dn_spec.rb +80 -0
- data/spec/unit/ldap/entry_spec.rb +51 -0
- data/spec/unit/ldap/filter_spec.rb +84 -0
- data/spec/unit/ldap_spec.rb +48 -0
- data/test/test_entry.rb +54 -2
- data/test/test_filter.rb +93 -54
- data/test/test_ldap_connection.rb +24 -0
- data/test/test_ldif.rb +31 -23
- data/test/test_rename.rb +77 -0
- data/test/test_snmp.rb +34 -33
- metadata +88 -52
- data/COPYING +0 -272
- data/LICENSE +0 -56
- data/README.txt +0 -68
- data/lib/net/ldap/core_ext/all.rb +0 -43
- data/lib/net/ldap/core_ext/array.rb +0 -42
- data/lib/net/ldap/core_ext/bignum.rb +0 -25
- data/lib/net/ldap/core_ext/false_class.rb +0 -11
- data/lib/net/ldap/core_ext/fixnum.rb +0 -74
- data/lib/net/ldap/core_ext/string.rb +0 -40
- data/lib/net/ldap/core_ext/true_class.rb +0 -11
- data/lib/net/ldap/psw.rb +0 -57
- data/lib/net/ldif.rb +0 -34
- data/test/test_ber.rb +0 -78
data/LICENSE
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
Net::LDAP is copyrighted free software by Francis Cianfrocca
|
2
|
-
<garbagecat10@gmail.com> and other contributors. You can redistribute it and/or
|
3
|
-
modify it under either the terms of the GPL (see the file COPYING), or the
|
4
|
-
conditions below:
|
5
|
-
|
6
|
-
1. You may make and give away verbatim copies of the source form of the
|
7
|
-
software without restriction, provided that you duplicate all of the
|
8
|
-
original copyright notices and associated disclaimers.
|
9
|
-
|
10
|
-
2. You may modify your copy of the software in any way, provided that you do
|
11
|
-
at least ONE of the following:
|
12
|
-
|
13
|
-
a) place your modifications in the Public Domain or otherwise make them
|
14
|
-
Freely Available, such as by posting said modifications to Usenet or
|
15
|
-
an equivalent medium, or by allowing the author to include your
|
16
|
-
modifications in the software.
|
17
|
-
|
18
|
-
b) use the modified software only within your corporation or
|
19
|
-
organization.
|
20
|
-
|
21
|
-
c) rename any non-standard executables so the names do not conflict with
|
22
|
-
standard executables, which must also be provided.
|
23
|
-
|
24
|
-
d) make other distribution arrangements with the author.
|
25
|
-
|
26
|
-
3. You may distribute the software in object code or executable form,
|
27
|
-
provided that you do at least ONE of the following:
|
28
|
-
|
29
|
-
a) distribute the executables and library files of the software, together
|
30
|
-
with instructions (in the manual page or equivalent) on where to get
|
31
|
-
the original distribution.
|
32
|
-
|
33
|
-
b) accompany the distribution with the machine-readable source of the
|
34
|
-
software.
|
35
|
-
|
36
|
-
c) give non-standard executables non-standard names, with instructions on
|
37
|
-
where to get the original software distribution.
|
38
|
-
|
39
|
-
d) make other distribution arrangements with the author.
|
40
|
-
|
41
|
-
4. You may modify and include the part of the software into any other
|
42
|
-
software (possibly commercial). But some files in the distribution are
|
43
|
-
not written by the author, so that they are not under this terms.
|
44
|
-
|
45
|
-
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
46
|
-
files under the ./missing directory. See each file for the copying
|
47
|
-
condition.
|
48
|
-
|
49
|
-
5. The scripts and library files supplied as input to or produced as output
|
50
|
-
from the software do not automatically fall under the copyright of the
|
51
|
-
software, but belong to whomever generated them, and may be sold
|
52
|
-
commercially, and may be aggregated with this software.
|
53
|
-
|
54
|
-
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
|
55
|
-
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
56
|
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.txt
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
= Net::LDAP for Ruby
|
2
|
-
|
3
|
-
== Description
|
4
|
-
|
5
|
-
Pure Ruby LDAP library.
|
6
|
-
|
7
|
-
== Where
|
8
|
-
|
9
|
-
=== Issues & Project Homepage
|
10
|
-
|
11
|
-
http://rubyforge.org/projects/net-ldap
|
12
|
-
|
13
|
-
=== Code
|
14
|
-
|
15
|
-
http://github.com/RoryO/ruby-net-ldap/
|
16
|
-
|
17
|
-
== FEATURES/PROBLEMS
|
18
|
-
|
19
|
-
The Lightweight Directory Access Protocol (LDAP) is an Internet protocol for
|
20
|
-
accessing distributed directory services.
|
21
|
-
|
22
|
-
Net::LDAP is an LDAP support library written in pure Ruby. It supports most
|
23
|
-
LDAP client features and a subset of server features as well.
|
24
|
-
|
25
|
-
* Standards-based (going for RFC 4511)
|
26
|
-
* Portable: 100% Ruby
|
27
|
-
|
28
|
-
== SYNOPSIS
|
29
|
-
|
30
|
-
See Net::LDAP for documentation and usage samples.
|
31
|
-
|
32
|
-
== REQUIREMENTS
|
33
|
-
|
34
|
-
Net::LDAP requires Ruby 1.8.7-compliant interpreter or better.
|
35
|
-
|
36
|
-
== INSTALL
|
37
|
-
|
38
|
-
Net::LDAP is a pure Ruby library. It does not require any external libraries.
|
39
|
-
You can install the RubyGems version of Net::LDAP available from the usual
|
40
|
-
sources.
|
41
|
-
|
42
|
-
* gem install net-ldap
|
43
|
-
|
44
|
-
Simply require 'net/ldap'.
|
45
|
-
|
46
|
-
== CREDITS
|
47
|
-
|
48
|
-
Net::LDAP was originally developed by:
|
49
|
-
|
50
|
-
* Francis Cianfrocca blackhedd@rubyforge.org
|
51
|
-
|
52
|
-
Contributions since:
|
53
|
-
|
54
|
-
* Emiel van de Laar emiel@rubyforge.org
|
55
|
-
* Rory O'Connell rory.ocon@gmail.com
|
56
|
-
* Kaspar Schiess eule@rubyforge.org
|
57
|
-
* Austin Ziegler austin@rubyforge.org
|
58
|
-
|
59
|
-
== LICENSE
|
60
|
-
|
61
|
-
Copyright (C) 2006 - 2010 by Francis Cianfrocca and other contributors.
|
62
|
-
|
63
|
-
Please read the file LICENSE for licensing restrictions on this library. In
|
64
|
-
the simplest terms, this library is available under the same terms as Ruby
|
65
|
-
itself.
|
66
|
-
|
67
|
-
Available under the same terms as Ruby. See LICENSE in the main distribution
|
68
|
-
for full licensing information.
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'net/ldap/core_ext/array'
|
2
|
-
require 'net/ldap/core_ext/string'
|
3
|
-
require 'net/ldap/core_ext/bignum'
|
4
|
-
require 'net/ldap/core_ext/fixnum'
|
5
|
-
require 'net/ldap/core_ext/false_class'
|
6
|
-
require 'net/ldap/core_ext/true_class'
|
7
|
-
|
8
|
-
class Array
|
9
|
-
include Net::LDAP::Extensions::Array
|
10
|
-
end
|
11
|
-
|
12
|
-
class String
|
13
|
-
include Net::BER::BERParser
|
14
|
-
include Net::LDAP::Extensions::String
|
15
|
-
end
|
16
|
-
|
17
|
-
class Bignum
|
18
|
-
include Net::LDAP::Extensions::Bignum
|
19
|
-
end
|
20
|
-
|
21
|
-
class Fixnum
|
22
|
-
include Net::LDAP::Extensions::Fixnum
|
23
|
-
end
|
24
|
-
|
25
|
-
class FalseClass
|
26
|
-
include Net::LDAP::Extensions::FalseClass
|
27
|
-
end
|
28
|
-
|
29
|
-
class TrueClass
|
30
|
-
include Net::LDAP::Extensions::TrueClass
|
31
|
-
end
|
32
|
-
|
33
|
-
class IO
|
34
|
-
include Net::BER::BERParser
|
35
|
-
end
|
36
|
-
|
37
|
-
class StringIO
|
38
|
-
include Net::BER::BERParser
|
39
|
-
end
|
40
|
-
|
41
|
-
class OpenSSL::SSL::SSLSocket
|
42
|
-
include Net::BER::BERParser
|
43
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Net
|
2
|
-
class LDAP
|
3
|
-
module Extensions
|
4
|
-
module Array
|
5
|
-
#
|
6
|
-
# to_ber_appsequence
|
7
|
-
# An application-specific sequence usually gets assigned
|
8
|
-
# a tag that is meaningful to the particular protocol being used.
|
9
|
-
# This is different from the universal sequence, which usually
|
10
|
-
# gets a tag value of 16.
|
11
|
-
# Now here's an interesting thing: We're adding the X.690
|
12
|
-
# "application constructed" code at the top of the tag byte (0x60),
|
13
|
-
# but some clients, notably ldapsearch, send "context-specific
|
14
|
-
# constructed" (0xA0). The latter would appear to violate RFC-1777,
|
15
|
-
# but what do I know? We may need to change this.
|
16
|
-
#
|
17
|
-
|
18
|
-
def to_ber id = 0; to_ber_seq_internal( 0x30 + id ); end
|
19
|
-
def to_ber_set id = 0; to_ber_seq_internal( 0x31 + id ); end
|
20
|
-
def to_ber_sequence id = 0; to_ber_seq_internal( 0x30 + id ); end
|
21
|
-
def to_ber_appsequence id = 0; to_ber_seq_internal( 0x60 + id ); end
|
22
|
-
def to_ber_contextspecific id = 0; to_ber_seq_internal( 0xA0 + id ); end
|
23
|
-
|
24
|
-
def to_ber_oid
|
25
|
-
ary = self.dup
|
26
|
-
first = ary.shift
|
27
|
-
raise Net::BER::BerError.new( "invalid OID" ) unless [0,1,2].include?(first)
|
28
|
-
first = first * 40 + ary.shift
|
29
|
-
ary.unshift first
|
30
|
-
oid = ary.pack("w*")
|
31
|
-
[6, oid.length].pack("CC") + oid
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def to_ber_seq_internal code
|
36
|
-
s = self.join
|
37
|
-
[code].pack('C') + s.length.to_ber_length_encoding + s
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end # class Array
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Net
|
2
|
-
class LDAP
|
3
|
-
module Extensions
|
4
|
-
module Bignum
|
5
|
-
|
6
|
-
def to_ber
|
7
|
-
# NOTE: Array#pack's 'w' is a BER _compressed_ integer. We need
|
8
|
-
# uncompressed BER integers, so we're not using that. See also:
|
9
|
-
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/228864
|
10
|
-
result = []
|
11
|
-
|
12
|
-
n = self
|
13
|
-
while n>0
|
14
|
-
b = n & 0xff
|
15
|
-
result << b
|
16
|
-
n = n >> 8
|
17
|
-
end
|
18
|
-
|
19
|
-
"\002" + ([result.size] + result.reverse).pack('C*')
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module Net
|
2
|
-
class LDAP
|
3
|
-
module Extensions
|
4
|
-
module Fixnum
|
5
|
-
#
|
6
|
-
# to_ber
|
7
|
-
#
|
8
|
-
def to_ber
|
9
|
-
"\002" + to_ber_internal
|
10
|
-
end
|
11
|
-
|
12
|
-
#
|
13
|
-
# to_ber_enumerated
|
14
|
-
#
|
15
|
-
def to_ber_enumerated
|
16
|
-
"\012" + to_ber_internal
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# to_ber_length_encoding
|
21
|
-
#
|
22
|
-
def to_ber_length_encoding
|
23
|
-
if self <= 127
|
24
|
-
[self].pack('C')
|
25
|
-
else
|
26
|
-
i = [self].pack('N').sub(/^[\0]+/,"")
|
27
|
-
[0x80 + i.length].pack('C') + i
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Generate a BER-encoding for an application-defined INTEGER.
|
32
|
-
# Example: SNMP's Counter, Gauge, and TimeTick types.
|
33
|
-
#
|
34
|
-
def to_ber_application tag
|
35
|
-
[0x40 + tag].pack("C") + to_ber_internal
|
36
|
-
end
|
37
|
-
|
38
|
-
#--
|
39
|
-
# Called internally to BER-encode the length and content bytes of a
|
40
|
-
# Fixnum. The caller will prepend the tag byte.
|
41
|
-
#
|
42
|
-
MAX_SIZE = 0.size
|
43
|
-
def to_ber_internal
|
44
|
-
# CAUTION: Bit twiddling ahead. You might want to shield your eyes
|
45
|
-
# or something.
|
46
|
-
|
47
|
-
# Looks for the first byte in the fixnum that is not all zeroes. It
|
48
|
-
# does this by masking one byte after another, checking the result
|
49
|
-
# for bits that are left on.
|
50
|
-
size = MAX_SIZE
|
51
|
-
while size>1
|
52
|
-
break if (self & (0xff << (size-1)*8)) > 0
|
53
|
-
size -= 1
|
54
|
-
end
|
55
|
-
|
56
|
-
# Store the size of the fixnum in the result
|
57
|
-
result = [size]
|
58
|
-
|
59
|
-
# Appends bytes to result, starting with higher orders first.
|
60
|
-
# Extraction of bytes is done by right shifting the original fixnum
|
61
|
-
# by an amount and then masking that with 0xff.
|
62
|
-
while size>0
|
63
|
-
# right shift size-1 bytes, mask with 0xff
|
64
|
-
result << ((self >> ((size-1)*8)) & 0xff)
|
65
|
-
size -= 1
|
66
|
-
end
|
67
|
-
|
68
|
-
result.pack('C*')
|
69
|
-
end
|
70
|
-
private :to_ber_internal
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
module Net
|
4
|
-
class LDAP
|
5
|
-
module Extensions
|
6
|
-
module String
|
7
|
-
#
|
8
|
-
# to_ber
|
9
|
-
# A universal octet-string is tag number 4,
|
10
|
-
# but others are possible depending on the context, so we
|
11
|
-
# let the caller give us one.
|
12
|
-
# The preferred way to do this in user code is via to_ber_application_sring
|
13
|
-
# and to_ber_contextspecific.
|
14
|
-
#
|
15
|
-
def to_ber code = 4
|
16
|
-
[code].pack('C') + length.to_ber_length_encoding + self
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# to_ber_application_string
|
21
|
-
#
|
22
|
-
def to_ber_application_string code
|
23
|
-
to_ber( 0x40 + code )
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# to_ber_contextspecific
|
28
|
-
#
|
29
|
-
def to_ber_contextspecific code
|
30
|
-
to_ber( 0x80 + code )
|
31
|
-
end
|
32
|
-
|
33
|
-
def read_ber syntax=nil
|
34
|
-
StringIO.new(self).
|
35
|
-
read_ber(syntax)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/net/ldap/psw.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
4
|
-
#
|
5
|
-
# Gmail: garbagecat10
|
6
|
-
#
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program; if not, write to the Free Software
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
-
#
|
21
|
-
#---------------------------------------------------------------------------
|
22
|
-
|
23
|
-
require 'digest/sha1'
|
24
|
-
require 'digest/md5'
|
25
|
-
|
26
|
-
module Net
|
27
|
-
class LDAP
|
28
|
-
class Password
|
29
|
-
class << self
|
30
|
-
# Generate a password-hash suitable for inclusion in an LDAP
|
31
|
-
# attribute. Pass a hash type (currently supported: :md5 and :sha)
|
32
|
-
# and a plaintext password. This function will return a hashed
|
33
|
-
# representation.
|
34
|
-
#
|
35
|
-
# STUB: This is here to fulfill the requirements of an RFC, which
|
36
|
-
# one?
|
37
|
-
#
|
38
|
-
# TODO, gotta do salted-sha and (maybe) salted-md5.
|
39
|
-
# Should we provide sha1 as a synonym for sha1? I vote no because
|
40
|
-
# then should you also provide ssha1 for symmetry?
|
41
|
-
def generate(type, str)
|
42
|
-
digest, digest_name = case type
|
43
|
-
when :md5
|
44
|
-
[Digest::MD5.new, 'MD5']
|
45
|
-
when :sha
|
46
|
-
[Digest::SHA1.new, 'SHA']
|
47
|
-
else
|
48
|
-
raise Net::LDAP::LdapError.new("unsupported password-hash type (#{type})")
|
49
|
-
end
|
50
|
-
|
51
|
-
digest << str.to_s
|
52
|
-
return "{#{digest_name}}#{[digest.digest].pack('m').chomp }"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/lib/net/ldif.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
#
|
3
|
-
# Net::LDIF for Ruby
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
8
|
-
#
|
9
|
-
# Gmail: garbagecat10
|
10
|
-
#
|
11
|
-
# This program is free software; you can redistribute it and/or modify
|
12
|
-
# it under the terms of the GNU General Public License as published by
|
13
|
-
# the Free Software Foundation; either version 2 of the License, or
|
14
|
-
# (at your option) any later version.
|
15
|
-
#
|
16
|
-
# This program is distributed in the hope that it will be useful,
|
17
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
# GNU General Public License for more details.
|
20
|
-
#
|
21
|
-
# You should have received a copy of the GNU General Public License
|
22
|
-
# along with this program; if not, write to the Free Software
|
23
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
# THIS FILE IS A STUB.
|
28
|
-
|
29
|
-
module Net
|
30
|
-
class LDIF
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|