Ruby on Rails
ActiveLDAP

Ruby/ActiveLdap provides an object oriented interface to LDAP. This library was inspired by ActiveRecord (both the concept and the library). It maps LDAP entries to Ruby objects with LDAP attribute accessors exposed as methods dynamically assigned based on your LDAP schema and each object’s objectClasses.

http://rubyforge.org/projects/ruby-activeldap
http://code.google.com/p/ruby-activeldap/

Using ActiveLdap with Apple’s OpenDirectory

Apple’s OpenDirectory has some attributes whose names contain ’-’ characters which are not permitted in method names. When ActiveLdap maps the attributes to methods it does not attempt to change the characters to correct the incompatibility.

To fix the problem, I added the following to my base LDAP class:


    def define_attribute_methods(attr)

      if @attr_methods.has_key? attr
        return
      end
      aliases = Base.schema.attribute_aliases(attr)
      aliases.each do |ali|

      @attr_methods[ali.gsub(/-/,'_')] = attr
      end
    end

    def make_subtypes(attr, value)

      return [attr.gsub(/-/,'_'), value] unless attr.match(/;/)

      ret_attr, *subtypes = attr.split(/;/)
      return [ret_attr.gsub(/-/,'_'), [make_subtypes_helper(subtypes, value)]]
    end

-John

2006-07-11 What about a rails scaffold generator?

2007-05-10 parasew: changed the wording from “ActiveLDAP” to “ActiveLdap”, since it was changed by the ActiveLdap Developers