module ROM::LDAP::Directory::Root

Public Instance Methods

contexts() click to toggle source

@return [String]

@api public

# File lib/rom/ldap/directory/root.rb, line 122
def contexts
  root['namingContexts'].sort
end
schema_attribute_types() click to toggle source

Query directory for all known attribute types

@return [Array<String>] Attribute types known by directory

@api public

# File lib/rom/ldap/directory/root.rb, line 80
def schema_attribute_types
  sub_schema['attributeTypes'].sort
end
schema_object_classes() click to toggle source

@return [Array<String>] Object classes known by directory

@api public

# File lib/rom/ldap/directory/root.rb, line 71
def schema_object_classes
  sub_schema['objectClasses'].sort
end
sub_schema_entry() click to toggle source

Distinguished name of subschema

@return [String]

@api public

# File lib/rom/ldap/directory/root.rb, line 64
def sub_schema_entry
  root.first('subschemaSubentry')
end
supported_controls() click to toggle source

@return [Array<String>]

@api public

# File lib/rom/ldap/directory/root.rb, line 94
def supported_controls
  root['supportedControl'].sort
end
supported_extensions() click to toggle source

@return [Array<String>]

@api public

# File lib/rom/ldap/directory/root.rb, line 87
def supported_extensions
  root['supportedExtension'].sort
end
supported_features() click to toggle source

@return [Array<String>]

@api public

# File lib/rom/ldap/directory/root.rb, line 108
def supported_features
  root['supportedFeatures'].sort
end
supported_mechanisms() click to toggle source

@return [Array<String>]

@api public

# File lib/rom/ldap/directory/root.rb, line 101
def supported_mechanisms
  root['supportedSASLMechanisms'].sort
end
supported_versions() click to toggle source

@return [Array<Integer>]

@api public

# File lib/rom/ldap/directory/root.rb, line 115
def supported_versions
  root['supportedLDAPVersion'].sort.map(&:to_i)
end
type() click to toggle source

Identify the LDAP server vendor, type determines vendor extension to load.

@see ldapwiki.com/wiki/Determine%20LDAP%20Server%20Vendor

@return [Symbol]

@api public

# File lib/rom/ldap/directory/root.rb, line 15
def type
  case root.first('vendorName')
  when /389/        then :three_eight_nine
  when /Apache/     then :apache_ds
  when /Apple/      then :open_directory
  when /ForgeRock/  then :open_dj
  when /IBM/        then :ibm
  when /Netscape/   then :netscape
  when /Novell/     then :e_directory
  when /Oracle/     then :open_ds
  when /Sun/        then :sun_microsystems
  when nil
    return :active_directory if ad?
    return :open_ldap if od?
  else
    :unknown
  end
end
vendor() click to toggle source

@example

[ 'Apple', '510.30' ]
[ 'Apache Software Foundation', '2.0.0-M24' ]

@return [Array<String>]

@api public

# File lib/rom/ldap/directory/root.rb, line 55
def vendor
  [vendor_name, vendor_version]
end
vendor_name() click to toggle source

@return [String]

@api public

# File lib/rom/ldap/directory/root.rb, line 37
def vendor_name
  root.first('vendorName')
end
vendor_version() click to toggle source

@return [String]

@api public

# File lib/rom/ldap/directory/root.rb, line 44
def vendor_version
  root.first('vendorVersion')
end

Private Instance Methods

ad?() click to toggle source

Check if vendor identifies as ActiveDirectory

@return [Boolean]

@api private

# File lib/rom/ldap/directory/root.rb, line 171
def ad?
  !root['forestFunctionality'].nil?
end
od?() click to toggle source

Check if vendor identifies as OpenLDAP

@return [Boolean]

@api private

# File lib/rom/ldap/directory/root.rb, line 180
def od?
  root['objectClass']&.include?('OpenLDAProotDSE')
end
root() click to toggle source

Representation of directory RootDSE

@see ldapwiki.com/wiki/Retrieving%20RootDSE

@return [Directory::Entry]

@raise [ResponseError]

@api private

# File lib/rom/ldap/directory/root.rb, line 137
def root
  @root ||= query(
    base: EMPTY_STRING,
    scope: SCOPE_BASE,
    attributes: ALL_ATTRS
  ).first

  @root || raise(ResponseError, 'Directory root failed to load')
end
sub_schema() click to toggle source

Representation of directory SubSchema

@return [Directory::Entry]

@raise [ResponseError]

@api private

# File lib/rom/ldap/directory/root.rb, line 154
def sub_schema
  @sub_schema ||= query(
    base: sub_schema_entry,
    scope: SCOPE_BASE,
    attributes:  %w[objectClasses attributeTypes],
    filter: '(objectClass=subschema)',
    max_results: 1
  ).first

  @sub_schema || raise(ResponseError, 'Directory schema failed to load')
end