require 'net/ldap' class DsAdmin::Storage::Ldap include DsAdmin::Storage def initialize(config) super(config) @ldap = Net::LDAP.new(@config.con(self)) end def read query = @config.query(self) ## # two things. # - create a hash from the ldap search result # - map the id's from the ldap search resulte into id's used in # the models. The mapping is read from the config. # foo = @ldap.search(query).map do |data| map = { :dn => :id } map.merge!(@config.map(self)) remapped = Hash.new data.each do |key,value| key = map[key] || key value = value.size==1 ? value[0] : value.to_a remapped.merge!({ key => value }) end remapped end end end