Module: ActiveLdap::Operations::Common

### Home Classes Methods

### In Files

- lib/active_ldap/operations.rb

### Methods

- #count
- #exist?
- #exists?
- #search

### 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::Operations::Common

### Constants

VALID_SEARCH_OPTIONS

### Public Instance Methods

count(options={}) click to toggle source

    # File lib/active_ldap/operations.rb, line 112
    def count(options={})
      search(options).size
    end

exist?(dn, options={}) click to toggle source

    # File lib/active_ldap/operations.rb, line 88
    def exist?(dn, options={})
      attr, value, prefix = split_search_value(dn)

      options_for_leaf = {
        :attribute => attr,
        :value => value,
        :prefix => prefix,
        :limit => 1,
      }

      attribute = attr || ensure_search_attribute
      options_for_non_leaf = {
        :attribute => attr,
        :value => value,
        :prefix => ["#{attribute}=#{value}", prefix].compact.join(","),
        :limit => 1,
        :scope => :base,
      }

      !search(options_for_leaf.merge(options)).empty? or
        !search(options_for_non_leaf.merge(options)).empty?
    end

Also aliased as: exists?
exists?(dn, options={}) click to toggle source
Alias for: exist?
search(options={}, &block) click to toggle source

    # File lib/active_ldap/operations.rb, line 29
    def search(options={}, &block)
      validate_search_options(options)
      attr = options[:attribute]
      value = options[:value] || '*'
      filter = options[:filter]
      prefix = options[:prefix]
      classes = options[:classes]
      requested_attributes = options[:attributes]

      value = value.first if value.is_a?(Array) and value.first.size == 1

      _attr = nil
      _prefix = nil
      if attr.nil? or attr == dn_attribute
        _attr, value, _prefix = split_search_value(value)
      end
      attr ||= _attr || ensure_search_attribute
      prefix ||= _prefix
      filter ||= [attr, value]
      filter = [:and, filter, *object_class_filters(classes)]
      _base = options[:base] ? [options[:base]] : [prefix, base]
      _base = prepare_search_base(_base)
      if options.has_key?(:ldap_scope)
        message = _(":ldap_scope search option is deprecated. "                        "Use :scope instead.")
        ActiveSupport::Deprecation.warn(message)
        options[:scope] ||= options[:ldap_scope]
      end
      search_options = {
        :base => _base,
        :scope => options[:scope] || scope,
        :filter => filter,
        :limit => options[:limit],
        :attributes => requested_attributes,
        :sort_by => options[:sort_by] || sort_by,
        :order => options[:order] || order,
      }
      options[:connection] ||= connection
      values = []
      requested_all_attributes_p =
        (requested_attributes.nil? or requested_attributes.include?('*'))
      options[:connection].search(search_options) do |dn, attrs|
        attributes = {}
        attrs.each do |key, _value|
          if requested_all_attributes_p or requested_attributes.include?(key)
            normalized_attribute, normalized_value =
              normalize_attribute_options(key, _value)
            attributes[normalized_attribute] ||= []
            attributes[normalized_attribute].concat(normalized_value)
          else
            next
          end
        end
        values << [dn, attributes]
      end
      values = values.collect {|_value| yield(_value)} if block_given?
      values
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.