| 1 |
# Copyright: (c) 2023, 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 |
| 6 |
short_description: Manage Active Directory objects |
| 7 |
description: |
| 8 |
- Manages Active Directory objects and their attributes. |
| 9 |
options: |
| 10 |
type: |
| 11 |
description: |
| 12 |
- The object type of the AD object. |
| 13 |
- This corresponds to the C(objectClass) of the AD object. |
| 14 |
- Some examples of a type are C(user), C(computer), C(group), C(subnet), |
| 15 |
C(contact), C(container). |
| 16 |
- This is required when I(state=present). |
| 17 |
type: str |
| 18 |
notes: |
| 19 |
- This is a generic module used to create and manage any object type in |
| 20 |
Active Directory. It will not validate all the correct defaults are set |
| 21 |
for each type when it is created. If a type specific module is available |
| 22 |
to manage that AD object type it is recommend to use that. |
| 23 |
- This module must be run on a Windows target host with the |
| 24 |
C(ActiveDirectory) module installed. |
| 25 |
extends_documentation_fragment: |
| 26 |
- microsoft.ad.ad_object |
| 27 |
- ansible.builtin.action_common_attributes |
| 28 |
attributes: |
| 29 |
check_mode: |
| 30 |
support: full |
| 31 |
diff_mode: |
| 32 |
support: full |
| 33 |
platform: |
| 34 |
platforms: |
| 35 |
- windows |
| 36 |
seealso: |
| 37 |
- module: microsoft.ad.domain |
| 38 |
- module: microsoft.ad.domain_controller |
| 39 |
- module: microsoft.ad.object_info |
| 40 |
- module: microsoft.ad.user |
| 41 |
- module: microsoft.ad.computer |
| 42 |
- module: microsoft.ad.group |
| 43 |
author: |
| 44 |
- Jordan Borean (@jborean93) |
| 45 |
|
| 46 |
EXAMPLES: | |
| 47 |
# Use this to get all valid types in a domain environment |
| 48 |
# (Get-ADObject -SearchBase (Get-ADRootDSE).subschemaSubentry -Filter * -Properties objectClasses).objectClasses | |
| 49 |
# Select-String -Pattern "Name\s+'(\w+)'" | |
| 50 |
# ForEach-Object { $_.Matches.Groups[1].Value } | |
| 51 |
# Sort-Object |
| 52 |
|
| 53 |
- name: Create a contact object |
| 54 |
microsoft.ad.object: |
| 55 |
name: MyContact |
| 56 |
description: My Contact Description |
| 57 |
type: contact |
| 58 |
state: present |
| 59 |
|
| 60 |
- name: Rename a contact object |
| 61 |
microsoft.ad.object: |
| 62 |
identity: '{{ contact_obj.object_guid }}' |
| 63 |
name: RenamedContact |
| 64 |
type: contact |
| 65 |
state: present |
| 66 |
|
| 67 |
- name: Move a contact object |
| 68 |
microsoft.ad.object: |
| 69 |
identity: '{{ contact_object.object_guid }}' |
| 70 |
name: MyContact |
| 71 |
path: OU=Contacts,DC=domain,DC=test |
| 72 |
type: contact |
| 73 |
state: present |
| 74 |
|
| 75 |
- name: Remove a contact object in default path |
| 76 |
microsoft.ad.object: |
| 77 |
name: MyContact |
| 78 |
state: absent |
| 79 |
|
| 80 |
- name: Remove a contact object in custom path |
| 81 |
microsoft.ad.object: |
| 82 |
name: MyContact |
| 83 |
path: OU=Contacts,DC=domain,DC=test |
| 84 |
state: absent |
| 85 |
|
| 86 |
- name: Remove a contact by identity |
| 87 |
microsoft.ad.object: |
| 88 |
identity: '{{ contact_obj.object_guid }}' |
| 89 |
state: absent |
| 90 |
|
| 91 |
- name: Create container object with custom attributes |
| 92 |
microsoft.ad.object: |
| 93 |
name: App |
| 94 |
attributes: |
| 95 |
set: |
| 96 |
wWWHomePage: https://ansible.com |
| 97 |
type: container |
| 98 |
state: present |
| 99 |
|
| 100 |
- name: Clear attribute of any value |
| 101 |
microsoft.ad.object: |
| 102 |
name: App |
| 103 |
attributes: |
| 104 |
set: |
| 105 |
wWWHomePage: ~ |
| 106 |
type: container |
| 107 |
state: present |
| 108 |
|
| 109 |
- name: Edit object security with Everyone Allow All access |
| 110 |
microsoft.ad.object: |
| 111 |
name: App |
| 112 |
attributes: |
| 113 |
add: |
| 114 |
nTSecurityDescriptor: |
| 115 |
type: security_descriptor |
| 116 |
value: O:DAG:DAD:PAI(A;CI;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD) |
| 117 |
type: container |
| 118 |
state: present |
| 119 |
|
| 120 |
- name: Ensure multiple values are present in attribute |
| 121 |
microsoft.ad.object: |
| 122 |
name: App |
| 123 |
attributes: |
| 124 |
add: |
| 125 |
extensionName: |
| 126 |
- value 1 |
| 127 |
- value 2 |
| 128 |
type: container |
| 129 |
state: present |
| 130 |
|
| 131 |
- name: Ensure multiple values are not present in attribute |
| 132 |
microsoft.ad.object: |
| 133 |
name: App |
| 134 |
attributes: |
| 135 |
remove: |
| 136 |
extensionName: |
| 137 |
- value 1 |
| 138 |
- value 3 |
| 139 |
type: container |
| 140 |
state: present |
| 141 |
|
| 142 |
RETURN: |
| 143 |
object_guid: |
| 144 |
description: |
| 145 |
- The C(objectGUID) of the AD object that was created, removed, or edited. |
| 146 |
- If a new object was created in check mode, a GUID of 0s will be |
| 147 |
returned. |
| 148 |
returned: always |
| 149 |
type: str |
| 150 |
sample: d84a141f-2b99-4f08-9da0-ed2d26864ba1 |
| 151 |
distinguished_name: |
| 152 |
description: |
| 153 |
- The C(distinguishedName) of the AD object that was created, removed, or |
| 154 |
edited. |
| 155 |
returned: always |
| 156 |
type: str |
| 157 |
sample: CN=TestUser,CN=Users,DC=domain,DC=test |