feat: add configurable search filter

This commit is contained in:
Stavros
2025-07-05 15:22:09 +03:00
parent 0e43c50ac0
commit 01042a3003
3 changed files with 6 additions and 1 deletions

View File

@@ -41,7 +41,7 @@ func (l *LDAP) Search(username string) (string, error) {
searchRequest := ldapgo.NewSearchRequest(
l.BaseDN,
ldapgo.ScopeWholeSubtree, ldapgo.NeverDerefAliases, 0, 0, false,
fmt.Sprintf("(uid=%s)", username),
fmt.Sprintf(l.Config.SearchFilter, username),
[]string{"dn"},
nil,
)

View File

@@ -41,6 +41,7 @@ type Config struct {
LdapBindPassword string `mapstructure:"ldap-bind-password"`
LdapBaseDN string `mapstructure:"ldap-base-dn"`
LdapInsecure bool `mapstructure:"ldap-insecure"`
LdapSearchFilter string `mapstructure:"ldap-search-filter"`
}
// Server configuration
@@ -135,4 +136,5 @@ type LdapConfig struct {
BindPassword string
BaseDN string
Insecure bool
SearchFilter string
}