Commit 8745cc5399c8bf8a13a20dd5e8a41bc59161d0cf:
    Cleanup only - no functional changes
    *) Use documented interface for getting the LDAP hostname
    *) construct equivalent ldapsearch command only once
    *) reraise exception vs raising new exception (affects stack traceback)


Branch: refs/heads/master
Author: Sam Ruby <[email protected]>
Committer: Sam Ruby <[email protected]>
Pusher: rubys <[email protected]>

------------------------------------------------------------
lib/whimsy/asf/ldap.rb                                       | ++++++ ------
------------------------------------------------------------
12 changes: 6 additions, 6 deletions.
------------------------------------------------------------


diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 6890304..c1cc777 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -123,17 +123,17 @@ def self.search_one(base, filter, attrs=nil)
     init_ldap unless defined? @ldap
     return [] unless @ldap
 
-    target = @ldap.instance_variable_get('@args').join(":") rescue '?'
-
-    Wunderbar.info "[#{target}] ldapsearch -x -LLL -b #{base} -s one #{filter} 
" +
+    target = @ldap.get_option(LDAP::LDAP_OPT_HOST_NAME) rescue '?'
+    cmd = "ldapsearch -x -LLL -b #{base} -s one #{filter} " +
       "#{[attrs].flatten.join(' ')}"
 
+    Wunderbar.info "[#{target}] #{cmd}"
+
     begin
       result = @ldap.search2(base, ::LDAP::LDAP_SCOPE_ONELEVEL, filter, attrs)
     rescue Exception => re
-      Wunderbar.warn "[#{target}] => #{re.inspect} for ldapsearch -x -LLL -b 
#{base} -s one #{filter} " +
-        "#{[attrs].flatten.join(' ')}"
-      raise re
+      Wunderbar.warn "[#{target}] => #{re.inspect} for #{cmd}"
+      raise
     end
 
     result.map! {|hash| hash[attrs]} if String === attrs

Reply via email to