diff --git a/authenticator/ldap_test.go b/authenticator/ldap_test.go index 407a33b..e31639a 100644 --- a/authenticator/ldap_test.go +++ b/authenticator/ldap_test.go @@ -352,6 +352,8 @@ func TestGetCNFromDN(t *testing.T) { res = getCNFromDN("cn=test") assert.Equal(t, "test", res) res = getCNFromDN("test") + assert.Equal(t, "test", res) + res = getCNFromDN("") assert.Empty(t, res) res = getCNFromDN("cn=admin ,ou=users,dc=mylab,dc=local") assert.Equal(t, "admin", res) diff --git a/authenticator/utils.go b/authenticator/utils.go index 15f61ef..4ec9c47 100644 --- a/authenticator/utils.go +++ b/authenticator/utils.go @@ -85,6 +85,7 @@ func getCNFromDN(dn string) string { if strings.HasPrefix(cn, "cn=") || strings.HasPrefix(cn, "ou=") { return strings.TrimSpace(cn[3:]) } + return cn } return "" }