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

Instance Method Summary collapse

Constructor Details

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

:nodoc:

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rex/proto/ldap.rb', line 8

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