Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 11 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 08, 2010
Nowhere Man Converts the Filter object to an RFC 2254-compatible text format.
Backporting of Ruby Net::LDAP v0.2.
http://github.com/halostatue/ruby-net-ldap
399255d
Nowhere Man Added Filter.join(left, right), Filter.intersect(left, right), and Fi…
…lter.negate(filtr) to match Filter#&, Filter#|, and Filter#~@.

Added Filter.present and Filter.present? aliases for the method previously only known as Filter.pres.

Backporting of Ruby Net::LDAP v0.2.
http://github.com/halostatue/ruby-net-ldap
c160cc4
Nowhere Man Renamed Gem in "my-ruby-net-ldap". 01970f8
Nowhere Man Updated GemSpec. 8a6b0fd
Nowhere Man Updated GemSpec. 86761a8
Nowhere Man Updated GemSpec and Rakefile. ed5890c
Nowhere Man Updated Rakefile, README and GemSpec. 64102aa
Nowhere Man Regenerated gemspec for version 0.5.0 628ab56
Nowhere Man Updated README. 0cfa1c9
Nowhere Man Updated README. 1b51d74
Nowhere Man Updated Rakefile and GemSpec. 8bf9523
View
0  History.txt → History.rdoc
File renamed without changes
View
30 Manifest.txt
@@ -1,30 +0,0 @@
-COPYING
-History.txt
-LICENSE
-Manifest.txt
-README.txt
-Rakefile
-Release-Announcement
-lib/net/ber.rb
-lib/net/ldap.rb
-lib/net/ldap/dataset.rb
-lib/net/ldap/entry.rb
-lib/net/ldap/filter.rb
-lib/net/ldap/pdu.rb
-lib/net/ldap/psw.rb
-lib/net/ldif.rb
-lib/net/snmp.rb
-pre-setup.rb
-setup.rb
-test/common.rb
-test/test_ber.rb
-test/test_entry.rb
-test/test_filter.rb
-test/test_ldif.rb
-test/test_password.rb
-test/test_snmp.rb
-test/testdata.ldif
-tests/NOTICE.txt
-tests/testldap.rb
-testserver/ldapserver.rb
-testserver/testdata.ldif
View
7 README.txt → README.rdoc
@@ -1,6 +1,6 @@
= Net::LDAP for Ruby
-* http://github.com/dim/ruby-net-ldap
+* http://github.com/nowhereman/ruby-net-ldap
== DESCRIPTION:
@@ -19,6 +19,8 @@ well.
* Standards-based (going for RFC 4511)
* Portable: 100% Ruby
+* Compatible with Ruby 1.8.6.
+* Backporting some Ruby Net::LDAP v0.2 features.
== INSTALL:
@@ -28,7 +30,7 @@ libraries.
You can install the RubyGems version of Net::LDAP available at
GitHub:
-* gem install dim-ruby-net-ldap --source=http://gems.github.com
+ gem install my-ruby-net-ldap --source=http://rubygems.org
== SYNOPSIS:
@@ -45,6 +47,7 @@ Contributions since:
* Austin Ziegler <halostatue@gmail.com>
* Emiel van de Laar <gemiel@gmail.com>
* Dimitrij Denissenko <contact@dvisionfactory.com>
+* Nowhere Man
== LICENSE:
View
29 Rakefile
@@ -1,7 +1,6 @@
# -*- ruby -*-
require 'rubygems'
-require 'hoe'
# Add 'lib' to load path.
$LOAD_PATH.unshift( "#{File.dirname(__FILE__)}/lib" )
@@ -9,21 +8,23 @@ $LOAD_PATH.unshift( "#{File.dirname(__FILE__)}/lib" )
# Pull in local 'net/ldap' as opposed to an installed version.
require 'net/ldap'
-Hoe.new('ruby-net-ldap', Net::LDAP::VERSION) do |p|
- p.developer('Francis Cianfrocca', 'garbagecat10@gmail.com')
- p.developer('Emiel van de Laar', 'gemiel@gmail.com')
-end
-
begin
require 'jeweler'
- Jeweler::Tasks.new do |spec|
- spec.name = "ruby-net-ldap"
- spec.summary = "Pure Ruby LDAP library"
- spec.email = "contact@dvisionfactory.com"
- spec.homepage = "http://github.com/dim/ruby-net-ldap"
- spec.description = "Net::LDAP is a feature-complete LDAP support library written in pure Ruby. It supports most LDAP client features and a subset of server features as well."
- spec.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Tom Copeland", "Austin Ziegler", "Dimitrij Denissenko"]
- spec.test_files = Dir.glob('test*/**')
+ Jeweler::Tasks.new do |s|
+ s.name = "my-ruby-net-ldap"
+ s.summary = "Pure Ruby LDAP library"
+ s.email = "contact@dvisionfactory.com"
+ s.homepage = "http://github.com/nowhereman/ruby-net-ldap"
+ s.rubyforge_project = "net-ldap"
+ s.description = "Net::LDAP is a feature-complete LDAP support library written in pure Ruby. It supports most LDAP client features and a subset of server features as well."
+ s.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Tom Copeland", "Austin Ziegler", "Dimitrij Denissenko", "Nowhere Man"]
+ s.test_files = Dir.glob('test*/**')
+ s.extra_rdoc_files = [
+ "History.rdoc",
+ "LICENSE",
+ "README.rdoc",
+ "COPYING"
+ ]
end
Jeweler::GemcutterTasks.new
rescue LoadError
View
197 lib/net/ldap/filter.rb
@@ -54,41 +54,144 @@ def initialize op, a, b
@right = b
end
- # #eq creates a filter object indicating that the value of
- # a paticular attribute must be either <i>present</i> or must
- # match a particular string.
- #
- # To specify that an attribute is "present" means that only
- # directory entries which contain a value for the particular
- # attribute will be selected by the filter. This is useful
- # in case of optional attributes such as <tt>mail.</tt>
- # Presence is indicated by giving the value "*" in the second
- # parameter to #eq. This example selects only entries that have
- # one or more values for <tt>sAMAccountName:</tt>
- # f = Net::LDAP::Filter.eq( "sAMAccountName", "*" )
- #
- # To match a particular range of values, pass a string as the
- # second parameter to #eq. The string may contain one or more
- # "*" characters as wildcards: these match zero or more occurrences
- # of any character. Full regular-expressions are <i>not</i> supported
- # due to limitations in the underlying LDAP protocol.
- # This example selects any entry with a <tt>mail</tt> value containing
- # the substring "anderson":
- # f = Net::LDAP::Filter.eq( "mail", "*anderson*" )
- #--
- # Removed gt and lt. They ain't in the standard!
- #
- def Filter::eq attribute, value; Filter.new :eq, attribute, value; end
- def Filter::ne attribute, value; Filter.new :ne, attribute, value; end
- def Filter::ex attribute, value; Filter.new :ex, attribute, value; end
- #def Filter::gt attribute, value; Filter.new :gt, attribute, value; end
- #def Filter::lt attribute, value; Filter.new :lt, attribute, value; end
- def Filter::ge attribute, value; Filter.new :ge, attribute, value; end
- def Filter::le attribute, value; Filter.new :le, attribute, value; end
-
- # #pres( attribute ) is a synonym for #eq( attribute, "*" )
- #
- def Filter::pres attribute; Filter.eq attribute, "*"; end
+ class << self
+ ##
+ # Creates a Filter object indicating that the value of a particular
+ # attribute must either be present or match a particular string.
+ #
+ # Specifying that an attribute is 'present' means only directory entries
+ # which contain a value for the particular attribute will be selected by
+ # the filter. This is useful in case of optional attributes such as
+ # <tt>mail.</tt> Presence is indicated by giving the value "*" in the
+ # second parameter to #eq. This example selects only entries that have
+ # one or more values for <tt>sAMAccountName:</tt>
+ #
+ # f = Net::LDAP::Filter.eq("sAMAccountName", "*")
+ #
+ # To match a particular range of values, pass a string as the second
+ # parameter to #eq. The string may contain one or more "*" characters as
+ # wildcards: these match zero or more occurrences of any character. Full
+ # regular-expressions are <i>not</i> supported due to limitations in the
+ # underlying LDAP protocol. This example selects any entry with a
+ # <tt>mail</tt> value containing the substring "anderson":
+ #
+ # f = Net::LDAP::Filter.eq("mail", "*anderson*")
+ def eq(attribute, value)
+ new(:eq, attribute, value)
+ end
+
+ ##
+ # Creates a Filter object indicating extensible comparison. This Filter
+ # object is currently considered EXPERIMENTAL.
+ #
+ # sample_attributes = ['cn:fr', 'cn:fr.eq',
+ # 'cn:1.3.6.1.4.1.42.2.27.9.4.49.1.3', 'cn:dn:fr', 'cn:dn:fr.eq']
+ # attr = sample_attributes.first # Pick an extensible attribute
+ # value = 'roberts'
+ #
+ # filter = "#{attr}:=#{value}" # Basic String Filter
+ # dc: example
+ #
+ # dn: ou=People,dc=example,dc=com
+ # objectClass: organizationalUnit
+ # objectClass: top
+ # ou: People
+ #
+ # dn: uid=1,ou=People,dc=example,dc=com
+ # objectClass: person
+ # objectClass: organizationalPerson
+ # objectClass: inetOrgPerson
+ # objectClass: top
+ # cn:: csO0YsOpcnRz
+ # sn:: YsO0YiByw7Riw6lydHM=
+ # givenName:: YsO0Yg==
+ # uid: 1
+ #
+ # =Refs:
+ # * http://www.ietf.org/rfc/rfc2251.txt
+ # * http://www.novell.com/documentation/edir88/edir88/?page=/documentation/edir88/edir88/data/agazepd.html
+ # * https://docs.opends.org/2.0/page/SearchingUsingInternationalCollationRules
+ #++
+ def ex(attribute, value)
+ new(:ex, attribute, value)
+ end
+
+ ##
+ # Creates a Filter object indicating that a particular attribute value
+ # is either not present or does not match a particular string; see
+ # Filter::eq for more information.
+ def ne(attribute, value)
+ new(:ne, attribute, value)
+ end
+
+ ##
+ # Creates a Filter object indicating that a particular attribute value
+ # is greater than or equal to the specified value.
+ def ge(attribute, value)
+ new(:ge, attribute, value)
+ end
+
+ ##
+ # Creates a Filter object indicating that a particular attribute value
+ # is less than or equal to the specified value.
+ def le(attribute, value)
+ new(:le, attribute, value)
+ end
+
+ ##
+ # Joins two or more filters so that all conditions must be true. Calling
+ # <tt>Filter.join(left, right)</tt> is the same as <tt>left &
+ # right</tt>.
+ #
+ # # Selects only entries that have an <tt>objectclass</tt> attribute.
+ # x = Net::LDAP::Filter.present("objectclass")
+ # # Selects only entries that have a <tt>mail</tt> attribute that begins
+ # # with "George".
+ # y = Net::LDAP::Filter.eq("mail", "George*")
+ # # Selects only entries that meet both conditions above.
+ # z = Net::LDAP::Filter.join(x, y)
+ def join(left, right)
+ Filter.new(:and, left, right)
+ end
+
+ ##
+ # Creates a disjoint comparison between two or more filters. Selects
+ # entries where either the left or right side are true. Calling
+ # <tt>Filter.intersect(left, right)</tt> is the same as <tt>left |
+ # right</tt>.
+ #
+ # # Selects only entries that have an <tt>objectclass</tt> attribute.
+ # x = Net::LDAP::Filter.present("objectclass")
+ # # Selects only entries that have a <tt>mail</tt> attribute that begins
+ # # with "George".
+ # y = Net::LDAP::Filter.eq("mail", "George*")
+ # # Selects only entries that meet either condition above.
+ # z = x | y
+ def intersect(left, right)
+ Filter.new(:or, left, right)
+ end
+
+ ##
+ # Negates a filter. Calling <tt>Fitler.negate(filter)</tt> i s the same
+ # as <tt>~filter</tt>.
+ #
+ # # Selects only entries that do not have an <tt>objectclass</tt>
+ # # attribute.
+ # x = ~Net::LDAP::Filter.present("objectclass")
+ def negate(filter)
+ Filter.new(:not, filter, nil)
+ end
+
+ ##
+ # This is a synonym for #eq(attribute, "*"). Also known as #present and
+ # #pres.
+ def present?(attribute)
+ Filter.eq(attribute, "*")
+ end
+
+ alias_method :present, :present?
+ alias_method :pres, :present?
+ end
# operator & ("AND") is used to conjoin two or more filters.
# This expression will select only entries that have an <tt>objectclass</tt>
@@ -104,7 +207,6 @@ def & filter; Filter.new :and, self, filter; end
#
def | filter; Filter.new :or, self, filter; end
-
#
# operator ~ ("NOT") is used to negate a filter.
# This expression will select only entries that <i>do not</i> have an <tt>objectclass</tt>
@@ -122,10 +224,10 @@ def == filter
self.instance_eval(str) == filter.instance_eval(str)
end
- def to_s
+ def to_raw_rfc2254
case @op
when :ne
- "(!(#{@left}=#{@right}))"
+ "!(#{@left}=#{@right})"
when :eq
"#{@left}=#{@right}"
when :ex
@@ -139,16 +241,27 @@ def to_s
when :le
"#{@left}<=#{@right}"
when :and
- "(&(#{@left})(#{@right}))"
+ "&(#{@left.__send__(:to_raw_rfc2254)})(#{@right.__send__(:to_raw_rfc2254)})"
when :or
- "(|(#{@left})(#{@right}))"
+ "|(#{@left.__send__(:to_raw_rfc2254)})(#{@right.__send__(:to_raw_rfc2254)})"
when :not
- "(!(#{@left}))"
+ "!(#{@left})"
else
- raise "invalid or unsupported operator in LDAP Filter"
+ "!(#{@left.__send__(:to_raw_rfc2254)})"
end
end
+ private :to_raw_rfc2254
+
+ ##
+ # Converts the Filter object to an RFC 2254-compatible text format.
+ def to_rfc2254
+ "(#{to_raw_rfc2254})"
+ end
+
+ def to_s
+ to_rfc2254
+ end
#--
# to_ber
View
83 my-ruby-net-ldap.gemspec
@@ -0,0 +1,83 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE
+# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{my-ruby-net-ldap}
+ s.version = "0.5.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Tom Copeland", "Austin Ziegler", "Dimitrij Denissenko", "Nowhere Man"]
+ s.date = %q{2010-06-08}
+ s.description = %q{Net::LDAP is a feature-complete LDAP support library written in pure Ruby. It supports most LDAP client features and a subset of server features as well.}
+ s.email = %q{contact@dvisionfactory.com}
+ s.extra_rdoc_files = [
+ "COPYING",
+ "History.rdoc",
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ "COPYING",
+ "History.rdoc",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION.yml",
+ "lib/net/ber.rb",
+ "lib/net/ldap.rb",
+ "lib/net/ldap/dataset.rb",
+ "lib/net/ldap/entry.rb",
+ "lib/net/ldap/filter.rb",
+ "lib/net/ldap/pdu.rb",
+ "lib/net/ldap/psw.rb",
+ "lib/net/ldif.rb",
+ "lib/net/snmp.rb",
+ "my-ruby-net-ldap.gemspec",
+ "pre-setup.rb",
+ "setup.rb",
+ "test/common.rb",
+ "test/test_ber.rb",
+ "test/test_entry.rb",
+ "test/test_filter.rb",
+ "test/test_ldif.rb",
+ "test/test_password.rb",
+ "test/test_snmp.rb",
+ "test/testdata.ldif",
+ "tests/NOTICE.txt",
+ "tests/testldap.rb",
+ "testserver/ldapserver.rb",
+ "testserver/testdata.ldif"
+ ]
+ s.homepage = %q{http://github.com/nowhereman/ruby-net-ldap}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{net-ldap}
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{Pure Ruby LDAP library}
+ s.test_files = [
+ "testserver/testdata.ldif",
+ "testserver/ldapserver.rb",
+ "tests/testldap.rb",
+ "tests/NOTICE.txt",
+ "test/common.rb",
+ "test/test_password.rb",
+ "test/testdata.ldif",
+ "test/test_ber.rb",
+ "test/test_snmp.rb",
+ "test/test_entry.rb",
+ "test/test_filter.rb",
+ "test/test_ldif.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
View
78 ruby-net-ldap.gemspec
@@ -1,78 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{ruby-net-ldap}
- s.version = "0.0.5"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Tom Copeland", "Austin Ziegler", "Dimitrij Denissenko"]
- s.date = %q{2009-05-28}
- s.description = %q{Net::LDAP is a feature-complete LDAP support library written in pure Ruby. It supports most LDAP client features and a subset of server features as well.}
- s.email = %q{contact@dvisionfactory.com}
- s.extra_rdoc_files = [
- "LICENSE",
- "README.txt"
- ]
- s.files = [
- "COPYING",
- "History.txt",
- "LICENSE",
- "Manifest.txt",
- "README.txt",
- "Rakefile",
- "VERSION.yml",
- "lib/net/ber.rb",
- "lib/net/ldap.rb",
- "lib/net/ldap/dataset.rb",
- "lib/net/ldap/entry.rb",
- "lib/net/ldap/filter.rb",
- "lib/net/ldap/pdu.rb",
- "lib/net/ldap/psw.rb",
- "lib/net/ldif.rb",
- "lib/net/snmp.rb",
- "pre-setup.rb",
- "ruby-net-ldap.gemspec",
- "setup.rb",
- "test/common.rb",
- "test/test_ber.rb",
- "test/test_entry.rb",
- "test/test_filter.rb",
- "test/test_ldif.rb",
- "test/test_password.rb",
- "test/test_snmp.rb",
- "test/testdata.ldif",
- "tests/NOTICE.txt",
- "tests/testldap.rb",
- "testserver/ldapserver.rb",
- "testserver/testdata.ldif"
- ]
- s.homepage = %q{http://github.com/dim/ruby-net-ldap}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.3}
- s.summary = %q{Pure Ruby LDAP library}
- s.test_files = [
- "test/test_ldif.rb",
- "test/test_filter.rb",
- "test/common.rb",
- "test/test_snmp.rb",
- "test/test_ber.rb",
- "test/test_password.rb",
- "test/test_entry.rb",
- "test/testdata.ldif",
- "tests/NOTICE.txt",
- "tests/testldap.rb",
- "testserver/ldapserver.rb",
- "testserver/testdata.ldif"
- ]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- else
- end
- else
- end
-end

No commit comments for this range

Something went wrong with that request. Please try again.