Merging an ugly set of changes I had forgotten about.
This commit is contained in:
commit
84e42ceb78
77
Hacking.rdoc
77
Hacking.rdoc
|
@ -1,19 +1,68 @@
|
||||||
= Hacking on Net::LDAP
|
= Hacking on Net::LDAP
|
||||||
|
|
||||||
|
We welcome your contributions to Net::LDAP. We accept most contributions, but
|
||||||
|
there are ways to increase the chance of your patch being accepted quickly.
|
||||||
|
|
||||||
|
== Licensing
|
||||||
|
|
||||||
|
Net::LDAP 0.2 and later are be licensed under an MIT-style license; any
|
||||||
|
contributions after 2010-04-20 must be under this license to be accepted.
|
||||||
|
|
||||||
|
== Formatting
|
||||||
|
|
||||||
|
* Your patches should be formatted like the rest of Net::LDAP.
|
||||||
|
* We use a text wrap of 76–78 characters, especially for documentation
|
||||||
|
contents.
|
||||||
|
* Operators should have spaces around them.
|
||||||
|
* Method definitions should have parentheses around arguments (and no
|
||||||
|
parentheses if there are no arguments).
|
||||||
|
* Indentation should be kept as flat as possible; this may mean being more
|
||||||
|
explicit with constants.
|
||||||
|
|
||||||
|
|
||||||
We welcome your contributions to Net::LDAP. To increase the chances of your
|
We welcome your contributions to Net::LDAP. To increase the chances of your
|
||||||
patches being accepted, we recommend that you follow the guidelines below:
|
patches being accepted, we recommend that you follow the guidelines below:
|
||||||
|
|
||||||
1. Your code should be formatted like the rest of Net::LDAP. We use a text
|
== Documentation
|
||||||
wrap of 76 - 78 characters, especially for documentation contents.
|
|
||||||
Operators should have spaces around them, method definitions should have
|
* Documentation: {net-ldap}[http://net-ldap.rubyforge.org/]
|
||||||
parentheses around arguments. Keep the indentation as flat as possible.
|
|
||||||
2. Your changes should be well-documented and described.
|
It is very important that, if you add new methods or objects, your code is
|
||||||
3. You must provide Rspec tests for any new or changed features.
|
well-documented. The purpose of the changes should be clearly described so that
|
||||||
4. You should provide LDIF data for importing into LDAP servers so that the
|
even if this is a feature we do not use, we can understand its purpose.
|
||||||
changes can be tested <em>in situ</em> with more than one real LDAP
|
|
||||||
server.
|
We also encourage documentation-only contributions that improve the
|
||||||
5. You should have tested your changes against a real LDAP server.
|
documentation of Net::LDAP.
|
||||||
6. Your patch should include modifications to History.rdoc summarizing the
|
|
||||||
change.
|
We encourage you to provide a good summary of your as a modification to
|
||||||
7. If you're a first-time contributor, your patch should include modifications
|
+History.rdoc+, and if you're not yet named as a contributor, include a
|
||||||
to Contributors.rdoc.
|
modification to +Contributors.rdoc+ to add yourself.
|
||||||
|
|
||||||
|
== Tests
|
||||||
|
|
||||||
|
The Net::LDAP team uses RSpec for unit testing; all changes must have rspec
|
||||||
|
tests for any new or changed features.
|
||||||
|
|
||||||
|
Your changes should have been tested against at least one real LDAP server; the
|
||||||
|
current tests are not sufficient to find all possible bugs. It's unlikely that
|
||||||
|
they will ever be sufficient given the variations in LDAP server behaviour.
|
||||||
|
|
||||||
|
If you're introducing a new feature, it would be preferred for you to provide
|
||||||
|
us with a sample LDIF data file for importing into LDAP servers for testing.
|
||||||
|
|
||||||
|
== Development Dependencies
|
||||||
|
|
||||||
|
Net::LDAP uses several libraries during development, all of which can be
|
||||||
|
installed using RubyGems.
|
||||||
|
|
||||||
|
* *hoe*
|
||||||
|
* *hoe-git*
|
||||||
|
* *metaid*
|
||||||
|
* *rspec*
|
||||||
|
* *flexmock*
|
||||||
|
|
||||||
|
== Participation
|
||||||
|
|
||||||
|
* RubyForge: {net-ldap}[http://rubyforge.org/projects/net-ldap]
|
||||||
|
* GitHub: {ruby-ldap/ruby-net-ldap}[https://github.com/ruby-ldap/ruby-net-ldap/]
|
||||||
|
* Group: {ruby-ldap}[http://groups.google.com/group/ruby-ldap]
|
||||||
|
|
21
History.rdoc
21
History.rdoc
|
@ -1,4 +1,4 @@
|
||||||
=== Net::LDAP 0.2.0 / 2011-__-__
|
=== Net::LDAP 0.2 / 2011-03-__
|
||||||
* Major Enhancements:
|
* Major Enhancements:
|
||||||
* Net::LDAP::Filter changes:
|
* Net::LDAP::Filter changes:
|
||||||
* Filters can only be constructed using our custom constructors (eq, ge,
|
* Filters can only be constructed using our custom constructors (eq, ge,
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
Fixed some of the regular expressions to be more canonically defined.
|
Fixed some of the regular expressions to be more canonically defined.
|
||||||
* Cleaned up the string representation of Filter objects.
|
* Cleaned up the string representation of Filter objects.
|
||||||
* Added experimental support for RFC4515 extensible matching (e.g.,
|
* Added experimental support for RFC4515 extensible matching (e.g.,
|
||||||
* "(cn:caseExactMatch:=Fred Flintstone)"); provided by "nowhereman".
|
"(cn:caseExactMatch:=Fred Flintstone)"); provided by "nowhereman".
|
||||||
* Minor Enhancements:
|
* Minor Enhancements:
|
||||||
* SSL capabilities will be enabled or disabled based on whether we can load
|
* SSL capabilities will be enabled or disabled based on whether we can load
|
||||||
OpenSSL successfully or not.
|
OpenSSL successfully or not.
|
||||||
|
@ -25,6 +25,17 @@
|
||||||
* Added some unit tests for the BER core extensions.
|
* Added some unit tests for the BER core extensions.
|
||||||
* Documentation Changes:
|
* Documentation Changes:
|
||||||
* Core class extension methods under Net::BER.
|
* Core class extension methods under Net::BER.
|
||||||
|
* Extensive changes to Net::BER documentation.
|
||||||
|
* Cleaned up some rdoc oddities, suppressed empty documentation sections
|
||||||
|
where possible.
|
||||||
|
* Added a document describing how to contribute to Net::LDAP most
|
||||||
|
effectively.
|
||||||
|
* Added a document recognizing contributors to Net::LDAP.
|
||||||
|
* Extended unit testing:
|
||||||
|
* Added some unit tests for the BER core extensions.
|
||||||
|
* The LDIF test data file was split for Ruby 1.9 regexp support.
|
||||||
|
* Added a cruisecontrol.rb task.
|
||||||
|
* Converted some test/unit tests to specs.
|
||||||
* Code clean-up:
|
* Code clean-up:
|
||||||
* Made the formatting of code consistent across all files.
|
* Made the formatting of code consistent across all files.
|
||||||
* Removed Net::BER::BERParser::TagClasses as it does not appear to be used.
|
* Removed Net::BER::BERParser::TagClasses as it does not appear to be used.
|
||||||
|
@ -35,16 +46,18 @@
|
||||||
Pdu#result. This may be changed in Net::LDAP 1.0 to return the full
|
Pdu#result. This may be changed in Net::LDAP 1.0 to return the full
|
||||||
Pdu#result, but if we do so, it will be that way for all LDAP calls
|
Pdu#result, but if we do so, it will be that way for all LDAP calls
|
||||||
involving Pdu objects.
|
involving Pdu objects.
|
||||||
|
* Renamed Net::LDAP::Psw to Net::LDAP::Password with a corresponding filename
|
||||||
|
change.
|
||||||
|
* Removed the stub file lib/net/ldif.rb and class Net::LDIF.
|
||||||
* Project Management:
|
* Project Management:
|
||||||
* Changed the license from Ruby + GPL to MIT with the agreement of the
|
* Changed the license from Ruby + GPL to MIT with the agreement of the
|
||||||
original author (Francis Cianfrocca) and the named contributors. Versions
|
original author (Francis Cianfrocca) and the named contributors. Versions
|
||||||
prior to 0.2.0 are still available under the Ruby + GPL license.
|
prior to 0.2.0 are still available under the Ruby + GPL license.
|
||||||
* Added a hacking document and a contributors document.
|
|
||||||
|
|
||||||
=== Net::LDAP 0.1.1 / 2010-03-18
|
=== Net::LDAP 0.1.1 / 2010-03-18
|
||||||
* Fixing a critical problem with sockets.
|
* Fixing a critical problem with sockets.
|
||||||
|
|
||||||
=== Net::LDAP 0.1.0 / 2010-03-17
|
=== Net::LDAP 0.1 / 2010-03-17
|
||||||
* Small fixes throughout, more to come.
|
* Small fixes throughout, more to come.
|
||||||
* Ruby 1.9 support added.
|
* Ruby 1.9 support added.
|
||||||
* Ruby 1.8.6 and below support removed. If we can figure out a compatible way
|
* Ruby 1.8.6 and below support removed. If we can figure out a compatible way
|
||||||
|
|
|
@ -22,3 +22,8 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
=== Notice of License Change
|
||||||
|
|
||||||
|
Versions prior to 0.2 were under Ruby's dual license with the GNU GPL. With
|
||||||
|
this release (0.2), Net::LDAP is now under the MIT license.
|
||||||
|
|
|
@ -21,7 +21,10 @@ lib/net/ldap/entry.rb
|
||||||
lib/net/ldap/filter.rb
|
lib/net/ldap/filter.rb
|
||||||
lib/net/ldap/password.rb
|
lib/net/ldap/password.rb
|
||||||
lib/net/ldap/pdu.rb
|
lib/net/ldap/pdu.rb
|
||||||
|
<<<<<<< HEAD
|
||||||
lib/net/ldif.rb
|
lib/net/ldif.rb
|
||||||
|
=======
|
||||||
|
>>>>>>> f46c68dce3be545811041fb344273a9c84d372c4
|
||||||
lib/net/snmp.rb
|
lib/net/snmp.rb
|
||||||
spec/integration/ssl_ber_spec.rb
|
spec/integration/ssl_ber_spec.rb
|
||||||
spec/spec.opts
|
spec/spec.opts
|
||||||
|
|
29
README.rdoc
29
README.rdoc
|
@ -2,20 +2,24 @@
|
||||||
|
|
||||||
== Description
|
== Description
|
||||||
|
|
||||||
Net::LDAP for Ruby implements client access for the Lightweight Directory
|
Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
||||||
Access Protocol (LDAP), an IETF standard protocol for accessing distributed
|
Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
|
||||||
directory services. Net::LDAP is written completely in Ruby with no external
|
accessing distributed directory services. Net::LDAP is written completely in
|
||||||
dependencies. It supports most LDAP client features and a subset of server
|
Ruby with no external dependencies. It supports most LDAP client features and a
|
||||||
features as well.
|
subset of server features as well.
|
||||||
|
|
||||||
Net::LDAP strives for standards-conformity ({RFC
|
Net::LDAP has been tested against modern popular LDAP servers including
|
||||||
4511}[http://www.rfc-editor.org/rfc/rfc4511.txt]), but it also provides support
|
OpenLDAP and Active Directory. The current release is mostly compliant with
|
||||||
for features in popular non-conforming LDAP servers.
|
earlier versions of the IETF LDAP RFCs (2251–2256, 2829–2830, 3377, and 3771).
|
||||||
|
Our roadmap for Net::LDAP 1.0 is to gain full <em>client</em> compliance with
|
||||||
|
the most recent LDAP RFCs (4510–4519, plutions of 4520–4532).
|
||||||
|
|
||||||
== Where
|
== Where
|
||||||
|
|
||||||
* {RubyForge}[http://rubyforge.org/projects/net-ldap]
|
* {RubyForge}[http://rubyforge.org/projects/net-ldap]
|
||||||
* {GitHub}[https://github.com/ruby-ldap/ruby-net-ldap]
|
* {GitHub}[https://github.com/ruby-ldap/ruby-net-ldap]
|
||||||
|
* {ruby-ldap@googlegroups.com}[http://groups.google.com/group/ruby-ldap]
|
||||||
|
* {Documentation}[http://net-ldap.rubyforge.org/]
|
||||||
|
|
||||||
The Net::LDAP for Ruby documentation, project description, and main downloads
|
The Net::LDAP for Ruby documentation, project description, and main downloads
|
||||||
can currently be found on {RubyForge}[http://rubyforge.org/projects/net-ldap].
|
can currently be found on {RubyForge}[http://rubyforge.org/projects/net-ldap].
|
||||||
|
@ -34,9 +38,14 @@ Net::LDAP is a pure Ruby library. It does not require any external libraries.
|
||||||
You can install the RubyGems version of Net::LDAP available from the usual
|
You can install the RubyGems version of Net::LDAP available from the usual
|
||||||
sources.
|
sources.
|
||||||
|
|
||||||
* gem install net-ldap
|
gem install net-ldap
|
||||||
|
|
||||||
Simply require 'net/ldap'.
|
Simply require either 'net-ldap' or 'net/ldap'.
|
||||||
|
|
||||||
|
For non-RubyGems installations of Net::LDAP, you can use Minero Aoki's
|
||||||
|
{setup.rb}[http://i.loveruby.net/en/projects/setup/] as the layout of
|
||||||
|
Net::LDAP is compliant. The setup installer is not included in the
|
||||||
|
Net::LDAP repository.
|
||||||
|
|
||||||
:include: Contributors.rdoc
|
:include: Contributors.rdoc
|
||||||
|
|
||||||
|
|
1
Rakefile
1
Rakefile
|
@ -31,6 +31,7 @@ Hoe.spec 'net-ldap' do
|
||||||
self.extra_dev_deps << [ "metaid", "~> 1" ]
|
self.extra_dev_deps << [ "metaid", "~> 1" ]
|
||||||
self.extra_dev_deps << [ "flexmock", "~> 0.9.0" ]
|
self.extra_dev_deps << [ "flexmock", "~> 0.9.0" ]
|
||||||
self.extra_dev_deps << [ "rspec", "~> 2.0" ]
|
self.extra_dev_deps << [ "rspec", "~> 2.0" ]
|
||||||
|
|
||||||
self.clean_globs << "coverage"
|
self.clean_globs << "coverage"
|
||||||
|
|
||||||
self.spec_extras[:required_ruby_version] = ">= 1.8.7"
|
self.spec_extras[:required_ruby_version] = ">= 1.8.7"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Net
|
module Net # :nodoc:
|
||||||
##
|
##
|
||||||
# == Basic Encoding Rules (BER) Support Module
|
# == Basic Encoding Rules (BER) Support Module
|
||||||
#
|
#
|
||||||
|
@ -105,7 +105,7 @@ module Net
|
||||||
# <tr><th>BMPString</th><th>C</th><td>30: 62 (0x3e, 0b00111110)</td></tr>
|
# <tr><th>BMPString</th><th>C</th><td>30: 62 (0x3e, 0b00111110)</td></tr>
|
||||||
# </table>
|
# </table>
|
||||||
module BER
|
module BER
|
||||||
VERSION = '0.1.0'
|
VERSION = '0.2'
|
||||||
|
|
||||||
##
|
##
|
||||||
# Used for BER-encoding the length and content bytes of a Fixnum integer
|
# Used for BER-encoding the length and content bytes of a Fixnum integer
|
||||||
|
|
|
@ -1,29 +1,5 @@
|
||||||
# NET::BER
|
|
||||||
# Mixes ASN.1/BER convenience methods into several standard classes. Also
|
|
||||||
# provides BER parsing functionality.
|
|
||||||
#
|
|
||||||
#--
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca and other contributors. All
|
|
||||||
# Rights Reserved.
|
|
||||||
#
|
|
||||||
# Gmail: garbagecat10
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
#++
|
|
||||||
|
|
||||||
require 'net/ber/ber_parser'
|
require 'net/ber/ber_parser'
|
||||||
|
# :stopdoc:
|
||||||
class IO
|
class IO
|
||||||
include Net::BER::BERParser
|
include Net::BER::BERParser
|
||||||
end
|
end
|
||||||
|
@ -37,36 +13,49 @@ if defined? ::OpenSSL
|
||||||
include Net::BER::BERParser
|
include Net::BER::BERParser
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
module Net::BER::Extensions; end
|
module Net::BER::Extensions # :nodoc:
|
||||||
|
end
|
||||||
|
|
||||||
require 'net/ber/core_ext/string'
|
require 'net/ber/core_ext/string'
|
||||||
|
# :stopdoc:
|
||||||
class String
|
class String
|
||||||
include Net::BER::BERParser
|
include Net::BER::BERParser
|
||||||
include Net::BER::Extensions::String
|
include Net::BER::Extensions::String
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'net/ber/core_ext/array'
|
require 'net/ber/core_ext/array'
|
||||||
|
# :stopdoc:
|
||||||
class Array
|
class Array
|
||||||
include Net::BER::Extensions::Array
|
include Net::BER::Extensions::Array
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
require 'net/ber/core_ext/bignum'
|
require 'net/ber/core_ext/bignum'
|
||||||
|
# :stopdoc:
|
||||||
class Bignum
|
class Bignum
|
||||||
include Net::BER::Extensions::Bignum
|
include Net::BER::Extensions::Bignum
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
require 'net/ber/core_ext/fixnum'
|
require 'net/ber/core_ext/fixnum'
|
||||||
|
# :stopdoc:
|
||||||
class Fixnum
|
class Fixnum
|
||||||
include Net::BER::Extensions::Fixnum
|
include Net::BER::Extensions::Fixnum
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
require 'net/ber/core_ext/true_class'
|
require 'net/ber/core_ext/true_class'
|
||||||
|
# :stopdoc:
|
||||||
class TrueClass
|
class TrueClass
|
||||||
include Net::BER::Extensions::TrueClass
|
include Net::BER::Extensions::TrueClass
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
require 'net/ber/core_ext/false_class'
|
require 'net/ber/core_ext/false_class'
|
||||||
|
# :stopdoc:
|
||||||
class FalseClass
|
class FalseClass
|
||||||
include Net::BER::Extensions::FalseClass
|
include Net::BER::Extensions::FalseClass
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
##
|
||||||
|
# BER extensions to the Array class.
|
||||||
module Net::BER::Extensions::Array
|
module Net::BER::Extensions::Array
|
||||||
##
|
##
|
||||||
# Converts an Array to a BER sequence. All values in the Array are
|
# Converts an Array to a BER sequence. All values in the Array are
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
##
|
||||||
|
# BER extensions to the Bignum class.
|
||||||
module Net::BER::Extensions::Bignum
|
module Net::BER::Extensions::Bignum
|
||||||
##
|
##
|
||||||
# Converts a Bignum to an uncompressed BER integer.
|
# Converts a Bignum to an uncompressed BER integer.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
##
|
||||||
|
# BER extensions to +false+.
|
||||||
module Net::BER::Extensions::FalseClass
|
module Net::BER::Extensions::FalseClass
|
||||||
##
|
##
|
||||||
# Converts +false+ to the BER wireline representation of +false+.
|
# Converts +false+ to the BER wireline representation of +false+.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
##
|
||||||
|
# Ber extensions to the Fixnum class.
|
||||||
module Net::BER::Extensions::Fixnum
|
module Net::BER::Extensions::Fixnum
|
||||||
##
|
##
|
||||||
# Converts the fixnum to BER format.
|
# Converts the fixnum to BER format.
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
|
||||||
|
##
|
||||||
|
# BER extensions to the String class.
|
||||||
module Net::BER::Extensions::String
|
module Net::BER::Extensions::String
|
||||||
##
|
##
|
||||||
# Converts a string to a BER string. Universal octet-strings are tagged
|
# Converts a string to a BER string. Universal octet-strings are tagged
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
##
|
||||||
|
# BER extensions to +true+.
|
||||||
module Net::BER::Extensions::TrueClass
|
module Net::BER::Extensions::TrueClass
|
||||||
##
|
##
|
||||||
# Converts +true+ to the BER wireline representation of +true+.
|
# Converts +true+ to the BER wireline representation of +true+.
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
|
||||||
module Net
|
module Net # :nodoc:
|
||||||
class LDAP
|
class LDAP
|
||||||
begin
|
begin
|
||||||
require 'openssl'
|
require 'openssl'
|
||||||
|
##
|
||||||
|
# Set to +true+ if OpenSSL is available and LDAPS is supported.
|
||||||
HasOpenSSL = true
|
HasOpenSSL = true
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
# :stopdoc:
|
||||||
HasOpenSSL = false
|
HasOpenSSL = false
|
||||||
|
# :startdoc:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,16 +23,6 @@ require 'net/ldap/dataset'
|
||||||
require 'net/ldap/password'
|
require 'net/ldap/password'
|
||||||
require 'net/ldap/entry'
|
require 'net/ldap/entry'
|
||||||
|
|
||||||
# == Net::LDAP
|
|
||||||
#
|
|
||||||
# This library provides a pure-Ruby implementation of the LDAP client
|
|
||||||
# protocol, per RFC-2251. It can be used to access any server which
|
|
||||||
# implements the LDAP protocol.
|
|
||||||
#
|
|
||||||
# Net::LDAP is intended to provide full LDAP functionality while hiding the
|
|
||||||
# more arcane aspects the LDAP protocol itself, and thus presenting as
|
|
||||||
# Ruby-like a programming interface as possible.
|
|
||||||
#
|
|
||||||
# == Quick-start for the Impatient
|
# == Quick-start for the Impatient
|
||||||
# === Quick Example of a user-authentication against an LDAP directory:
|
# === Quick Example of a user-authentication against an LDAP directory:
|
||||||
#
|
#
|
||||||
|
@ -246,7 +240,7 @@ require 'net/ldap/entry'
|
||||||
# and then keeps it open while it executes a user-supplied block.
|
# and then keeps it open while it executes a user-supplied block.
|
||||||
# Net::LDAP#open closes the connection on completion of the block.
|
# Net::LDAP#open closes the connection on completion of the block.
|
||||||
class Net::LDAP
|
class Net::LDAP
|
||||||
VERSION = "0.1.1"
|
VERSION = "0.2"
|
||||||
|
|
||||||
class LdapError < StandardError; end
|
class LdapError < StandardError; end
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,3 @@
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Gmail: garbagecat10
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
#
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# An LDAP Dataset. Used primarily as an intermediate format for converting
|
# An LDAP Dataset. Used primarily as an intermediate format for converting
|
||||||
# to and from LDIF strings and Net::LDAP::Entry objects.
|
# to and from LDIF strings and Net::LDAP::Entry objects.
|
||||||
|
@ -28,77 +6,6 @@ class Net::LDAP::Dataset < Hash
|
||||||
# Dataset object comments.
|
# Dataset object comments.
|
||||||
attr_reader :comments
|
attr_reader :comments
|
||||||
|
|
||||||
class << self
|
|
||||||
class ChompedIO #:nodoc:
|
|
||||||
def initialize(io)
|
|
||||||
@io = io
|
|
||||||
end
|
|
||||||
def gets
|
|
||||||
s = @io.gets
|
|
||||||
s.chomp if s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
|
||||||
# Reads an object that returns data line-wise (using #gets) and parses
|
|
||||||
# LDIF data into a Dataset object.
|
|
||||||
def read_ldif(io) #:yields: entry-type, value Used mostly for debugging.
|
|
||||||
ds = Net::LDAP::Dataset.new
|
|
||||||
io = ChompedIO.new(io)
|
|
||||||
|
|
||||||
line = io.gets
|
|
||||||
dn = nil
|
|
||||||
|
|
||||||
while line
|
|
||||||
new_line = io.gets
|
|
||||||
|
|
||||||
if new_line =~ /^[\s]+/
|
|
||||||
line << " " << $'
|
|
||||||
else
|
|
||||||
nextline = new_line
|
|
||||||
|
|
||||||
if line =~ /^#/
|
|
||||||
ds.comments << line
|
|
||||||
yield :comment, line if block_given?
|
|
||||||
elsif line =~ /^dn:[\s]*/i
|
|
||||||
dn = $'
|
|
||||||
ds[dn] = Hash.new { |k,v| k[v] = [] }
|
|
||||||
yield :dn, dn if block_given?
|
|
||||||
elsif line.empty?
|
|
||||||
dn = nil
|
|
||||||
yield :end, nil if block_given?
|
|
||||||
elsif line =~ /^([^:]+):([\:]?)[\s]*/
|
|
||||||
# $1 is the attribute name
|
|
||||||
# $2 is a colon iff the attr-value is base-64 encoded
|
|
||||||
# $' is the attr-value
|
|
||||||
# Avoid the Base64 class because not all Ruby versions have it.
|
|
||||||
attrvalue = ($2 == ":") ? $'.unpack('m').shift : $'
|
|
||||||
ds[dn][$1.downcase.to_sym] << attrvalue
|
|
||||||
yield :attr, [$1.downcase.to_sym, attrvalue] if block_given?
|
|
||||||
end
|
|
||||||
|
|
||||||
line = nextline
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ds
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
|
||||||
# Creates a Dataset object from an Entry object. Used mostly to assist
|
|
||||||
# with the conversion of
|
|
||||||
def from_entry(entry)
|
|
||||||
dataset = Net::LDAP::Dataset.new
|
|
||||||
hash = { }
|
|
||||||
entry.each_attribute do |attribute, value|
|
|
||||||
next if attribute == :dn
|
|
||||||
hash[attribute] = value
|
|
||||||
end
|
|
||||||
dataset[entry.dn] = hash
|
|
||||||
dataset
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def initialize(*args, &block) # :nodoc:
|
def initialize(*args, &block) # :nodoc:
|
||||||
super
|
super
|
||||||
@comments = []
|
@comments = []
|
||||||
|
@ -152,6 +59,7 @@ class Net::LDAP::Dataset < Hash
|
||||||
ary
|
ary
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
# This is an internal convenience method to determine if a value requires
|
# This is an internal convenience method to determine if a value requires
|
||||||
# base64-encoding before conversion to LDIF output. The standard approach
|
# base64-encoding before conversion to LDIF output. The standard approach
|
||||||
# in most LDAP tools is to check whether the value is a password, or if
|
# in most LDAP tools is to check whether the value is a password, or if
|
||||||
|
@ -162,13 +70,84 @@ class Net::LDAP::Dataset < Hash
|
||||||
# why we handle the simplest cases first. Ideally, we would also test the
|
# why we handle the simplest cases first. Ideally, we would also test the
|
||||||
# first/last byte, but it's a bit harder to do this in a way that's
|
# first/last byte, but it's a bit harder to do this in a way that's
|
||||||
# compatible with both 1.8.6 and 1.8.7.
|
# compatible with both 1.8.6 and 1.8.7.
|
||||||
def value_is_binary?(value)
|
def value_is_binary?(value) # :nodoc:
|
||||||
value = value.to_s
|
value = value.to_s
|
||||||
return true if value[0] == ?: or value[0] == ?<
|
return true if value[0] == ?: or value[0] == ?<
|
||||||
value.each_byte { |byte| return true if (byte < 32) || (byte > 126) }
|
value.each_byte { |byte| return true if (byte < 32) || (byte > 126) }
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
private :value_is_binary?
|
private :value_is_binary?
|
||||||
|
|
||||||
|
class << self
|
||||||
|
class ChompedIO # :nodoc:
|
||||||
|
def initialize(io)
|
||||||
|
@io = io
|
||||||
|
end
|
||||||
|
def gets
|
||||||
|
s = @io.gets
|
||||||
|
s.chomp if s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates a Dataset object from an Entry object. Used mostly to assist
|
||||||
|
# with the conversion of
|
||||||
|
def from_entry(entry)
|
||||||
|
dataset = Net::LDAP::Dataset.new
|
||||||
|
hash = { }
|
||||||
|
entry.each_attribute do |attribute, value|
|
||||||
|
next if attribute == :dn
|
||||||
|
hash[attribute] = value
|
||||||
|
end
|
||||||
|
dataset[entry.dn] = hash
|
||||||
|
dataset
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Reads an object that returns data line-wise (using #gets) and parses
|
||||||
|
# LDIF data into a Dataset object.
|
||||||
|
def read_ldif(io)
|
||||||
|
ds = Net::LDAP::Dataset.new
|
||||||
|
io = ChompedIO.new(io)
|
||||||
|
|
||||||
|
line = io.gets
|
||||||
|
dn = nil
|
||||||
|
|
||||||
|
while line
|
||||||
|
new_line = io.gets
|
||||||
|
|
||||||
|
if new_line =~ /^[\s]+/
|
||||||
|
line << " " << $'
|
||||||
|
else
|
||||||
|
nextline = new_line
|
||||||
|
|
||||||
|
if line =~ /^#/
|
||||||
|
ds.comments << line
|
||||||
|
yield :comment, line if block_given?
|
||||||
|
elsif line =~ /^dn:[\s]*/i
|
||||||
|
dn = $'
|
||||||
|
ds[dn] = Hash.new { |k,v| k[v] = [] }
|
||||||
|
yield :dn, dn if block_given?
|
||||||
|
elsif line.empty?
|
||||||
|
dn = nil
|
||||||
|
yield :end, nil if block_given?
|
||||||
|
elsif line =~ /^([^:]+):([\:]?)[\s]*/
|
||||||
|
# $1 is the attribute name
|
||||||
|
# $2 is a colon iff the attr-value is base-64 encoded
|
||||||
|
# $' is the attr-value
|
||||||
|
# Avoid the Base64 class because not all Ruby versions have it.
|
||||||
|
attrvalue = ($2 == ":") ? $'.unpack('m').shift : $'
|
||||||
|
ds[dn][$1.downcase.to_sym] << attrvalue
|
||||||
|
yield :attr, [$1.downcase.to_sym, attrvalue] if block_given?
|
||||||
|
end
|
||||||
|
|
||||||
|
line = nextline
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ds
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'net/ldap/entry' unless defined? Net::LDAP::Entry
|
require 'net/ldap/entry' unless defined? Net::LDAP::Entry
|
||||||
|
|
|
@ -1,27 +1,3 @@
|
||||||
# LDAP Entry (search-result) support classes
|
|
||||||
#
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Gmail: garbagecat10
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
#
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Objects of this class represent individual entries in an LDAP directory.
|
# Objects of this class represent individual entries in an LDAP directory.
|
||||||
# User code generally does not instantiate this class. Net::LDAP#search
|
# User code generally does not instantiate this class. Net::LDAP#search
|
||||||
|
|
|
@ -1,25 +1,4 @@
|
||||||
# Encoding: UTF-8
|
# -*- ruby encoding: utf-8 -*-
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca and other contributors. All
|
|
||||||
# Rights Reserved.
|
|
||||||
#
|
|
||||||
# Gmail: garbagecat10
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by the Free
|
|
||||||
# Software Foundation; either version 2 of the License, or (at your option)
|
|
||||||
# any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but
|
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
# for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to:
|
|
||||||
# Free Software Foundation, Inc.
|
|
||||||
# 51 Franklin St, Fifth Floor
|
|
||||||
# Boston, MA 02110-1301
|
|
||||||
# USA
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Class Net::LDAP::Filter is used to constrain LDAP searches. An object of
|
# Class Net::LDAP::Filter is used to constrain LDAP searches. An object of
|
||||||
|
|
|
@ -1,25 +1,3 @@
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Gmail: garbagecat10
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
#
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,3 @@
|
||||||
# LDAP PDU support classes
|
|
||||||
#
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Gmail: garbagecat10
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
#
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -261,7 +237,8 @@ end
|
||||||
|
|
||||||
module Net
|
module Net
|
||||||
##
|
##
|
||||||
# Handle the renamed constants.
|
# Handle renamed constants Net::LdapPdu (Net::LDAP::PDU) and
|
||||||
|
# Net::LdapPduError (Net::LDAP::PDU::Error).
|
||||||
def self.const_missing(name) #:nodoc:
|
def self.const_missing(name) #:nodoc:
|
||||||
case name.to_s
|
case name.to_s
|
||||||
when "LdapPdu"
|
when "LdapPdu"
|
||||||
|
@ -276,4 +253,3 @@ module Net
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # module Net
|
end # module Net
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module Net
|
|
||||||
class LDIF
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
# :stopdoc:
|
||||||
module Net
|
module Net
|
||||||
|
|
||||||
class SNMP
|
class SNMP
|
||||||
VERSION = '0.1.0'
|
VERSION = '0.2'
|
||||||
|
|
||||||
AsnSyntax = Net::BER.compile_syntax({
|
AsnSyntax = Net::BER.compile_syntax({
|
||||||
:application => {
|
:application => {
|
||||||
|
@ -264,4 +264,4 @@ module Net
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
require 'common'
|
require 'common'
|
||||||
|
|
||||||
require 'net/ldif'
|
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
require 'base64'
|
require 'base64'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue