Module: ActiveLdap::Operations::LDIF

Defined in:
lib/active_ldap/operations.rb

Defined Under Namespace

Modules: AddRecordLoadable, ContentRecordLoadable, DeleteRecordLoadable, ModifyNameRecordLoadable, ModifyRecordLoadable

Instance Method Summary collapse

Instance Method Details

#dump(options = {}) ⇒ Object



324
325
326
327
328
329
330
331
332
333
# File 'lib/active_ldap/operations.rb', line 324

def dump(options={})
  ldif = Ldif.new
  options = {:base => base, :scope => scope}.merge(options)
  options[:connection] ||= connection
  options[:connection].search(options) do |dn, attributes|
    ldif << Ldif::Record.new(dn, attributes)
  end
  return "" if ldif.records.empty?
  ldif.to_s
end

#load(ldif, options = {}) ⇒ Object



340
341
342
343
344
345
# File 'lib/active_ldap/operations.rb', line 340

def load(ldif, options={})
  return if ldif.blank?
  Ldif.parse(ldif).each do |record|
    record.load(self, options)
  end
end

#to_ldif(dn, attributes) ⇒ Object



335
336
337
338
# File 'lib/active_ldap/operations.rb', line 335

def to_ldif(dn, attributes)
  record = Ldif::Record.new(dn, attributes)
  Ldif.new([record]).to_s
end