Class: Net::LDAP::Connection
- Inherits:
-
Object
- Object
- Net::LDAP::Connection
- Defined in:
- lib/rex/proto/ldap.rb
Overview
Update Net::LDAP’s initialize and new_connection method to honor a tracking proxies setting
Direct Known Subclasses
Defined Under Namespace
Modules: ConnectionSaslIO, SocketSaslIO, SynchronousRead
Instance Method Summary collapse
-
#initialize(server) {|_self| ... } ⇒ Connection
constructor
Initialize the LDAP connection using Rex::Socket::TCP, and optionally set up encryption on the connection if configured.
Constructor Details
#initialize(server) {|_self| ... } ⇒ Connection
Initialize the LDAP connection using Rex::Socket::TCP, and optionally set up encryption on the connection if configured.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/rex/proto/ldap.rb', line 184 def initialize(server) begin @conn = Rex::Socket::Tcp.create( 'PeerHost' => server[:host], 'PeerPort' => server[:port], 'Proxies' => server[:proxies], 'Timeout' => server[:connect_timeout] ) @conn.extend(SynchronousRead) # Set up read/write wrapping self.extend(ConnectionSaslIO) rescue SocketError raise Net::LDAP::LdapError, 'No such address or other socket error.' rescue Errno::ECONNREFUSED raise Net::LDAP::LdapError, "Server #{server[:host]} refused connection on port #{server[:port]}." end if server[:encryption] setup_encryption server[:encryption] @conn.extend Forwardable @conn.def_delegators :@io, :localinfo, :peerinfo end yield self if block_given? end |