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 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] DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update GetText::Translation 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/schema/syntaxes.rb lib/active_ldap/xml.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 Translation 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 60
60:       def add(dn, entries, options={})
61:         super do |_dn, _entries|
62:           info = {:dn => _dn, :attributes => _entries}
63:           execute(:add, info, _dn, parse_entries(_entries))
64:         end
65:       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 54
54:       def delete(targets, options={})
55:         super do |target|
56:           execute(:delete, {:dn => target}, target)
57:         end
58:       end

[Source]

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

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 74
74:       def modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={})
75:         super do |_dn, _new_rdn, _delete_old_rdn, _new_superior|
76:           info = {
77:             :name => "modify: RDN",
78:             :dn => _dn,
79:             :new_rdn => _new_rdn,
80:             :new_superior => _new_superior,
81:             :delete_old_rdn => _delete_old_rdn
82:           }
83:           _new_rdn = "#{_new_rdn},#{_new_superior}" if _new_superior
84:           execute(:modify_rdn, info, _dn, _new_rdn, _delete_old_rdn)
85:         end
86:       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|
46:           info = {
47:             :base => base, :scope => scope_name(scope), :filter => filter,
48:             :attributes => attrs, :limit => limit,
49:           }
50:           execute(:search, info, base, scope, filter, attrs, limit, &block)
51:         end
52:       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 102
102:       def ensure_method(method)
103:         method ||= "plain"
104:         normalized_method = method.to_s.downcase.to_sym
105:         return METHOD[normalized_method] if METHOD.has_key?(normalized_method)
106: 
107:         available_methods = METHOD.keys.collect {|m| m.inspect}.join(", ")
108:         format = _("%s is not one of the available connect methods: %s")
109:         raise ConfigurationError, format % [method.inspect, available_methods]
110:       end

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]