Skip to content

Commit 493b81b

Browse files
author
blackhedd
committed
added Net::LDAP::Entry#to_ldif
1 parent fb4b2ba commit 493b81b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/net/ldap/entry.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ def each
128128
alias_method :each_attribute, :each
129129

130130

131+
132+
# Converts the Entry to a String, representing the
133+
# Entry's attributes in LDIF format.
134+
def to_ldif
135+
ary = []
136+
ary << "dn: #{dn}\n"
137+
each_attribute do |k,v|
138+
v.each {|v1|
139+
ary << "#{k}: #{v1}\n" unless k == :dn
140+
}
141+
end
142+
ary << "\n"
143+
ary.join
144+
end
145+
146+
131147
#--
132148
# Convenience method to convert unknown method names
133149
# to attribute references. Of course the method name

0 commit comments

Comments
 (0)