Class | ActiveLDAP::Base |
In: |
lib/activeldap/base.rb
|
Parent: | Object |
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 | -> | __methods |
Add available attributes to the methods |
logger | [RW] | |
may | [R] | Parsed schema structures |
must | [R] | Parsed schema structures |
On connect, this is overriden by the :base argument Make the return value the string that is your LDAP 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 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=dataspill,dc=org. 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 sets the LDAP server hostname :port sets 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) :retries - indicates the number of attempts to reconnect that will be undertaken when a stale connection occurs. -1 means infinite. :sasl_quiet - if true, sets @sasl_quiet on the Ruby/LDAP connection :method - whether to use :ssl, :tls, or :plain (unencrypted) :retry_wait - seconds to wait before retrying a connection :ldap_scope - dictates how to find objects. ONELEVEL by default to avoid dn_attr collisions across OUs. Think before changing. :return_objects - indicates whether find/find_all will return objects or just the distinguished name attribute value of the matches :timeout - time in seconds - defaults to disabled. This CAN interrupt search() requests. Be warned. :retry_on_timeout - whether to reconnect when timeouts occur. Defaults to true See lib/configuration.rb for defaults for each option
Return the LDAP connection object currently in use Alternately execute a command against the connection object "safely" using a given block. Use the given "errmsg" for any error conditions.
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’])
THIS METHOD IS DANGEROUS. INPUT IS NOT SANITIZED.
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.
On connect, this is overriden by the :base argument
Set this to LDAP_SCOPE_SUBTREE if you have a LDAP tree where all objects of the same class living in different parts of the same subtree, but not. LDAP_SCOPE_ONELEVEL is for use when all the objects in your classes live under one shared level (e.g. ou=People,dc=localdomain)
This can be overriden on a per class basis in ldap_mapping :scope
Attempts to reconnect up to the number of times allowed If forced, try once then fail with ConnectionError if not connected.
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.
This is optionally set to the array of objectClass names that are minimally required for EVERY object on your LDAP server. If you don’t want one, set this to [].
search
Wraps Ruby/LDAP connection.search to make it easier to search for specific data without cracking open Base.connection
attributes
Return attribute methods so that a program can determine available attributes dynamically without schema awareness
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.