Class ActiveLdap::Adapter::Jndi
In: lib/active_ldap/adapter/jndi.rb
Parent: Base
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid DistinguishedNameNotSetError EntryNotFound LdapError SaveError StrongAuthenticationRequired NotImplemented 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] Base DistinguishedName Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Normalizable Common Find LDIF Delete Update ActiveRecord::Callbacks GetText Parser 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 ActiveRecord::Validations 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 ClassMethods Normalizable Attributes Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Configuration ClassMethods ObjectClass ClassMethods Callbacks lib/active_ldap/get_text/parser.rb GetText lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/base.rb lib/active_ldap/adapter/jndi.rb Adapter Validations GetTextFallback Helper 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,
80:             :new_rdn => _new_rdn,
81:             :new_superior => _new_superior,
82:             :delete_old_rdn => _delete_old_rdn
83:           }
84:           _new_rdn = "#{_new_rdn},#{_new_superior}" if _new_superior
85:           execute(:modify_rdn, info, _dn, _new_rdn, _delete_old_rdn)
86:         end
87:       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, :limit => limit,
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 103
103:       def ensure_method(method)
104:         method ||= "plain"
105:         normalized_method = method.to_s.downcase.to_sym
106:         return METHOD[normalized_method] if METHOD.has_key?(normalized_method)
107: 
108:         available_methods = METHOD.keys.collect {|m| m.inspect}.join(", ")
109:         format = _("%s is not one of the available connect methods: %s")
110:         raise ConfigurationError, format % [method.inspect, available_methods]
111:       end

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]