lib/net/ldap.rb in net-ldap-0.1.0 vs lib/net/ldap.rb in net-ldap-0.1.1

- old
+ new

@@ -1,7 +1,8 @@ require 'openssl' require 'ostruct' +require 'socket' require 'net/ber' require 'net/ldap/pdu' require 'net/ldap/filter' require 'net/ldap/dataset' @@ -230,14 +231,14 @@ # to the server when the method is called. They execute the operation (typically binding first) # and then disconnect from the server. The exception is Net::LDAP#open, which makes a connection # to the server and then keeps it open while it executes a user-supplied block. Net::LDAP#open # closes the connection on completion of the block. class LDAP + VERSION = "0.1.1" + class LdapError < StandardError; end - VERSION = "0.1.0" - SearchScope_BaseObject = 0 SearchScope_SingleLevel = 1 SearchScope_WholeSubtree = 2 SearchScopes = [SearchScope_BaseObject, SearchScope_SingleLevel, SearchScope_WholeSubtree] @@ -1118,11 +1119,13 @@ MaxSaslChallenges = 10 def initialize server begin @conn = TCPSocket.new( server[:host], server[:port] ) - rescue - raise LdapError.new( "no connection to server" ) + rescue SocketError + raise LdapError, "No such address or other socket error." + rescue Errno::ECONNREFUSED + raise LdapError, "Server #{server[:host]} refused connection on port #{server[:port]}." end if server[:encryption] setup_encryption server[:encryption] end