From 272cbe260914f0b4255dd02de4a37f7a43e5c1a5 Mon Sep 17 00:00:00 2001 From: Tatsuya Ogawa Date: Tue, 15 Sep 2020 23:49:11 +0900 Subject: [PATCH 1/3] fix LdapServerAsnSyntax compile --- testserver/ldapserver.rb | 43 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/testserver/ldapserver.rb b/testserver/ldapserver.rb index aa8881a2..a44b7cdd 100644 --- a/testserver/ldapserver.rb +++ b/testserver/ldapserver.rb @@ -14,27 +14,7 @@ #------------------------------------------------ -module LdapServer - LdapServerAsnSyntax = { - :application => { - :constructed => { - 0 => :array, # LDAP BindRequest - 3 => :array # LDAP SearchRequest - }, - :primitive => { - 2 => :string, # ldapsearch sends this to unbind - }, - }, - :context_specific => { - :primitive => { - 0 => :string, # simple auth (password) - 7 => :string # present filter - }, - :constructed => { - 3 => :array # equality filter - }, - }, - } +module LdapServer def post_init $logger.info "Accepted LDAP connection" @@ -192,6 +172,27 @@ def load_test_data require 'net/ldap' + LdapServerAsnSyntax = Net::BER.compile_syntax({ + :application => { + :constructed => { + 0 => :array, # LDAP BindRequest + 3 => :array # LDAP SearchRequest + }, + :primitive => { + 2 => :string, # ldapsearch sends this to unbind + }, + }, + :context_specific => { + :primitive => { + 0 => :string, # simple auth (password) + 7 => :string # present filter + }, + :constructed => { + 3 => :array # equality filter + }, + }, + }) + EventMachine.run do $logger.info "starting LDAP server on 127.0.0.1 port 3890" EventMachine.start_server "127.0.0.1", 3890, LdapServer From 364c92447d62af8e4feeb2f82b6a39c846da5aa2 Mon Sep 17 00:00:00 2001 From: Tatsuya Ogawa Date: Wed, 16 Sep 2020 00:14:50 +0900 Subject: [PATCH 2/3] fix typo --- testserver/ldapserver.rb | 42 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/testserver/ldapserver.rb b/testserver/ldapserver.rb index a44b7cdd..504a136d 100644 --- a/testserver/ldapserver.rb +++ b/testserver/ldapserver.rb @@ -172,26 +172,28 @@ def load_test_data require 'net/ldap' - LdapServerAsnSyntax = Net::BER.compile_syntax({ - :application => { - :constructed => { - 0 => :array, # LDAP BindRequest - 3 => :array # LDAP SearchRequest - }, - :primitive => { - 2 => :string, # ldapsearch sends this to unbind - }, - }, - :context_specific => { - :primitive => { - 0 => :string, # simple auth (password) - 7 => :string # present filter - }, - :constructed => { - 3 => :array # equality filter - }, - }, - }) + LdapServerAsnSyntax = Net::BER.compile_syntax( + { + :application => { + :constructed => { + 0 => :array, # LDAP BindRequest + 3 => :array # LDAP SearchRequest + }, + :primitive => { + 2 => :string, # ldapsearch sends this to unbind + }, + }, + :context_specific => { + :primitive => { + 0 => :string, # simple auth (password) + 7 => :string # present filter + }, + :constructed => { + 3 => :array # equality filter + }, + }, + } + ) EventMachine.run do $logger.info "starting LDAP server on 127.0.0.1 port 3890" From 8e481a4df1e9b2ae6ba67b027fd7ec6c57956a52 Mon Sep 17 00:00:00 2001 From: Tatsuya Ogawa Date: Fri, 9 Oct 2020 19:02:57 +0900 Subject: [PATCH 3/3] fix syntax --- testserver/ldapserver.rb | 47 +++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/testserver/ldapserver.rb b/testserver/ldapserver.rb index 504a136d..9adeacb0 100644 --- a/testserver/ldapserver.rb +++ b/testserver/ldapserver.rb @@ -14,7 +14,27 @@ #------------------------------------------------ -module LdapServer +module LdapServer + LdapServerAsnSyntaxTemplate = { + :application => { + :constructed => { + 0 => :array, # LDAP BindRequest + 3 => :array # LDAP SearchRequest + }, + :primitive => { + 2 => :string, # ldapsearch sends this to unbind + }, + }, + :context_specific => { + :primitive => { + 0 => :string, # simple auth (password) + 7 => :string # present filter + }, + :constructed => { + 3 => :array # equality filter + }, + }, + } def post_init $logger.info "Accepted LDAP connection" @@ -171,30 +191,7 @@ def load_test_data $ldif = load_test_data require 'net/ldap' - - LdapServerAsnSyntax = Net::BER.compile_syntax( - { - :application => { - :constructed => { - 0 => :array, # LDAP BindRequest - 3 => :array # LDAP SearchRequest - }, - :primitive => { - 2 => :string, # ldapsearch sends this to unbind - }, - }, - :context_specific => { - :primitive => { - 0 => :string, # simple auth (password) - 7 => :string # present filter - }, - :constructed => { - 3 => :array # equality filter - }, - }, - } - ) - + LdapServerAsnSyntax = Net::BER.compile_syntax(LdapServerAsnSyntaxTemplate) EventMachine.run do $logger.info "starting LDAP server on 127.0.0.1 port 3890" EventMachine.start_server "127.0.0.1", 3890, LdapServer