Class: Fooldap::Operation
- Inherits:
-
LDAP::Server::Operation
- Object
- LDAP::Server::Operation
- Fooldap::Operation
- Defined in:
- lib/fooldap.rb
Instance Method Summary collapse
-
#initialize(connection, messageID, server) ⇒ Operation
constructor
A new instance of Operation.
- #search(basedn, scope, deref, filter, attrs = nil) ⇒ Object
- #simple_bind(version, dn, password) ⇒ Object
Constructor Details
#initialize(connection, messageID, server) ⇒ Operation
Returns a new instance of Operation.
49 50 51 52 |
# File 'lib/fooldap.rb', line 49 def initialize(connection, , server) super(connection, ) @server = server end |
Instance Method Details
#search(basedn, scope, deref, filter, attrs = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fooldap.rb', line 66 def search(basedn, scope, deref, filter, attrs=nil) group_filter = [:eq, "objectclass", nil, "groupofNames"] if filter == [:true] groups = @server.groups.select { |dn, users| dn =~ /#{basedn}/ } return groups.each { |dn, users| send_group_result(dn, users) } end if filter.first == :eq if filter == group_filter return @server.groups.each { |group| send_group_result(*group) } else return @server.find_users(basedn, filter).each { |dn| send_SearchResultEntry(dn, {}) } end elsif filter.first == :and if filter[1] == group_filter member_eq = filter[2] if member_eq[0] == :eq and member_eq[1] == 'member' user_dn = member_eq[3] return @server.find_groups(user_dn).each { |group| send_group_result(*group) } end end end raise LDAP::ResultError::UnwillingToPerform, "Only some matches are supported" end |
#simple_bind(version, dn, password) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fooldap.rb', line 54 def simple_bind(version, dn, password) unless dn raise LDAP::ResultError::InappropriateAuthentication, "This server does not support anonymous bind" end unless @server.valid_credentials?(dn, password) raise LDAP::ResultError::InvalidCredentials, "Invalid credentials" end end |