diff --git a/internal/ldap/object.go b/internal/ldap/object.go index d4e5c6f..fcefec7 100644 --- a/internal/ldap/object.go +++ b/internal/ldap/object.go @@ -8,6 +8,7 @@ package ldap import ( "fmt" + "regexp" "github.com/majewsky/portunus/internal/core" ) @@ -94,10 +95,11 @@ func renderUser(u core.User, dnSuffix string, allGroups []core.Group) Object { if u.POSIX.LoginShell != "" { obj.Attributes["loginShell"] = []string{u.POSIX.LoginShell} } + var nonASCII = regexp.MustCompile("[^\\x00-\\x7F]") if u.POSIX.GECOS == "" { - obj.Attributes["gecos"] = []string{u.FullName()} + obj.Attributes["gecos"] = []string{nonASCII.ReplaceAllString(u.FullName(), "")} } else { - obj.Attributes["gecos"] = []string{u.POSIX.GECOS} + obj.Attributes["gecos"] = []string{nonASCII.ReplaceAllString(u.POSIX.GECOS, "")} } obj.Attributes["objectClass"] = append(obj.Attributes["objectClass"], "posixAccount") }