Class: ActiveLdap::Adapter::Ldap
- Inherits:
-
Base
- Object
- Base
- ActiveLdap::Adapter::Ldap
show all
- Defined in:
- lib/active_ldap/adapter/ldap.rb
Defined Under Namespace
Modules: Method
Constant Summary
Constants inherited
from Base
Base::VALID_ADAPTER_CONFIGURATION_KEYS
Instance Method Summary
collapse
Methods inherited from Base
#connecting?, #disconnect!, #initialize, ldap_connection, net_ldap_connection, #rebind, #schema
included
Instance Method Details
#add(dn, entries, options = {}) ⇒ Object
115
116
117
118
119
|
# File 'lib/active_ldap/adapter/ldap.rb', line 115
def add(dn, entries, options={})
super do |dn, entries|
execute(:add, dn, parse_entries(entries))
end
end
|
#bind(options = {}) ⇒ Object
50
51
52
53
54
|
# File 'lib/active_ldap/adapter/ldap.rb', line 50
def bind(options={})
super do
@connection.error_message
end
end
|
#bind_as_anonymous(options = {}) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/active_ldap/adapter/ldap.rb', line 56
def bind_as_anonymous(options={})
super do
execute(:bind)
true
end
end
|
#bound? ⇒ Boolean
63
64
65
|
# File 'lib/active_ldap/adapter/ldap.rb', line 63
def bound?
connecting? and @connection.bound?
end
|
#connect(options = {}) ⇒ Object
37
38
39
40
41
|
# File 'lib/active_ldap/adapter/ldap.rb', line 37
def connect(options={})
super do |host, port, method|
method.connect(host, port)
end
end
|
#delete(targets, options = {}) ⇒ Object
109
110
111
112
113
|
# File 'lib/active_ldap/adapter/ldap.rb', line 109
def delete(targets, options={})
super do |target|
execute(:delete, target)
end
end
|
#load(ldifs, options = {}) ⇒ Object
103
104
105
106
107
|
# File 'lib/active_ldap/adapter/ldap.rb', line 103
def load(ldifs, options={})
super do |ldif|
LDAP::LDIF.parse_entry(ldif).send(@connection)
end
end
|
#modify(dn, entries, options = {}) ⇒ Object
121
122
123
124
125
|
# File 'lib/active_ldap/adapter/ldap.rb', line 121
def modify(dn, entries, options={})
super do |dn, entries|
execute(:modify, dn, parse_entries(entries))
end
end
|
#search(options = {}, &block) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/active_ldap/adapter/ldap.rb', line 67
def search(options={}, &block)
super(options) do |base, scope, filter, attrs, limit, callback|
begin
i = 0
execute(:search, base, scope, filter, attrs) do |entry|
i += 1
attributes = {}
entry.attrs.each do |attr|
attributes[attr] = entry.vals(attr)
end
callback.call([entry.dn, attributes], block)
break if limit and limit <= i
end
rescue RuntimeError
if $!.message == "no result returned by search"
@logger.debug do
args = [filter, attrs.inspect]
_("No matches: filter: %s: attributes: %s") % args
end
else
raise
end
end
end
end
|
#to_ldif(dn, attributes) ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/active_ldap/adapter/ldap.rb', line 93
def to_ldif(dn, attributes)
ldif = LDAP::LDIF.to_ldif("dn", [dn.dup])
attributes.sort_by do |key, value|
key
end.each do |key, values|
ldif << LDAP::LDIF.to_ldif(key, values)
end
ldif
end
|
#unbind(options = {}) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/active_ldap/adapter/ldap.rb', line 43
def unbind(options={})
return unless bound?
operation(options) do
execute(:unbind)
end
end
|