Class: Ldapi::Backend
- Inherits:
-
Object
- Object
- Ldapi::Backend
- Defined in:
- lib/ldapi/backend.rb
Constant Summary collapse
- ATTRS =
[ "objectclass", "givenname", "sn", "objectclass", 'apple-imhandle', 'cn', 'gidnumber', # 'jpegphoto', 'mail', 'uid', 'uidnumber', 'homedirectory' ]
Instance Method Summary collapse
-
#initialize ⇒ Backend
constructor
A new instance of Backend.
- #search(uid) ⇒ Object
Constructor Details
#initialize ⇒ Backend
Returns a new instance of Backend.
17 18 19 20 |
# File 'lib/ldapi/backend.rb', line 17 def initialize @ldap = Net::LDAP.new( :host => Ldapi.configuration.ldap_server, :port => 389 ) end |
Instance Method Details
#search(uid) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ldapi/backend.rb', line 22 def search(uid) result = {} filter = Net::LDAP::Filter.eq( "uid", uid ) @ldap.search( :base => Ldapi.configuration.search_base, :filter => filter, :attributes => ATTRS ) do |entry| entry.each do |attribute, values| if values.size == 1 result[attribute] = values.first else result[attribute] = values end end end result end |