class LOM
Constants
- TIME_FORMAT
Time format used in ldap
- VERSION
Public Class Methods
Get debugging mode
# File lib/lom/core.rb, line 40 def self.debug @@debug ||= [] end
Set debugging mode @param [Array<:dry,:verbose>] debugging options
# File lib/lom/core.rb, line 46 def self.debug=(v) @@debug = v end
Retrieve the identifier.
The given `dn` should be a direct child of the `branch`, and if `attr` is specified, the attribute name should also match.
~~~ dn = “uid=jdoe,ou=People,dc=example,dc=com” LOM.id_from_dn
(dn, “ou=People,dc=example,dc=com”, :uid) ~~~
@param [String] dn DN of the object @param [String] branch Branch the DN should belong @param [Symbol,String] attr Attribute name
@return [String] Identifier @return [nil] Unable to extract identifier
# File lib/lom/ldap.rb, line 24 def self.id_from_dn(dn, branch, attr = nil) if sub = Net::LDAP::DN.sub?(dn, branch) k, v, o = sub.to_a if o.nil? && (!attr.nil? || (k == attr.to_s)) v end end end
Get the LDAP
handler to use
In order of preference:
-
the handler set using lh=
-
the LH constant in this scope or parent scope
-
the one defined in $lh
# File lib/lom/handler.rb, line 19 def self.lh @lh || const_get(:LH) || $lh end
# File lib/lom/handler.rb, line 7 def self.lh=(lh) @lh = lh end
Convert a Date/Time object to an ldap string representation
@param [Date, Time] ts
@return [String] string representation of time in ldap
# File lib/lom/core.rb, line 31 def self.to_ldap_time(ts) case ts when Date, Time then ts.strftime(TIME_FORMAT) when nil then nil else raise ArgumentError end end