diff options
Diffstat (limited to 'worker/tests/ldap.rb')
-rw-r--r-- | worker/tests/ldap.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/worker/tests/ldap.rb b/worker/tests/ldap.rb new file mode 100644 index 0000000..4570f66 --- /dev/null +++ b/worker/tests/ldap.rb @@ -0,0 +1,41 @@ +require 'timeout' + + +# +# Run an LDAP test. +# +# +# Return value +# TRUE: The host is up +# +# FALSE: The host is not up +# +def ldap_test ( params ) + + # + # Get the hostname & port to test against. + # + host = params['target_host'] + port = params['test_port'] + + puts "LDAP testing host #{host}:#{port}" + + + begin + timeout(3) do + + begin + socket = TCPSocket.new( host, port ) + socket.close() + return true + rescue + puts "LDAP exception on host #{host}:#{port} - #{$!}" + return false + end + end + rescue Timeout::Error => e + puts "TIMEOUT: #{e}" + return false + end + return false +end |