Skip to content
6 changes: 5 additions & 1 deletion azuredevops/internal/service/identity/data_identity_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func flattenIdentityUsers(users *[]identity.Identity) (*[]identity.Identity, err
Id: user.Id,
ProviderDisplayName: user.ProviderDisplayName,
// Add other fields here if needed
CustomDisplayName: user.CustomDisplayName, //It might be the match is based on CustomDisplayName
// TODO check how to compare against "DirectoryAlias":{"$type":"System.String","$value":"user_name"}} and "Account":{"$type":"System.String","$value":"Norkevicius_Ad"}
}
results[i] = newUser
}
Expand All @@ -101,7 +103,9 @@ func flattenIdentityUsers(users *[]identity.Identity) (*[]identity.Identity, err
// Filter results to validate user is correct. Occurs post-flatten due to missing properties based on search-filter.
func validateIdentityUser(users *[]identity.Identity, userName string, searchFilter string) *identity.Identity {
for _, user := range *users {
if strings.Contains(strings.ToLower(*user.ProviderDisplayName), strings.ToLower(userName)) {
if strings.Contains(strings.ToLower(*user.ProviderDisplayName), strings.ToLower(userName)) || strings.Contains(strings.ToLower(*user.CustomDisplayName), strings.ToLower(userName)) { // It might be the match is based on CustomDisplayName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if strings.Contains(strings.ToLower(*user.ProviderDisplayName), strings.ToLower(userName)) || strings.Contains(strings.ToLower(*user.CustomDisplayName), strings.ToLower(userName)) { // It might be the match is based on CustomDisplayName
if user.ProviderDisplayName != nil && strings.Contains(strings.ToLower(*user.ProviderDisplayName), strings.ToLower(userName)) {
return &user
}
if user.CustomDisplayName != nil && strings.Contains(strings.ToLower(*user.CustomDisplayName), strings.ToLower(userName)) {
return &user
}


// TODO check how to compare against "DirectoryAlias":{"$type":"System.String","$value":"user_name"}} and "Account":{"$type":"System.String","$value":"Norkevicius_Ad"}
return &user
}
}
Expand Down