Class: ActiveLdap::Adapter::JndiConnection

### Home Classes Methods

### In Files

- lib/active_ldap/adapter/jndi_connection.rb

### Parent

Object

### Namespace

- MODULE ActiveLdap::Adapter::JndiConnection::Scope
- CLASS ActiveLdap::Adapter::JndiConnection::ModifyRecord

### Methods

- ::new
- #add
- #bind_as_anonymous
- #bound?
- #delete
- #modify
- #modify_rdn
- #sasl_bind
- #search
- #simple_bind
- #unbind

### Files

- USAGE

### Class/Module Index

Quicksearch

- ActiveLdap
- ActiveLdap::ActionController
- ActiveLdap::ActionController::LdapBenchmarking
- ActiveLdap::Acts
- ActiveLdap::Acts::Tree
- ActiveLdap::Acts::Tree::ClassMethods
- ActiveLdap::Adapter
- ActiveLdap::Adapter::Base
- ActiveLdap::Adapter::Jndi
- ActiveLdap::Adapter::JndiConnection
- ActiveLdap::Adapter::JndiConnection::ModifyRecord
- ActiveLdap::Adapter::JndiConnection::Scope
- ActiveLdap::Adapter::Ldap
- ActiveLdap::Adapter::Ldap::Method
- ActiveLdap::Adapter::Ldap::Method::Base
- ActiveLdap::Adapter::Ldap::Method::Plain
- ActiveLdap::Adapter::Ldap::Method::SSL
- ActiveLdap::Adapter::Ldap::Method::TLS
- ActiveLdap::Adapter::NetLdap
- ActiveLdap::Association
- ActiveLdap::Association::BelongsTo
- ActiveLdap::Association::BelongsToMany
- ActiveLdap::Association::Children
- ActiveLdap::Association::Collection
- ActiveLdap::Association::HasMany
- ActiveLdap::Association::HasManyUtils
- ActiveLdap::Association::HasManyWrap
- ActiveLdap::Association::Proxy
- ActiveLdap::Associations
- ActiveLdap::Associations::ClassMethods
- ActiveLdap::AttributeMethods
- ActiveLdap::AttributeMethods::BeforeTypeCast
- ActiveLdap::AttributeMethods::Dirty
- ActiveLdap::AttributeMethods::Query
- ActiveLdap::AttributeMethods::Read
- ActiveLdap::AttributeMethods::Write
- ActiveLdap::Attributes
- ActiveLdap::Attributes::ClassMethods
- ActiveLdap::Attributes::Normalizable
- ActiveLdap::Callbacks
- ActiveLdap::Callbacks::ClassMethods
- ActiveLdap::Command
- ActiveLdap::Compatible
- ActiveLdap::Configuration
- ActiveLdap::Configuration::ClassMethods
- ActiveLdap::Connection
- ActiveLdap::Connection::ClassMethods
- ActiveLdap::DN
- ActiveLdap::DistinguishedName
- ActiveLdap::DistinguishedName::Parser
- ActiveLdap::EntryAttribute
- ActiveLdap::Escape
- ActiveLdap::Generators
- ActiveLdap::Generators::ModelGenerator
- ActiveLdap::Generators::ScaffoldGenerator
- ActiveLdap::GetText
- ActiveLdap::GetText::Parser
- ActiveLdap::GetTextSupport
- ActiveLdap::Helper
- ActiveLdap::HumanReadable
- ActiveLdap::HumanReadable::ClassMethods
- ActiveLdap::LDIF
- ActiveLdap::LdapError
- ActiveLdap::Ldif
- ActiveLdap::Ldif::AddRecord
- ActiveLdap::Ldif::Attribute
- ActiveLdap::Ldif::Attributes
- ActiveLdap::Ldif::ChangeRecord
- ActiveLdap::Ldif::ChangeRecord::Control
- ActiveLdap::Ldif::ContentRecord
- ActiveLdap::Ldif::DeleteRecord
- ActiveLdap::Ldif::ModifyDNRecord
- ActiveLdap::Ldif::ModifyNameRecord
- ActiveLdap::Ldif::ModifyRDNRecord
- ActiveLdap::Ldif::ModifyRecord
- ActiveLdap::Ldif::ModifyRecord::AddOperation
- ActiveLdap::Ldif::ModifyRecord::DeleteOperation
- ActiveLdap::Ldif::ModifyRecord::Operation
- ActiveLdap::Ldif::ModifyRecord::ReplaceOperation
- ActiveLdap::Ldif::Parser
- ActiveLdap::Ldif::Record
- ActiveLdap::Ldif::Scanner
- ActiveLdap::LogSubscriber
- ActiveLdap::ObjectClass
- ActiveLdap::ObjectClass::ClassMethods
- ActiveLdap::Operations
- ActiveLdap::Operations::ClassOnlyDelete
- ActiveLdap::Operations::ClassOnlyUpdate
- ActiveLdap::Operations::Common
- ActiveLdap::Operations::Delete
- ActiveLdap::Operations::Find
- ActiveLdap::Operations::LDIF
- ActiveLdap::Operations::LDIF::AddRecordLoadable
- ActiveLdap::Operations::LDIF::ContentRecordLoadable
- ActiveLdap::Operations::LDIF::DeleteRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyNameRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::AddOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::DeleteOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::ReplaceOperationModifiable
- ActiveLdap::Operations::Update
- ActiveLdap::Persistence
- ActiveLdap::Populate
- ActiveLdap::Railtie
- ActiveLdap::Railties
- ActiveLdap::Railties::ControllerRuntime
- ActiveLdap::Railties::ControllerRuntime::ClassMethods
- ActiveLdap::Schema
- ActiveLdap::Schema::Attribute
- ActiveLdap::Schema::Entry
- ActiveLdap::Schema::ObjectClass
- ActiveLdap::Schema::Syntax
- ActiveLdap::Schema::Syntaxes
- ActiveLdap::Schema::Syntaxes::Base
- ActiveLdap::Schema::Syntaxes::BitString
- ActiveLdap::Schema::Syntaxes::Boolean
- ActiveLdap::Schema::Syntaxes::CountryString
- ActiveLdap::Schema::Syntaxes::DirectoryString
- ActiveLdap::Schema::Syntaxes::DistinguishedName
- ActiveLdap::Schema::Syntaxes::GeneralizedTime
- ActiveLdap::Schema::Syntaxes::Integer
- ActiveLdap::Schema::Syntaxes::JPEG
- ActiveLdap::Schema::Syntaxes::NameAndOptionalUID
- ActiveLdap::Schema::Syntaxes::NumericString
- ActiveLdap::Schema::Syntaxes::OID
- ActiveLdap::Schema::Syntaxes::OtherMailbox
- ActiveLdap::Schema::Syntaxes::PostalAddress
- ActiveLdap::Schema::Syntaxes::PrintableString
- ActiveLdap::Schema::Syntaxes::TelephoneNumber
- ActiveLdap::UserPassword
- ActiveLdap::UserPassword::Salt
- ActiveLdap::Validations
- ActiveLdap::XML
- ActiveLdap::Xml
- ActiveLdap::Xml::Serializer
- LDAP
- LDAP::Conn
- LDAP::Mod
- Net
- Net::LDAP
- Net::LDAP::Entry
- ActionView
- ActionView::Base
- URI
- URI::LDAPS
- Object
- Timeout

No matching classes.

# ActiveLdap::Adapter::JndiConnection

### Constants

BasicAttributes
Context
Control
HashTable
InitialDirContext
InitialLdapContext
ModificationItem
NameNotFoundException
NamingException
SearchControls
StartTlsRequest

### Public Class Methods

new(host, port, method) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 74
    def initialize(host, port, method)
      @host = host
      @port = port
      @method = method
      @context = nil
      @tls = nil
    end

### Public Instance Methods

add(dn, records) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 128
    def add(dn, records)
      attributes = BasicAttributes.new
      records.each do |record|
        attributes.put(record.to_java_attribute)
      end
      @context.create_subcontext(dn, attributes)
    end

bind_as_anonymous() click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 103
    def bind_as_anonymous
      setup_context(nil, nil, "none")
      bound?
    end

bound?() click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 89
    def bound?
      not @context.nil?
    end

delete(dn) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 150
    def delete(dn)
      @context.destroy_subcontext(dn)
    end

modify(dn, records) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 136
    def modify(dn, records)
      items = records.collect(&:to_java_modification_item)
      @context.modify_attributes(dn, items.to_java(ModificationItem))
    end

modify_rdn(dn, new_rdn, delete_old_rdn) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 141
    def modify_rdn(dn, new_rdn, delete_old_rdn)
      # should use mutex
      delete_rdn_key = "java.naming.ldap.deleteRDN"
      @context.add_to_environment(delete_rdn_key, delete_old_rdn.to_s)
      @context.rename(dn, new_rdn)
    ensure
      @context.remove_from_environment(delete_rdn_key)
    end

sasl_bind(bind_dn, mechanism, quiet) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 93
    def sasl_bind(bind_dn, mechanism, quiet)
      setup_context(bind_dn, password, mechanism)
      bound?
    end

search(base, scope, filter, attrs, limit) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 108
    def search(base, scope, filter, attrs, limit)
      controls = SearchControls.new
      controls.search_scope = scope

      controls.count_limit = limit if limit
      unless attrs.blank?
        controls.returning_attributes = attrs.to_java(:string)
      end

      @context.search(base, filter, controls).each do |result|
        attributes = {}
        result.attributes.get_all.each do |attribute|
          attributes[attribute.get_id] = attribute.get_all.collect do |value|
            value.is_a?(String) ? value : String.from_java_bytes(value)
          end
        end
        yield([result.name_in_namespace, attributes])
      end
    end

simple_bind(bind_dn, password) click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 98
    def simple_bind(bind_dn, password)
      setup_context(bind_dn, password, "simple")
      bound?
    end

unbind() click to toggle source

    # File lib/active_ldap/adapter/jndi_connection.rb, line 82
    def unbind
      @tls.close if @tls
      @tls = nil
      @context.close if @context
      @context = nil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.