Skip to content

Commit

Permalink
Merge pull request #406 from hashicorp/d/user-data-source-type
Browse files Browse the repository at this point in the history
data.azuread_user: export the user_type attribute
  • Loading branch information
manicminer authored Feb 24, 2021
2 parents 4d3c5aa + f1ec534 commit d32712f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ The following attributes are exported:
* `surname` - The user's surname (family name or last name).
* `usage_location` - The usage location of the Azure AD User.
* `user_principal_name` - The User Principal Name of the Azure AD User.
* `user_type` - The user type in the directory. One of `Guest` or `Member`.
4 changes: 3 additions & 1 deletion docs/resources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ The following arguments are supported:
* `surname` - (Optional) The user's surname (family name or last name).
* `usage_location` - (Optional) The usage location of the User. Required for users that will be assigned licenses due to legal requirement to check for availability of services in countries. The usage location is a two letter country code (ISO standard 3166). Examples include: `NO`, `JP`, and `GB`. Cannot be reset to null once set.
* `user_principal_name` - (Required) The User Principal Name of the User.
* `user_type` - (Optional) - The user type in the directory. Valid values are `Guest` and `Member`. Defaults to `Member`.
* `user_type` - (Optional) The user type in the directory. Valid values are `Guest` and `Member`. Defaults to `Member`.

~> Note on Guest Users: Due to API limitations, when configuring a Guest user, `password` must be specified. Since the password isn't used for authenticating the user, it's suggested to specify a placeholder string. This will be fixed in version 2.0 of the provider.

## Attributes Reference

Expand Down
7 changes: 7 additions & 0 deletions internal/services/users/user_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func userData() *schema.Resource {
Computed: true,
Description: "The primary cellular telephone number for the user.",
},

"user_type": {
Type: schema.TypeString,
Computed: true,
Description: "Whether the user is homed in the current tenant or a guest user invited from another tenant.",
},
},
}
}
Expand Down Expand Up @@ -215,6 +221,7 @@ func userDataRead(ctx context.Context, d *schema.ResourceData, meta interface{})
tf.Set(d, "surname", user.Surname)
tf.Set(d, "usage_location", user.UsageLocation)
tf.Set(d, "user_principal_name", user.UserPrincipalName)
tf.Set(d, "user_type", user.UserType)

jobTitle := ""
if v, ok := user.AdditionalProperties["jobTitle"]; ok {
Expand Down
1 change: 1 addition & 0 deletions internal/services/users/user_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (UserDataSource) testCheckFunc(data acceptance.TestData) resource.TestCheck
check.That(data.ResourceName).Key("country").HasValue(fmt.Sprintf("acctestUser-%d-Country", data.RandomInteger)),
check.That(data.ResourceName).Key("postal_code").HasValue("111111"),
check.That(data.ResourceName).Key("mobile").HasValue("(555) 555-5555"),
check.That(data.ResourceName).Key("user_type").HasValue("Member"),
)
}

Expand Down

0 comments on commit d32712f

Please sign in to comment.