Class: FakeLDAP::Operation

Inherits:
LDAP::Server::Operation
  • Object
show all
Defined in:
lib/fakeldap.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, messageID, server) ⇒ Operation

Returns a new instance of Operation.



37
38
39
40
# File 'lib/fakeldap.rb', line 37

def initialize(connection, messageID, server)
  super(connection, messageID)
  @server = server
end

Instance Method Details

#search(basedn, scope, deref, filter, attrs = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/fakeldap.rb', line 54

def search(basedn, scope, deref, filter, attrs=nil)
  unless filter.first == :eq
    raise LDAP::ResultError::UnwillingToPerform,
      "Only equality matches are supported"
  end

  @server.find_users(basedn, filter).each do |dn|
    send_SearchResultEntry(dn, {})
  end
end

#simple_bind(version, dn, password) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fakeldap.rb', line 42

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