Class: ActiveLdap::Adapter::Jndi

Inherits:
Base
  • Object
show all
Defined in:
lib/active_ldap/adapter/jndi.rb

Constant Summary collapse

METHOD =
{
  :ssl => :ssl,
  :tls => :start_tls,
  :plain => nil,
}

Constants inherited from Base

Base::VALID_ADAPTER_CONFIGURATION_KEYS

Instance Method Summary collapse

Methods inherited from Base

#bind, #bound?, #disconnect!, #entry_attribute, #initialize, jndi_connection, ldap_connection, #naming_contexts, net_ldap_connection, #rebind, #schema, #supported_control

Methods included from GetTextSupport

included

Constructor Details

This class inherits a constructor from ActiveLdap::Adapter::Base

Instance Method Details

#add(dn, entries, options = {}) ⇒ Object



76
77
78
79
80
81
# File 'lib/active_ldap/adapter/jndi.rb', line 76

def add(dn, entries, options={})
  super do |_dn, _entries|
    info = {:dn => _dn, :attributes => _entries}
    execute(:add, info, _dn, parse_entries(_entries))
  end
end

#bind_as_anonymous(options = {}) ⇒ Object



55
56
57
58
59
60
# File 'lib/active_ldap/adapter/jndi.rb', line 55

def bind_as_anonymous(options={})
  super do
    execute(:bind_as_anonymous, :name => "bind: anonymous")
    true
  end
end

#connect(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/active_ldap/adapter/jndi.rb', line 21

def connect(options={})
  super do |host, port, method|
    uri = construct_uri(host, port, method == :ssl)
    with_start_tls = method == :start_tls
    follow_referrals = follow_referrals?(options)
    info = {
      :uri => uri,
      :with_start_tls => with_start_tls,
      :follow_referrals => follow_referrals,
    }
    [
      log("connect", info) {
        JndiConnection.new(host,
                           port,
                           method,
                           @timeout,
                           follow_referrals)
      },
      uri,
      with_start_tls,
    ]
  end
end

#connecting?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/active_ldap/adapter/jndi.rb', line 45

def connecting?
  super and @connection.bound?
end

#delete(targets, options = {}) ⇒ Object



70
71
72
73
74
# File 'lib/active_ldap/adapter/jndi.rb', line 70

def delete(targets, options={})
  super do |target|
    execute(:delete, {:dn => target}, target)
  end
end

#modify(dn, entries, options = {}) ⇒ Object



83
84
85
86
87
88
# File 'lib/active_ldap/adapter/jndi.rb', line 83

def modify(dn, entries, options={})
  super do |_dn, _entries|
    info = {:dn => _dn, :attributes => _entries}
    execute(:modify, info, _dn, parse_entries(_entries))
  end
end

#modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options = {}) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/active_ldap/adapter/jndi.rb', line 90

def modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={})
  super do |_dn, _new_rdn, _delete_old_rdn, _new_superior|
    info = {
      :name => "modify: RDN",
      :dn => _dn,
      :new_rdn => _new_rdn,
      :new_superior => _new_superior,
      :delete_old_rdn => _delete_old_rdn
    }
    _new_rdn = "#{_new_rdn},#{_new_superior}" if _new_superior
    execute(:modify_rdn, info, _dn, _new_rdn, _delete_old_rdn)
  end
end

#search(options = {}, &block) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/active_ldap/adapter/jndi.rb', line 62

def search(options={}, &block)
  super(options) do |search_options|
    scope = search_options[:scope]
    info = search_options.merge(scope: scope_name(scope))
    execute(:search, info, search_options, &block)
  end
end

#unbind(options = {}) ⇒ Object



49
50
51
52
53
# File 'lib/active_ldap/adapter/jndi.rb', line 49

def unbind(options={})
  super do
    execute(:unbind)
  end
end