From 82a8f44a2f4cf0686635d2a23ebb41a8f445194e Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Fri, 23 Feb 2018 15:35:58 -0800 Subject: Simplify server bind functions For our purposes, it doesn't need to route multiple functions across different DNs, so use a simple function instead. --- server_bind.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'server_bind.go') diff --git a/server_bind.go b/server_bind.go index da8b062..e0c19f4 100644 --- a/server_bind.go +++ b/server_bind.go @@ -1,12 +1,13 @@ package ldapserver import ( - "github.com/mark-rushakoff/ldapserver/internal/asn1-ber" "log" "net" + + "github.com/mark-rushakoff/ldapserver/internal/asn1-ber" ) -func HandleBindRequest(req *ber.Packet, fns map[string]Binder, conn net.Conn) (resultCode LDAPResultCode) { +func HandleBindRequest(req *ber.Packet, fn BindFunc, conn net.Conn) (resultCode LDAPResultCode) { defer func() { if r := recover(); r != nil { resultCode = LDAPResultOperationsError @@ -35,12 +36,7 @@ func HandleBindRequest(req *ber.Packet, fns map[string]Binder, conn net.Conn) (r return LDAPResultInappropriateAuthentication case LDAPBindAuthSimple: if len(req.Children) == 3 { - fnNames := []string{} - for k := range fns { - fnNames = append(fnNames, k) - } - fn := routeFunc(bindDN, fnNames) - resultCode, err := fns[fn].Bind(bindDN, bindAuth.Data.String(), conn) + resultCode, err := fn(bindDN, bindAuth.Data.String(), conn) if err != nil { log.Printf("BindFn Error %s", err.Error()) return LDAPResultOperationsError -- cgit v1.2.3