From 0209addad1ef9fe6a7eb21d13aa6906715c8999a Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 12 Jun 2026 06:52:39 +0000 Subject: [PATCH] OK --- examples/ldapdb.yaml | 23 ++++++++++++++++++++++- examples/server2.rb | 25 +++++++------------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/examples/ldapdb.yaml b/examples/ldapdb.yaml index 5959cf1..c6e97be 100644 --- a/examples/ldapdb.yaml +++ b/examples/ldapdb.yaml @@ -2,11 +2,32 @@ dc=pvincent,dc=re: cn: - Top object -cn=admin,dc=pvincent,dc=re: +mail=admin@pvincent.re,dc=zourit,dc=re: cn: - admin sn: - Vincentdmin mail: - admin@pvincent.re +mail=test1@pvincent.re,dc=zourit,dc=re: + cn: + - test1 + sn: + - Test1 + mail: + - test1@pvincent.re +mail=test2@pvincent.re,dc=zourit,dc=re: + cn: + - test2 + sn: + - Test2 + mail: + - test2@pvincent.re +mail=test3@pvincent.re,dc=zourit,dc=re: + cn: + - test3 + sn: + - Test3 + mail: + - test3@pvincent.re diff --git a/examples/server2.rb b/examples/server2.rb index 28468d3..3d6a004 100755 --- a/examples/server2.rb +++ b/examples/server2.rb @@ -26,25 +26,16 @@ class HashOperation < LDAP::Server::Operation version = protocolOp.value[0].value authentication = protocolOp.value[2] 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 - # 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) $logger.info("SEARCHING...basedn=#{basedn}, scope=#{scope}, deref=#{deref}, filter=#{filter}") basedn = basedn.downcase - result = nil + nil case scope when LDAP::Server::BaseObject # client asked for single object by DN @@ -52,22 +43,20 @@ class HashOperation < LDAP::Server::Operation raise LDAP::ResultError::NoSuchObject unless obj $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 @hash.each do |dn, av| next unless dn.index(basedn, -basedn.length) # under basedn? 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 else raise LDAP::ResultError::UnwillingToPerform, 'OneLevel not implemented' end - $logger.info "result=#{result}" - # result end end