From ec795bcc71246ed2878d4c00913f9d40590b8160 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 24 Feb 2021 12:23:09 +0000 Subject: [PATCH 1/3] data.azuread_user: export the user_type attribute --- docs/data-sources/user.md | 1 + internal/services/users/user_data_source.go | 6 ++++++ internal/services/users/user_data_source_test.go | 1 + 3 files changed, 8 insertions(+) diff --git a/docs/data-sources/user.md b/docs/data-sources/user.md index 781dd93172..336a97803c 100644 --- a/docs/data-sources/user.md +++ b/docs/data-sources/user.md @@ -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`. diff --git a/internal/services/users/user_data_source.go b/internal/services/users/user_data_source.go index d9ffba41a1..96539a1059 100644 --- a/internal/services/users/user_data_source.go +++ b/internal/services/users/user_data_source.go @@ -156,6 +156,11 @@ func userData() *schema.Resource { Computed: true, Description: "The primary cellular telephone number for the user.", }, + + "user_type": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -215,6 +220,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 { diff --git a/internal/services/users/user_data_source_test.go b/internal/services/users/user_data_source_test.go index bc7e066a24..6e63e54260 100644 --- a/internal/services/users/user_data_source_test.go +++ b/internal/services/users/user_data_source_test.go @@ -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"), ) } From b69ca781ff4a193fcf366e87959d6a67029a5bf2 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 24 Feb 2021 12:23:41 +0000 Subject: [PATCH 2/3] Docs note on password when configuring guest users --- docs/resources/user.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/resources/user.md b/docs/resources/user.md index ac172c1b59..ccca278f73 100644 --- a/docs/resources/user.md +++ b/docs/resources/user.md @@ -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 From f1ec53482f5a9b3f86337b9563c70db803da812b Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 24 Feb 2021 13:28:35 +0000 Subject: [PATCH 3/3] Address review: add description for user_type attribute --- internal/services/users/user_data_source.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/services/users/user_data_source.go b/internal/services/users/user_data_source.go index 96539a1059..5dafe48d0d 100644 --- a/internal/services/users/user_data_source.go +++ b/internal/services/users/user_data_source.go @@ -158,8 +158,9 @@ func userData() *schema.Resource { }, "user_type": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "Whether the user is homed in the current tenant or a guest user invited from another tenant.", }, }, }