Class URI::LDAP
In: lib/uri/ldap.rb
Parent: Generic

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

Methods

Constants

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

Public Class methods

[Source]

    # File lib/uri/ldap.rb, line 41
41:     def self.build(args)
42:       tmp = Util::make_components_hash(self, args)
43: 
44:       if tmp[:dn]
45:         tmp[:path] = tmp[:dn]
46:       end
47: 
48:       query = []
49:       [:extensions, :filter, :scope, :attributes].collect do |x|
50:         next if !tmp[x] && query.size == 0
51:         query.unshift(tmp[x])
52:       end
53: 
54:       tmp[:query] = query.join('?')
55: 
56:       return super(tmp)
57:     end

[Source]

    # File lib/uri/ldap.rb, line 59
59:     def initialize(*arg)
60:       super(*arg)
61: 
62:       if @fragment
63:         raise InvalidURIError, 'bad LDAP URL'
64:       end
65: 
66:       parse_dn
67:       parse_query
68:     end

Public Instance methods

[Source]

     # File lib/uri/ldap.rb, line 120
120:     def attributes
121:       @attributes
122:     end

[Source]

     # File lib/uri/ldap.rb, line 131
131:     def attributes=(val)
132:       set_attributes(val)
133:       val
134:     end

[Source]

     # File lib/uri/ldap.rb, line 104
104:     def dn
105:       @dn
106:     end

[Source]

     # File lib/uri/ldap.rb, line 115
115:     def dn=(val)
116:       set_dn(val)
117:       val
118:     end

[Source]

     # File lib/uri/ldap.rb, line 168
168:     def extensions
169:       @extensions
170:     end

[Source]

     # File lib/uri/ldap.rb, line 179
179:     def extensions=(val)
180:       set_extensions(val)
181:       val
182:     end

[Source]

     # File lib/uri/ldap.rb, line 152
152:     def filter
153:       @filter
154:     end

[Source]

     # File lib/uri/ldap.rb, line 163
163:     def filter=(val)
164:       set_filter(val)
165:       val
166:     end

[Source]

     # File lib/uri/ldap.rb, line 184
184:     def hierarchical?
185:       false
186:     end

[Source]

     # File lib/uri/ldap.rb, line 136
136:     def scope
137:       @scope
138:     end

[Source]

     # File lib/uri/ldap.rb, line 147
147:     def scope=(val)
148:       set_scope(val)
149:       val
150:     end

Protected Instance methods

[Source]

     # File lib/uri/ldap.rb, line 124
124:     def set_attributes(val)
125:       @attributes = val
126:       build_path_query
127:       @attributes
128:     end

[Source]

     # File lib/uri/ldap.rb, line 108
108:     def set_dn(val)
109:       @dn = val
110:       build_path_query
111:       @dn
112:     end

[Source]

     # File lib/uri/ldap.rb, line 172
172:     def set_extensions(val)
173:       @extensions = val
174:       build_path_query
175:       @extensions
176:     end

[Source]

     # File lib/uri/ldap.rb, line 156
156:     def set_filter(val)
157:       @filter = val
158:       build_path_query
159:       @filter
160:     end

[Source]

     # File lib/uri/ldap.rb, line 140
140:     def set_scope(val)
141:       @scope = val
142:       build_path_query
143:       @scope
144:     end

Private Instance methods

[Source]

     # File lib/uri/ldap.rb, line 92
 92:     def build_path_query
 93:       @path = '/' + @dn
 94: 
 95:       query = []
 96:       [@extensions, @filter, @scope, @attributes].each do |x|
 97:         next if !x && query.size == 0
 98:         query.unshift(x)
 99:       end
100:       @query = query.join('?')
101:     end

[Source]

    # File lib/uri/ldap.rb, line 70
70:     def parse_dn
71:       @dn = @path[1..-1]
72:     end

[Source]

    # File lib/uri/ldap.rb, line 75
75:     def parse_query
76:       @attributes = nil
77:       @scope      = nil
78:       @filter     = nil
79:       @extensions = nil
80: 
81:       if @query
82:         attrs, scope, filter, extensions = @query.split('?')
83: 
84:         @attributes = attrs if attrs && attrs.size > 0
85:         @scope      = scope if scope && scope.size > 0
86:         @filter     = filter if filter && filter.size > 0
87:         @extensions = extensions if extensions && extensions.size > 0
88:       end
89:     end

[Validate]