Module: Ldapter

Defined in:
lib/ldapter.rb,
lib/ldapter/entry.rb,
lib/ldapter/errors.rb,
lib/ldapter/schema.rb,
lib/ldapter/methods.rb,
lib/ldapter/adapters.rb,
lib/ldapter/syntaxes.rb,
lib/ldapter/attribute_set.rb,
lib/ldapter/before_type_cast.rb,
lib/ldapter/adapters/abstract_adapter.rb,
lib/ldapter/adapters/net_ldap_adapter.rb,
lib/ldapter/adapters/ldap_conn_adapter.rb,
lib/ldapter/adapters/active_directory_adapter.rb

Overview

Getting started

See the methods of the Ldapter module (below) for information on connecting.

See the Ldapter::Methods module for information on searching with your connection object.

Search results are Ldapter::Entry objects. See the documentation for this class for information on manipulating and updating them, as well as creating new entries.

Defined Under Namespace

Modules: Adapters, BeforeTypeCast, Errors, Methods, Schema, Syntaxes Classes: AttributeSet, Class, Entry, Error, Module, ServerError

Constant Summary

SCOPES =
{
  :base     => 0, # ::LDAP::LDAP_SCOPE_BASE,
  :onelevel => 1, # ::LDAP::LDAP_SCOPE_ONELEVEL,
  :subtree  => 2  # ::LDAP::LDAP_SCOPE_SUBTREE
}
SYNTAXES =
{}

Class Method Summary (collapse)

Class Method Details

+ (Object) Class(options) Also known as: Namespace

The core constructor of Ldapter. This method returns an anonymous class which can then be inherited from.

The new class is not intended to be instantiated, instead serving as a namespace. Included in this namespace is a set of class methods, as found in Ldapter::Methods, and a class hierarchy mirroring the object classes found on the server.

options = {
  :adapter  => :active_directory,
  :host     => "pdc.mycompany.com",
  :username => "mylogin@mycompany.com",
  :password => "mypassword"
}

class MyCompany < Ldapter::Class(options)
  # This class and many others are created automatically based on
  # information from the server.
  class User
    alias  sAMAccountName
  end
end

me = MyCompany.search(:filter => {:cn => "Name, My"}).first
puts me.

Options given to this method are relayed to Ldapter::Adapters.for. The documentation for this method should be consulted for further information.



92
93
94
95
96
# File 'lib/ldapter.rb', line 92

def self.Class(options)
  klass = ::Class.new(Class)
  klass.instance_variable_set(:@options, Ldapter::Adapters.for(options))
  klass
end

+ (Object) Module(options)

Similar to Ldapter::Class, accepting the same options. Instead of returning an anonymous class that activates upon inheritance, it returns an anonymous module that activates upon inclusion.

module MyCompany
  include Ldapter::Module(options)
  # This class and many others are created automatically based on
  # information from the server.
  class User
    alias  sAMAccountName
  end
end

me = MyCompany.search(:filter => {:cn => "Name, My"}).first
puts me.


60
61
62
# File 'lib/ldapter.rb', line 60

def self.Module(options)
  Ldapter::Module.new(options)
end

+ (Object) Object(options, &block)

Returns an object that can be assigned directly to a variable. This allows for an "anonymous" Ldapter object.

@my_company = Ldapter::Object(options)
@my_company::User.class_eval do
  alias  sAMAccountName
end


36
37
38
39
40
41
42
43
44
# File 'lib/ldapter.rb', line 36

def self.Object(options,&block)
  base = ::Module.new do
    include Ldapter::Module(options)
  end
  if block_given?
    base.class_eval(&block)
  end
  base
end