forked from mikaelkrief/inspec-azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazurerm_ad_user.md.erb
248 lines (160 loc) · 5.42 KB
/
azurerm_ad_user.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
---
title: About the azurerm_ad_user Resource
platform: azure
---
# azurerm\_ad\_user
Use the `azurerm_ad_user` InSpec audit resource to test properties of
an Azure Active Directory user within a Tenant.
<br />
## Azure REST API version
This resource interacts with version `1.6` of the Azure Graph API. For more
information see the [official Azure documentation](https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/users-operations#GetAUser).
At the moment, there doesn't appear to be a way to select the version of the
Azure API docs. If you notice a newer version being referenced in the official
documentation please open an issue or submit a pull request using the updated
version.
## Availability
### Installation
This resource is available in the `inspec-azure` [resource
pack](https://www.inspec.io/docs/reference/glossary/#resource-pack). To use it, add the
following to your `inspec.yml` in your top-level profile:
depends:
inspec-azure:
git: https://github.com/inspec/inspec-azure.git
You'll also need to setup your Azure credentials; see the resource pack
[README](https://github.com/inspec/inspec-azure#inspec-for-azure).
### Version
This resource first became available in 1.1.0 of the inspec-azure resource pack.
## Syntax
The `user_id` must be given as a parameter.
describe azurerm_ad_user(user_id: 'someUserId') do
it { should exist }
end
<br />
## Examples
If an Active Directory user account is referenced with a valid ID
describe azurerm_ad_user(user_id: 'someValidId')
it { should exist }
end
If an Active Directory user account is referenced with an invalid ID
describe azurerm_ad_user(user_id: 'someInvalidId')
it { should_not exist }
end
<br />
## Parameters
- `user_id`
## Parameter Examples
# user_id is a required parameter
describe azurerm_ad_user(user_id: 'MyUserId') do
...
end
## Attributes
- `object_id`
- `account_enabled`
- `city`
- `country`
- `department`
- `displayName`
- `facsimile_telephone_number`
- `given_name`
- `job_title`
- `mail`
- `mail_nickname`
- `mobile`
- `password_policies`
- `password_profile`
- `postal_code`
- `state`
- `street_address`
- `surname`
- `telephone_number`
- `usage_location`
- `user_principal_name`
- `user_type`
### object\_id
The user's object ID.
### account\_enabled
Whether the account is enabled.
### city
The user's city.
### country
The user's country.
### department
The user's department.
### displayName
The display name of the user.
### facsimile\_telephone\_number
the user's facsimile (fax) number.
### given\_name
the given name for the user.
### job\_title
the user's job title.
### mail
the primary email address of the user.
### mail\_nickname
The mail alias for the user.
### mobile
The user's mobile (cell) phone number.
### password\_policies
The password policies for the user.
### password\_profile
The password profile for the user.
### postal\_code
The user's postal (ZIP) code.
### state
The user's state.
### street\_address
The user's street address.
### surname
The user's surname (family name or last name).
### telephone\_number
The user's telephone number.
### usage\_location
A two letter country code (ISO standard 3166). Required for users that will be
assigned licenses due to legal requirement to check for availability of
services in countries. Examples include: "US", "JP", and "GB".
### user\_principal\_name
The principal name of the user.
### user\_type
A string value that can be used to classify user types in your directory, such as 'Member' and 'Guest'.
### Other Attributes
There are additional attributes that may be accessed that we have not
documented. Please take a look at the [Azure documentation](#-Azure-REST-API-version).
Any attribute in the response may be accessed with the key names separated by
dots (`.`). Given the example response in their documentation:
```
...
"preferredLanguage": "en-US",
"provisionedPlans": [
{
"capabilityStatus": "Enabled",
"provisioningStatus": "Success",
"service": "exchange"
},
...
```
We may access `provisioningStatus` with:
```
its('provisionedPlants.first.provisioningStatus') { should eq "Success" }
```
The API may not always return keys that do not have any associated data. There
may be cases where the deeply nested property may not have the desired
attribute along your call chain. If you find yourself writing tests against
properties that may be nil, fork this resource pack and add an accessor to the
resource. Within that accessor you'll be able to guard against nil keys. Pull
requests are always welcome.
## Matchers
This InSpec audit resource has the following special matchers. For a full list of
available matchers, please visit our [Universal Matchers
page](https://www.inspec.io/docs/reference/matchers/).
### exists
describe azurerm_ad_user(user_id: 'someUserId') do
it { should exist }
end
## Azure Permissions
The Client/Active Directory Application you have configured Inspec Azure to use (`AZURE_CLIENT_ID`) must
have permissions to read User data from the Azure Graph RBAC API.
Please refer to the [Microsoft Documentation](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications#updating-an-application)
for information on how to grant these permissions to your application.
<br />
Note: An Azure Admin must grant your application these permissions.