|
|
@ -26,25 +26,16 @@ class HashOperation < LDAP::Server::Operation |
|
|
version = protocolOp.value[0].value |
|
|
version = protocolOp.value[0].value |
|
|
authentication = protocolOp.value[2] |
|
|
authentication = protocolOp.value[2] |
|
|
password = authentication.value |
|
|
password = authentication.value |
|
|
$logger.info("AUTHENTICATION ..version=#{version}, dn=#{dn}, password=#{password}") |
|
|
|
|
|
super |
|
|
|
|
|
|
|
|
valid = password == 'toto' |
|
|
|
|
|
$logger.info("AUTHENTICATION ..version=#{version}, dn=#{dn}, valid=#{valid}") |
|
|
|
|
|
send_BindResponse(valid ? 0 : 1) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
# def simple_bind(version, dn, password) |
|
|
|
|
|
# super.simple_bind(version, dn, password) |
|
|
|
|
|
# $logger.info("SIMPLE BIND...version=#{version}, dn=#{dn}") |
|
|
|
|
|
# |
|
|
|
|
|
# raise LDAP::ResultError::ProtocolError, 'version 3 only' if version != 3 |
|
|
|
|
|
# raise LDAP::ResultError::InvalidCredentials, 'Invalid credentials' if password.nil? || password == '' |
|
|
|
|
|
# |
|
|
|
|
|
# $logger.info('authentication SUCCESS') |
|
|
|
|
|
# end |
|
|
|
|
|
# |
|
|
|
|
|
def search(basedn, scope, deref, filter) |
|
|
def search(basedn, scope, deref, filter) |
|
|
$logger.info("SEARCHING...basedn=#{basedn}, scope=#{scope}, deref=#{deref}, filter=#{filter}") |
|
|
$logger.info("SEARCHING...basedn=#{basedn}, scope=#{scope}, deref=#{deref}, filter=#{filter}") |
|
|
|
|
|
|
|
|
basedn = basedn.downcase |
|
|
basedn = basedn.downcase |
|
|
result = nil |
|
|
|
|
|
|
|
|
nil |
|
|
case scope |
|
|
case scope |
|
|
when LDAP::Server::BaseObject |
|
|
when LDAP::Server::BaseObject |
|
|
# client asked for single object by DN |
|
|
# client asked for single object by DN |
|
|
@ -52,22 +43,20 @@ class HashOperation < LDAP::Server::Operation |
|
|
raise LDAP::ResultError::NoSuchObject unless obj |
|
|
raise LDAP::ResultError::NoSuchObject unless obj |
|
|
|
|
|
|
|
|
$logger.info('BaseObject') |
|
|
$logger.info('BaseObject') |
|
|
result = send_SearchResultEntry(basedn, obj) if LDAP::Server::Filter.run(filter, obj) |
|
|
|
|
|
|
|
|
send_SearchResultEntry(basedn, obj) if LDAP::Server::Filter.run(filter, obj) |
|
|
when LDAP::Server::WholeSubtree |
|
|
when LDAP::Server::WholeSubtree |
|
|
@hash.each do |dn, av| |
|
|
@hash.each do |dn, av| |
|
|
next unless dn.index(basedn, -basedn.length) # under basedn? |
|
|
next unless dn.index(basedn, -basedn.length) # under basedn? |
|
|
next unless LDAP::Server::Filter.run(filter, av) # attribute filter? |
|
|
next unless LDAP::Server::Filter.run(filter, av) # attribute filter? |
|
|
|
|
|
|
|
|
$logger.info('WholeSubtree') |
|
|
|
|
|
result = send_SearchResultEntry(dn, av) |
|
|
|
|
|
|
|
|
$logger.info("WholeSubtree av=#{av}") |
|
|
|
|
|
send_SearchResultEntry(dn, av) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
else |
|
|
else |
|
|
raise LDAP::ResultError::UnwillingToPerform, 'OneLevel not implemented' |
|
|
raise LDAP::ResultError::UnwillingToPerform, 'OneLevel not implemented' |
|
|
|
|
|
|
|
|
end |
|
|
end |
|
|
$logger.info "result=#{result}" |
|
|
|
|
|
# result |
|
|
|
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|