module ROM::LDAP::Directory::Root
Public Instance Methods
@return [String]
@api public
# File lib/rom/ldap/directory/root.rb, line 122 def contexts root['namingContexts'].sort end
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
@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
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
@return [Array<String>]
@api public
# File lib/rom/ldap/directory/root.rb, line 94 def supported_controls root['supportedControl'].sort end
@return [Array<String>]
@api public
# File lib/rom/ldap/directory/root.rb, line 87 def supported_extensions root['supportedExtension'].sort end
@return [Array<String>]
@api public
# File lib/rom/ldap/directory/root.rb, line 108 def supported_features root['supportedFeatures'].sort end
@return [Array<String>]
@api public
# File lib/rom/ldap/directory/root.rb, line 101 def supported_mechanisms root['supportedSASLMechanisms'].sort end
@return [Array<Integer>]
@api public
# File lib/rom/ldap/directory/root.rb, line 115 def supported_versions root['supportedLDAPVersion'].sort.map(&:to_i) end
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
@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
@return [String]
@api public
# File lib/rom/ldap/directory/root.rb, line 37 def vendor_name root.first('vendorName') end
@return [String]
@api public
# File lib/rom/ldap/directory/root.rb, line 44 def vendor_version root.first('vendorVersion') end
Private Instance Methods
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
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
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
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