| 1 |
# Copyright: (c) 2022, Ansible Project |
| 2 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 3 |
|
| 4 |
DOCUMENTATION: |
| 5 |
module: object_info |
| 6 |
short_description: Gather information an Active Directory object |
| 7 |
description: |
| 8 |
- Gather information about multiple Active Directory object(s). |
| 9 |
requirements: |
| 10 |
- C(ActiveDirectory) PowerShell module |
| 11 |
options: |
| 12 |
domain_password: |
| 13 |
description: |
| 14 |
- The password for I(domain_username). |
| 15 |
- This can be set under the R(play's module defaults,module_defaults_groups) |
| 16 |
under the C(group/microsoft.ad.domain) group. |
| 17 |
type: str |
| 18 |
domain_server: |
| 19 |
description: |
| 20 |
- Specified the Active Directory Domain Services instance to connect to. |
| 21 |
- Can be in the form of an FQDN or NetBIOS name. |
| 22 |
- If not specified then the value is based on the default domain of the |
| 23 |
computer running PowerShell. |
| 24 |
- This can be set under the R(play's module defaults,module_defaults_groups) |
| 25 |
under the C(group/microsoft.ad.domain) group. |
| 26 |
type: str |
| 27 |
domain_username: |
| 28 |
description: |
| 29 |
- The username to use when interacting with AD. |
| 30 |
- If this is not set then the user that is used for authentication will |
| 31 |
be the connection user. |
| 32 |
- Ansible will be unable to use the connection user unless auth is |
| 33 |
Kerberos with credential delegation or CredSSP, or become is used on |
| 34 |
the task. |
| 35 |
- This can be set under the R(play's module defaults,module_defaults_groups) |
| 36 |
under the C(group/microsoft.ad.domain) group. |
| 37 |
type: str |
| 38 |
filter: |
| 39 |
description: |
| 40 |
- Specifies a query string using the PowerShell Expression Language |
| 41 |
syntax. |
| 42 |
- This follows the same rules and formatting as the C(-Filter) parameter |
| 43 |
for the PowerShell AD cmdlets except there is no variable |
| 44 |
substitutions. |
| 45 |
- This is mutually exclusive with I(identity) and I(ldap_filter). |
| 46 |
type: str |
| 47 |
identity: |
| 48 |
description: |
| 49 |
- Specifies a single Active Directory object by its distinguished name |
| 50 |
or its object GUID. |
| 51 |
- This is mutually exclusive with I(filter) and I(ldap_filter). |
| 52 |
- This cannot be used with either the I(search_base) or I(search_scope) |
| 53 |
options. |
| 54 |
type: str |
| 55 |
include_deleted: |
| 56 |
description: |
| 57 |
- Also search for deleted Active Directory objects. |
| 58 |
default: false |
| 59 |
type: bool |
| 60 |
ldap_filter: |
| 61 |
description: |
| 62 |
- Like I(filter) but this is a traditional LDAP query string to filter |
| 63 |
the objects to return. |
| 64 |
- This is mutually exclusive with I(filter) and I(identity). |
| 65 |
type: str |
| 66 |
properties: |
| 67 |
description: |
| 68 |
- A list of properties to return. |
| 69 |
- If a property is C(*), all properties that have a set value on the AD |
| 70 |
object will be returned. |
| 71 |
- If a property is valid on the object but not set, it is only returned |
| 72 |
if defined explicitly in this option list. |
| 73 |
- The properties C(DistinguishedName), C(Name), C(ObjectClass), and |
| 74 |
C(ObjectGUID) are always returned. |
| 75 |
- Specifying multiple properties can have a performance impact, it is |
| 76 |
best to only return what is needed. |
| 77 |
- If an invalid property is specified then the module will display a |
| 78 |
warning for each object it is invalid on. |
| 79 |
type: list |
| 80 |
elements: str |
| 81 |
search_base: |
| 82 |
description: |
| 83 |
- Specify the Active Directory path to search for objects in. |
| 84 |
- This cannot be set with I(identity). |
| 85 |
- By default the search base is the default naming context of the target |
| 86 |
AD instance which is the DN returned by |
| 87 |
C(Get-ADRootDSE | Select-Object -ExpandProperty defaultNamingContext). |
| 88 |
type: str |
| 89 |
search_scope: |
| 90 |
description: |
| 91 |
- Specify the scope of when searching for an object in the |
| 92 |
I(search_base). |
| 93 |
- C(base) will limit the search to the base object so the maximum number |
| 94 |
of objects returned is always one. This will not search any objects |
| 95 |
inside a container. |
| 96 |
- C(one_level) will search the current path and any immediate objects in |
| 97 |
that path. |
| 98 |
- C(subtree) will search the current path and all objects of that path |
| 99 |
recursively. |
| 100 |
- This cannot be set with I(identity). |
| 101 |
choices: |
| 102 |
- base |
| 103 |
- one_level |
| 104 |
- subtree |
| 105 |
type: str |
| 106 |
notes: |
| 107 |
- The C(groupType_AnsibleFlags), |
| 108 |
C(msDS-SupportedEncryptionTypes_AnsibleFlags), |
| 109 |
C(sAMAccountType_AnsibleFlags), and C(userAccountControl_AnsibleFlags) |
| 110 |
return property is something set by the module itself as an easy way to |
| 111 |
view what those flags represent. These properties cannot be used as part |
| 112 |
of the I(filter) or I(ldap_filter) and are automatically added if those |
| 113 |
properties were requested. |
| 114 |
- This module must be run on a Windows target host with the |
| 115 |
C(ActiveDirectory) module installed. |
| 116 |
extends_documentation_fragment: |
| 117 |
- ansible.builtin.action_common_attributes |
| 118 |
attributes: |
| 119 |
check_mode: |
| 120 |
support: full |
| 121 |
diff_mode: |
| 122 |
support: none |
| 123 |
platform: |
| 124 |
platforms: |
| 125 |
- windows |
| 126 |
seealso: |
| 127 |
- module: microsoft.ad.domain |
| 128 |
- module: microsoft.ad.domain_controller |
| 129 |
- module: microsoft.ad.group |
| 130 |
- module: microsoft.ad.object |
| 131 |
- module: microsoft.ad.user |
| 132 |
- module: microsoft.ad.computer |
| 133 |
- ref: Migration guide <ansible_collections.microsoft.ad.docsite.guide_migration.migrated_modules.win_domain_object_info> |
| 134 |
description: This module replaces C(community.windows.win_domain_object_info). See the migration guide for details. |
| 135 |
- module: community.windows.win_domain_object_info |
| 136 |
author: |
| 137 |
- Jordan Borean (@jborean93) |
| 138 |
|
| 139 |
EXAMPLES: | |
| 140 |
- name: Get all properties for the specified account using its DistinguishedName |
| 141 |
microsoft.ad.object_info: |
| 142 |
identity: CN=Username,CN=Users,DC=domain,DC=com |
| 143 |
properties: '*' |
| 144 |
|
| 145 |
- name: Get the SID for all user accounts as a filter |
| 146 |
microsoft.ad.object_info: |
| 147 |
filter: ObjectClass -eq 'user' -and objectCategory -eq 'Person' |
| 148 |
properties: |
| 149 |
- objectSid |
| 150 |
|
| 151 |
- name: Get the SID for all user accounts as a LDAP filter |
| 152 |
microsoft.ad.object_info: |
| 153 |
ldap_filter: (&(objectClass=user)(objectCategory=Person)) |
| 154 |
properties: |
| 155 |
- objectSid |
| 156 |
|
| 157 |
- name: Search all computer accounts in a specific path that were added after February 1st |
| 158 |
microsoft.ad.object_info: |
| 159 |
filter: objectClass -eq 'computer' -and whenCreated -gt '20200201000000.0Z' |
| 160 |
properties: '*' |
| 161 |
search_scope: one_level |
| 162 |
search_base: CN=Computers,DC=domain,DC=com |
| 163 |
|
| 164 |
RETURN: |
| 165 |
objects: |
| 166 |
description: |
| 167 |
- A list of dictionaries that are the Active Directory objects found and |
| 168 |
the properties requested. |
| 169 |
- The dict's keys are the property name and the value is the value for the |
| 170 |
property. |
| 171 |
- All date properties are return in the ISO 8601 format in the UTC |
| 172 |
timezone. |
| 173 |
- All SID properties are returned as a dict with the keys C(Sid) as the |
| 174 |
SID string and C(Name) as the translated SID account name. |
| 175 |
- All byte properties are returned as a base64 string. |
| 176 |
- All security descriptor properties are returned as the SDDL string of |
| 177 |
that descriptor. |
| 178 |
- The properties C(DistinguishedName), C(Name), C(ObjectClass), and |
| 179 |
C(ObjectGUID) are always returned. |
| 180 |
returned: always |
| 181 |
type: list |
| 182 |
elements: dict |
| 183 |
sample: | |
| 184 |
[{ |
| 185 |
"accountExpires": 0, |
| 186 |
"adminCount": 1, |
| 187 |
"CanonicalName": "domain.com/Users/Administrator", |
| 188 |
"CN": "Administrator", |
| 189 |
"Created": "2020-01-13T09:03:22.0000000Z", |
| 190 |
"Description": "Built-in account for administering computer/domain", |
| 191 |
"DisplayName": null, |
| 192 |
"DistinguishedName": "CN=Administrator,CN=Users,DC=domain,DC=com", |
| 193 |
"memberOf": [ |
| 194 |
"CN=Group Policy Creator Owners,CN=Users,DC=domain,DC=com", |
| 195 |
"CN=Domain Admins",CN=Users,DC=domain,DC=com" |
| 196 |
], |
| 197 |
"Name": "Administrator", |
| 198 |
"nTSecurityDescriptor": "O:DAG:DAD:PAI(A;;LCRPLORC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)(A;;CCDCLCSWRPWPLOCRSDRCWDWO;;;BA)", |
| 199 |
"ObjectCategory": "CN=Person,CN=Schema,CN=Configuration,DC=domain,DC=com", |
| 200 |
"ObjectClass": "user", |
| 201 |
"ObjectGUID": "c8c6569e-4688-4f3c-8462-afc4ff60817b", |
| 202 |
"objectSid": { |
| 203 |
"Sid": "S-1-5-21-2959096244-3298113601-420842770-500", |
| 204 |
"Name": "DOMAIN\Administrator" |
| 205 |
}, |
| 206 |
"sAMAccountName": "Administrator", |
| 207 |
}] |