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

data.azuread_user: export the user_type attribute #406

Merged
merged 3 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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