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 ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid 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 Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb 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_44_0.png

Methods

Constants

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 44
44:       def bound?
45:         connecting? and @connection.bound?
46:       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 59
59:       def delete(targets, options={})
60:         super do |target|
61:           execute(:delete, {:dn => target}, target)
62:         end
63:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 72
72:       def modify(dn, entries, options={})
73:         super do |dn, entries|
74:           info = {:dn => dn, :attributes => entries}
75:           execute(:modify, info, dn, parse_entries(entries))
76:         end
77:       end

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 79
79:       def modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={})
80:         super do |dn, new_rdn, delete_old_rdn, new_superior|
81:           info = {
82:             :name => "modify: RDN", :dn => dn, :new_rdn => new_rdn,
83:             :delete_old_rdn => delete_old_rdn,
84:           }
85:           execute(:modify_rdn, info, dn, new_rdn, delete_old_rdn)
86:         end
87:       end

[Source]

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

[Source]

    # File lib/active_ldap/adapter/jndi.rb, line 31
31:       def unbind(options={})
32:         return unless bound?
33:         operation(options) do
34:           execute(:unbind)
35:         end
36:       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 163
163:       def ensure_mod_type(type)
164:         case type
165:         when :replace, :add
166:           type
167:         when :delete
168:           :remove
169:         else
170:           raise ArgumentError, _("unknown type: %s") % type
171:         end
172:       end

[Source]

     # File lib/active_ldap/adapter/jndi.rb, line 113
113:       def ensure_scope(scope)
114:         scope_map = {
115:           :base => 0,
116:           :one => 1,
117:           :sub => 2,
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 150
150:       def parse_entries(entries)
151:         result = []
152:         entries.each do |type, key, attributes|
153:           mod_type = ensure_mod_type(type)
154:           binary = schema.attribute(key).binary?
155:           attributes.each do |name, values|
156:             result << JndiConnection::ModifyRecord.new(mod_type, name,
157:                                                        values, binary)
158:           end
159:         end
160:         result
161:       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 = {:name => "bind: SASL", :dn => bind_dn, :mechanism => mechanism}
139:           execute(:sasl_bind, info, bind_dn, mechanism, quiet)
140:         end
141:       end

[Source]

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

[Source]

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

[Validate]