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



402
403
404
405
406
407
408
409
410
411
# File 'lib/active_ldap/operations.rb', line 402

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



421
422
423
424
425
426
# File 'lib/active_ldap/operations.rb', line 421

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



417
418
419
# File 'lib/active_ldap/operations.rb', line 417

def to_ldif(dn, attributes)
  Ldif.new([to_ldif_record(dn, attributes)]).to_s
end

#to_ldif_record(dn, attributes) ⇒ Object



413
414
415
# File 'lib/active_ldap/operations.rb', line 413

def to_ldif_record(dn, attributes)
  Ldif::Record.new(dn, attributes)
end