Class: Net::LDAP::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/ldap.rb

Overview

Monkeypatch upstream library, for now TODO: write a real LDAP client in Rex and migrate all consumers

Defined Under Namespace

Modules: SynchronousRead

Instance Method Summary collapse

Constructor Details

#initialize(server) {|_self| ... } ⇒ Connection

Returns a new instance of Connection.

Yields:

  • (_self)

Yield Parameters:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rex/proto/ldap.rb', line 24

def initialize(server)
  begin
    @conn = Rex::Socket::Tcp.create(
      'PeerHost' => server[:host],
      'PeerPort' => server[:port],
      'Proxies' => server[:proxies]
    )
    @conn.extend(SynchronousRead)
  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]
  end

  yield self if block_given?
end