Skip to content

Commit

Permalink
Add missing MailNickname validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmarabeas committed Jun 15, 2020
1 parent a85f77f commit 9c3f091
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions azuread/data_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func dataUsers() *schema.Resource {
Type: schema.TypeList,
Optional: true,
Computed: true,
ConflictsWith: []string{"user_principal_names"},
ConflictsWith: []string{"user_principal_names", "mail_nicknames"},
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validate.UUID,
Expand All @@ -37,7 +37,7 @@ func dataUsers() *schema.Resource {
Type: schema.TypeList,
Optional: true,
Computed: true,
ConflictsWith: []string{"object_ids"},
ConflictsWith: []string{"object_ids", "mail_nicknames"},
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validate.NoEmptyStrings,
Expand Down Expand Up @@ -181,11 +181,11 @@ func dataSourceUsersRead(d *schema.ResourceData, meta interface{}) error {
mailNicknames := make([]string, 0, len(users))
var userList []map[string]interface{}
for _, u := range users {
if !gracefulError && (u.ObjectID == nil || u.UserPrincipalName == nil) {
if !gracefulError && (u.ObjectID == nil || u.UserPrincipalName == nil || u.MailNickname == nil) {
return fmt.Errorf("User with nil ObjectId or UPN was found: %v", u)
}

if u.ObjectID != nil || u.UserPrincipalName != nil {
if u.ObjectID != nil || u.UserPrincipalName != nil || u.MailNickname != nil {
oids = append(oids, *u.ObjectID)
upns = append(upns, *u.UserPrincipalName)
mailNicknames = append(mailNicknames, *u.MailNickname)
Expand Down

0 comments on commit 9c3f091

Please sign in to comment.