Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azuredevops_identity_user - validateIdentityUser based on CustomDisplayName userName(search criteria) match #1072

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
Collaborator

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