From 493b81bd6907fe0be67425ed56aee0b74a3c2c12 Mon Sep 17 00:00:00 2001 From: blackhedd Date: Fri, 18 Aug 2006 19:41:03 +0000 Subject: [PATCH] added Net::LDAP::Entry#to_ldif --- lib/net/ldap/entry.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/net/ldap/entry.rb b/lib/net/ldap/entry.rb index 625c5db..0b56cbe 100644 --- a/lib/net/ldap/entry.rb +++ b/lib/net/ldap/entry.rb @@ -128,6 +128,22 @@ class LDAP alias_method :each_attribute, :each + + # Converts the Entry to a String, representing the + # Entry's attributes in LDIF format. + def to_ldif + ary = [] + ary << "dn: #{dn}\n" + each_attribute do |k,v| + v.each {|v1| + ary << "#{k}: #{v1}\n" unless k == :dn + } + end + ary << "\n" + ary.join + end + + #-- # Convenience method to convert unknown method names # to attribute references. Of course the method name