Method: Ldaptic::DN#initialize
- Defined in:
- lib/ldaptic/dn.rb
#initialize(dn, source = nil) ⇒ DN
Create a new Ldaptic::DN object. dn can either be a string, or an array of pairs.
Ldaptic::DN([{:cn=>"Thomas, David"}, {:dc=>"pragprog"}, {:dc=>"com"}])
# => "CN=Thomas\\, David,DC=pragprog,DC=com"
The optional second object specifies either an LDAP::Conn object or a Ldaptic object to be used to find the DN with #find.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ldaptic/dn.rb', line 49 def initialize(dn, source = nil) @source = source dn = dn.dn if dn.respond_to?(:dn) if dn.respond_to?(:to_ary) dn = dn.map do |pair| if pair.kind_of?(Hash) Ldaptic::RDN(pair).to_str else pair end end * ',' end if dn.include?(".") && !dn.include?("=") dn = dn.split(".").map {|dc| "DC=#{Ldaptic.escape(dc)}"} * "," end super(dn) end |