Skip to content

Commit

Permalink
Merge pull request #6259 from 2403905/issue-5431
Browse files Browse the repository at this point in the history
Omitempty givenName attribute when create user #5431
  • Loading branch information
2403905 authored May 10, 2023
2 parents 1c0e318 + 11e51b9 commit 21dfe2d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-omitempty-givenName.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions services/graph/pkg/identity/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -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)),
Expand Down
3 changes: 2 additions & 1 deletion services/graph/pkg/identity/ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func TestUpdateUser(t *testing.T) {
displayName string
onPremisesSamAccountName string
accountEnabled *bool
givenName *string
userType *string
}
type args struct {
Expand Down Expand Up @@ -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,
}

Expand Down

0 comments on commit 21dfe2d

Please sign in to comment.