Class: ROM::LDAP::Client Private

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Includes:
Authentication, Operations
Defined in:
lib/rom/ldap/client.rb,
lib/rom/ldap/client/operations.rb,
lib/rom/ldap/client/authentication.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Authentication, Operations

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#bind, #sasl_bind, #start_tls

Methods included from Operations

#add, #delete, #password_modify, #rename, #search, #update

Instance Attribute Details

#hostString (readonly)

Returns:

  • (String)


26
# File 'lib/rom/ldap/client.rb', line 26

option :host, reader: :private, type: Types::Strict::String

#socketObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/rom/ldap/client.rb', line 37

def socket
  @socket
end

Instance Method Details

#alive?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/rom/ldap/client.rb', line 77

def alive?
  return false if closed?

  if IO.select([socket], nil, nil, 0)
    begin
      !socket.eof?
    rescue StandardError
      false
    end
  else
    true
  end
rescue IOError
  false
end

#closeNilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (NilClass)


68
69
70
71
72
73
# File 'lib/rom/ldap/client.rb', line 68

def close
  return if socket.nil?

  socket.close
  @socket = nil
end

#closed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


62
63
64
# File 'lib/rom/ldap/client.rb', line 62

def closed?
  socket.nil? || (socket.is_a?(::Socket) && socket.closed?)
end

#open {|Socket| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create connection (encrypted) and authenticate.

Yields:

Raises:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rom/ldap/client.rb', line 44

def open
  unless alive?
    @socket = Socket.new(options).call

    # tls
    if ssl
      start_tls
      sasl_bind # (mechanism:, credentials:, challenge:)
    end

    bind(auth) unless auth.nil? # simple auth
  end

  yield(@socket)
end