Class ActiveLdap::Adapter::Jndi
In: lib/active_ldap/adapter/jndi.rb
Parent: Base
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/xml.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb Compatible ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_46_0.png

Methods

Constants

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

Public Instance methods

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 61
61:       def add(dn, entries, options={})
62:         super do |_dn, _entries|
63:           info = {:dn => _dn, :attributes => _entries}
64:           execute(:add, info, _dn, parse_entries(_entries))
65:         end
66:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 37
37:       def bind_as_anonymous(options={})
38:         super do
39:           execute(:bind_as_anonymous, :name => "bind: anonymous")
40:           true
41:         end
42:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 21
21:       def connect(options={})
22:         super do |host, port, method|
23:           uri = construct_uri(host, port, method == :ssl)
24:           with_start_tls = method == :start_tls
25:           info = {:uri => uri, :with_start_tls => with_start_tls}
26:           [log("connect", info) {JndiConnection.new(host, port, method)},
27:            uri, with_start_tls]
28:         end
29:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 55
55:       def delete(targets, options={})
56:         super do |target|
57:           execute(:delete, {:dn => target}, target)
58:         end
59:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 68
68:       def modify(dn, entries, options={})
69:         super do |_dn, _entries|
70:           info = {:dn => _dn, :attributes => _entries}
71:           execute(:modify, info, _dn, parse_entries(_entries))
72:         end
73:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 75
75:       def modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={})
76:         super do |_dn, _new_rdn, _delete_old_rdn, _new_superior|
77:           info = {
78:             :name => "modify: RDN",
79:             :dn => _dn, :new_rdn => _new_rdn, :delete_old_rdn => _delete_old_rdn,
80:           }
81:           execute(:modify_rdn, info, _dn, _new_rdn, _delete_old_rdn)
82:         end
83:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 44
44:       def search(options={}, &block)
45:         super(options) do |base, scope, filter, attrs, limit, callback|
46:           info = {
47:             :base => base, :scope => scope_name(scope), :filter => filter,
48:             :attributes => attrs,
49:           }
50:           execute(:search, info,
51:                   base, scope, filter, attrs, limit, callback, &block)
52:         end
53:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 31
31:       def unbind(options={})
32:         super do
33:           execute(:unbind)
34:         end
35:       end

Private Instance methods

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 99
 99:       def ensure_method(method)
100:         method ||= "plain"
101:         normalized_method = method.to_s.downcase.to_sym
102:         return METHOD[normalized_method] if METHOD.has_key?(normalized_method)
103: 
104:         available_methods = METHOD.keys.collect {|m| m.inspect}.join(", ")
105:         format = _("%s is not one of the available connect methods: %s")
106:         raise ConfigurationError, format % [method.inspect, available_methods]
107:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 169
169:       def ensure_mod_type(type)
170:         case type
171:         when :replace, :add
172:           type
173:         when :delete
174:           :remove
175:         else
176:           raise ArgumentError, _("unknown type: %s") % type
177:         end
178:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 109
109:       def ensure_scope(scope)
110:         scope_map = {
111:           :base => JndiConnection::Scope::OBJECT,
112:           :one => JndiConnection::Scope::ONE_LEVEL,
113:           :sub => JndiConnection::Scope::SUBTREE,
114:         }
115:         value = scope_map[scope || :sub]
116:         if value.nil?
117:           available_scopes = scope_map.keys.inspect
118:           format = _("%s is not one of the available LDAP scope: %s")
119:           raise ArgumentError, format % [scope.inspect, available_scopes]
120:         end
121:         value
122:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 86
86:       def execute(method, info=nil, *args, &block)
87:         name = (info || {}).delete(:name) || method
88:         log(name, info) {@connection.send(method, *args, &block)}
89:       rescue JndiConnection::NamingException
90:         if /\[LDAP: error code (\d+) - ([^\]]+)\]/ =~ $!.to_s
91:           message = $2
92:           klass = LdapError::ERRORS[Integer($1)]
93:           klass ||= ActiveLdap::LdapError
94:           raise klass, message
95:         end
96:         raise
97:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 152
152:       def parse_entries(entries)
153:         result = []
154:         entries.each do |type, key, attributes|
155:           mod_type = ensure_mod_type(type)
156:           binary = schema.attribute(key).binary?
157:           attributes.each do |name, values|
158:             real_binary = binary
159:             if values.any? {|value| Ldif::Attribute.binary_value?(value)}
160:               real_binary = true
161:             end
162:             result << JndiConnection::ModifyRecord.new(mod_type, name,
163:                                                        values, real_binary)
164:           end
165:         end
166:         result
167:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 132
132:       def sasl_bind(bind_dn, options={})
133:         super do |_bind_dn, mechanism, quiet|
134:           info = {
135:             :name => "bind: SASL",
136:             :dn => _bind_dn,
137:             :mechanism => mechanism
138:           }
139:           execute(:sasl_bind, info, _bind_dn, mechanism, quiet)
140:           true
141:         end
142:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 124
124:       def scope_name(scope)
125:         {
126:           JndiConnection::Scope::OBJECT => :base,
127:           JndiConnection::Scope::ONE_LEVEL => :one,
128:           JndiConnection::Scope::SUBTREE => :sub,
129:         }[scope]
130:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 144
144:       def simple_bind(bind_dn, options={})
145:         super do |_bind_dn, password|
146:           info = {:name => "bind", :dn => _bind_dn}
147:           execute(:simple_bind, info, _bind_dn, password)
148:           true
149:         end
150:       end

[Validate]