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 Attribute Summary

Attributes inherited from Base

#runtime

Instance Method Summary collapse

Methods inherited from Base

#bind, #connecting?, #disconnect!, #entry_attribute, #initialize, jndi_connection, ldap_connection, #log_info, net_ldap_connection, #rebind, #reset_runtime, #schema

Methods included from GetTextSupport

included

Constructor Details

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

Instance Method Details

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



65
66
67
68
69
70
# File 'lib/active_ldap/adapter/jndi.rb', line 65

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



38
39
40
41
42
# File 'lib/active_ldap/adapter/jndi.rb', line 38

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

#bound?Boolean

Returns:

  • (Boolean)


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

def bound?
  connecting? and @connection.bound?
end

#connect(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
# 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
    info = {:uri => uri, :with_start_tls => with_start_tls}
    [log("connect", info) {JndiConnection.new(host, port, method)},
     uri, with_start_tls]
  end
end

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



59
60
61
62
63
# File 'lib/active_ldap/adapter/jndi.rb', line 59

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

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



72
73
74
75
76
77
# File 'lib/active_ldap/adapter/jndi.rb', line 72

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



79
80
81
82
83
84
85
86
87
# File 'lib/active_ldap/adapter/jndi.rb', line 79

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,
      :delete_old_rdn => delete_old_rdn,
    }
    execute(:modify_rdn, dn, new_rdn, delete_old_rdn)
  end
end

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



48
49
50
51
52
53
54
55
56
57
# File 'lib/active_ldap/adapter/jndi.rb', line 48

def search(options={}, &block)
  super(options) do |base, scope, filter, attrs, limit, callback|
    info = {
      :base => base, :scope => scope_name(scope), :filter => filter,
      :attributes => attrs,
    }
    execute(:search, info,
            base, scope, filter, attrs, limit, callback, &block)
  end
end

#unbind(options = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/active_ldap/adapter/jndi.rb', line 31

def unbind(options={})
  return unless bound?
  operation(options) do
    execute(:unbind)
  end
end