fruitbasket/modules/ldap/0004-make-givenName-optional.patch

35 lines
1.4 KiB
Diff
Raw Permalink Normal View History

diff --git a/internal/core/user.go b/internal/core/user.go
2024-03-05 15:10:20 +01:00
index f45fdf7..4f93b37 100644
--- a/internal/core/user.go
+++ b/internal/core/user.go
2024-03-05 15:10:20 +01:00
@@ -76,7 +76,6 @@ func (u User) validateLocal(cfg *ValidationConfig) (errs errext.ErrorSet) {
MustBePosixAccountNameIf(u.LoginName, u.POSIX != nil),
))
errs.Add(ref.Field("given_name").WrapFirst(
- MustNotBeEmpty(u.GivenName),
MustNotHaveSurroundingSpaces(u.GivenName),
))
errs.Add(ref.Field("family_name").WrapFirst(
diff --git a/internal/ldap/object.go b/internal/ldap/object.go
index d4e5c6f..1225084 100644
--- a/internal/ldap/object.go
+++ b/internal/ldap/object.go
@@ -73,7 +73,6 @@ func renderUser(u core.User, dnSuffix string, allGroups []core.Group) Object {
"uid": {u.LoginName},
"cn": {u.FullName()},
"sn": {u.FamilyName},
- "givenName": {u.GivenName},
"userPassword": {u.PasswordHash},
"isMemberOf": memberOfGroupDNames,
"objectClass": {"portunusPerson", "inetOrgPerson", "organizationalPerson", "person", "top"},
2024-03-05 15:10:20 +01:00
@@ -83,6 +82,9 @@ func renderUser(u core.User, dnSuffix string, allGroups []core.Group) Object {
if u.EMailAddress != "" {
obj.Attributes["mail"] = []string{u.EMailAddress}
}
+ if u.GivenName != "" {
+ obj.Attributes["givenName"] = []string{u.GivenName}
+ }
if len(u.SSHPublicKeys) > 0 {
obj.Attributes["sshPublicKey"] = u.SSHPublicKeys
}