Class: URI::LDAP

Inherits:
Generic show all
Defined in:
lib/uri/ldap.rb

Overview

LDAP URI SCHEMA (described in RFC2255) ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>]]]

Constant Summary collapse

DEFAULT_PORT =
389
COMPONENT =
[
  :scheme,
  :host, :port,
  :dn,
  :attributes,
  :scope,
  :filter,
  :extensions,
].freeze
SCOPE =
[
  SCOPE_ONE = 'one',
  SCOPE_SUB = 'sub',
  SCOPE_BASE = 'base',
].freeze

Constants inherited from Generic

Generic::USE_REGISTRY

Constants included from REGEXP

REGEXP::ABS_PATH, REGEXP::ABS_URI, REGEXP::ABS_URI_REF, REGEXP::ESCAPED, REGEXP::FRAGMENT, REGEXP::HOST, REGEXP::OPAQUE, REGEXP::PORT, REGEXP::QUERY, REGEXP::REGISTRY, REGEXP::REL_PATH, REGEXP::REL_URI, REGEXP::REL_URI_REF, REGEXP::SCHEME, REGEXP::UNSAFE, REGEXP::URI_REF, REGEXP::USERINFO

Constants included from URI

VERSION, VERSION_CODE

Instance Attribute Summary

Attributes inherited from Generic

#fragment, #host, #opaque, #path, #port, #query, #registry, #scheme

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generic

#==, #absolute?, build2, #coerce, component, #component, #default_port, default_port, #eql?, #hash, #inspect, #merge, #merge!, #normalize, #normalize!, #password, #password=, #relative?, #route_from, #route_to, #select, #to_s, use_registry, #user, #user=, #userinfo, #userinfo=

Methods included from URI

extract, join, parse, regexp, split

Methods included from Escape

#escape, #unescape

Constructor Details

#initialize(*arg) ⇒ LDAP

Returns a new instance of LDAP.



59
60
61
62
63
64
65
66
67
68
# File 'lib/uri/ldap.rb', line 59

def initialize(*arg)
  super(*arg)

  if @fragment
    raise InvalidURIError, 'bad LDAP URL'
  end

  parse_dn
  parse_query
end

Class Method Details

.build(args) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/uri/ldap.rb', line 41

def self.build(args)
  tmp = Util::make_components_hash(self, args)

  if tmp[:dn]
    tmp[:path] = tmp[:dn]
  end

  query = []
  [:extensions, :filter, :scope, :attributes].collect do |x|
    next if !tmp[x] && query.size == 0
    query.unshift(tmp[x])
  end

  tmp[:query] = query.join('?')

  return super(tmp)
end

Instance Method Details

#attributesObject



120
121
122
# File 'lib/uri/ldap.rb', line 120

def attributes
  @attributes
end

#attributes=(val) ⇒ Object



131
132
133
134
# File 'lib/uri/ldap.rb', line 131

def attributes=(val)
  set_attributes(val)
  val
end

#dnObject



104
105
106
# File 'lib/uri/ldap.rb', line 104

def dn
  @dn
end

#dn=(val) ⇒ Object



115
116
117
118
# File 'lib/uri/ldap.rb', line 115

def dn=(val)
  set_dn(val)
  val
end

#extensionsObject



168
169
170
# File 'lib/uri/ldap.rb', line 168

def extensions
  @extensions
end

#extensions=(val) ⇒ Object



179
180
181
182
# File 'lib/uri/ldap.rb', line 179

def extensions=(val)
  set_extensions(val)
  val
end

#filterObject



152
153
154
# File 'lib/uri/ldap.rb', line 152

def filter
  @filter
end

#filter=(val) ⇒ Object



163
164
165
166
# File 'lib/uri/ldap.rb', line 163

def filter=(val)
  set_filter(val)
  val
end

#hierarchical?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/uri/ldap.rb', line 184

def hierarchical?
  false
end

#scopeObject



136
137
138
# File 'lib/uri/ldap.rb', line 136

def scope
  @scope
end

#scope=(val) ⇒ Object



147
148
149
150
# File 'lib/uri/ldap.rb', line 147

def scope=(val)
  set_scope(val)
  val
end