Omitempty givenName attribute when creating user #5431

This commit is contained in:
Roman Perekhod
2023-05-09 12:29:19 +02:00
parent 233e406be4
commit 11e51b9812
3 changed files with 9 additions and 3 deletions

View File

@@ -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

View File

@@ -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)),

View File

@@ -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,
}