diff --git a/changelog/unreleased/fix-omitempty-givenName.md b/changelog/unreleased/fix-omitempty-givenName.md new file mode 100644 index 0000000000..08ae5157a9 --- /dev/null +++ b/changelog/unreleased/fix-omitempty-givenName.md @@ -0,0 +1,6 @@ +Bugfix: Fix the empty string givenName attribute when creating user + +Omitempty givenName attribute when creating user + +https://github.com/owncloud/ocis/issues/5431 +https://github.com/owncloud/ocis/pull/6259 diff --git a/services/graph/pkg/identity/ldap.go b/services/graph/pkg/identity/ldap.go index 6920a43f4c..c64eaab9a4 100644 --- a/services/graph/pkg/identity/ldap.go +++ b/services/graph/pkg/identity/ldap.go @@ -784,7 +784,6 @@ func (i *LDAP) createUserModelFromLDAP(e *ldap.Entry) *libregraph.User { if err != nil { i.logger.Warn().Str("dn", e.DN).Str(i.userAttributeMap.id, e.GetAttributeValue(i.userAttributeMap.id)).Msg("Invalid User. Cannot convert UUID") } - givenName := e.GetEqualFoldAttributeValue(i.userAttributeMap.givenName) surname := e.GetEqualFoldAttributeValue(i.userAttributeMap.surname) if id != "" && opsan != "" { @@ -793,7 +792,7 @@ func (i *LDAP) createUserModelFromLDAP(e *ldap.Entry) *libregraph.User { Mail: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.mail)), OnPremisesSamAccountName: &opsan, Id: &id, - GivenName: &givenName, + GivenName: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.givenName)), Surname: &surname, UserType: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.userType)), AccountEnabled: booleanOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.accountEnabled)), diff --git a/services/graph/pkg/identity/ldap_test.go b/services/graph/pkg/identity/ldap_test.go index d3bcf91921..3db4efc840 100644 --- a/services/graph/pkg/identity/ldap_test.go +++ b/services/graph/pkg/identity/ldap_test.go @@ -308,6 +308,7 @@ func TestUpdateUser(t *testing.T) { displayName string onPremisesSamAccountName string accountEnabled *bool + givenName *string userType *string } type args struct { @@ -1441,7 +1442,7 @@ func TestUpdateUser(t *testing.T) { DisplayName: &tt.want.displayName, OnPremisesSamAccountName: &tt.want.onPremisesSamAccountName, Surname: &emptyString, - GivenName: &emptyString, + GivenName: tt.want.givenName, UserType: tt.want.userType, }