ActiveLDAP::Base (Class)

In: lib/activeldap/base.rb
Parent: Object

Base

Base is the primary class which contains all of the core ActiveLDAP functionality. It is meant to only ever be subclassed by extension classes.

Methods

External Aliases

methods -> __methods
  Add available attributes to the methods

Attributes

logger  [RW] 
may  [R]  Parsed schema structures
must  [R]  Parsed schema structures

Public Class methods

Base.base

This method when included into Base provides an inheritable, overwritable configuration setting

This should be a string with the base of the ldap server such as ‘dc=example,dc=com’, and it should be overwritten by including configuration.rb into this class. When subclassing, the specified prefix will be concatenated.

Base.close This method deletes the LDAP connection object. This does NOT reset any overridden values from a Base.connect call.

Connect and bind to LDAP creating a class variable for use by all ActiveLDAP objects.

config

config must be a hash that may contain any of the following fields: :user, :password_block, :logger, :host, :port, :base, :bind_format, :try_sasl, :allow_anonymous :user specifies the username to bind with. :bind_format specifies the string to substitute the username into on bind. e.g. uid=%s,ou=People,dc=example,dc=com. Overrides @@bind_format. :password_block specifies a Proc object that will yield a String to be used as the password when called. :logger specifies a preconfigured Log4r::Logger to be used for all logging :host overrides the configuration.rb @@host setting with the LDAP server hostname :port overrides the configuration.rb @@port setting for the LDAP server port :base overwrites Base.base - this affects EVERYTHING :try_sasl indicates that a SASL bind should be attempted when binding to the server (default: false) :allow_anonymous indicates that a true anonymous bind is allowed when trying to bind to the server (default: true)

Return the LDAP connection object currently in use

Set the LDAP connection avoiding Base.connect or multiplexing connections

Driver generator

TODO add type checking This let’s you call this method to create top-level extension object. This is really just a proof of concept and has not truly useful purpose. example: Base.create_object(:class => "user", :dnattr => "uid", :classes => [‘top’])

Base.dnattr

This is a placeholder for the class method that will be overridden on calling ldap_mapping in a subclass. Using a class method allows for clean inheritance from classes that already have a ldap_mapping.

Base.required_classes

This method when included into Base provides an inheritable, overwritable configuration setting

The value should be the minimum required objectClasses to make an object in the LDAP server, or an empty array []. This should be overwritten by configuration.rb. Note that subclassing does not cause concatenation of arrays to occurs.

Return the schema object

search

Wraps Ruby/LDAP connection.search to make it easier to search for specific data without cracking open Base.connection

Public Instance methods

attributes

Return attribute methods so that a program can determine available attributes dynamically without schema awareness

delete

Delete this entry from LDAP

dn

Return the authoritative dn

exists?

Return whether the entry exists in LDAP or not

method_missing

If a given method matches an attribute or an attribute alias then call the appropriate method. TODO: Determine if it would be better to define each allowed method

      using class_eval instead of using method_missing.  This would
      give tab completion in irb.

validate

Basic validation:

  • Verify that every ‘MUST’ specified in the schema has a value defined
  • Enforcement of undefined attributes is handled in the objectClass= method

Must call enforce_types() first before enforcement can be guaranteed

write

Write and validate this object into LDAP either adding or replacing attributes TODO: Binary data support TODO: Relative DN support

[Validate]