You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
760 B
34 lines
760 B
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
|