Skip to content

Latest commit

 

History

History
1217 lines (1176 loc) · 55.4 KB

community.windows.win_domain_user_module.rst

File metadata and controls

1217 lines (1176 loc) · 55.4 KB

community.windows.win_domain_user

Manages Windows Active Directory user accounts

  • Manages Windows Active Directory user accounts.
Parameter Choices/Defaults Comments
account_locked
boolean
    Choices:
  • no
  • yes
no will unlock the user account if locked.
Note that there is not a way to lock an account as an administrator.
Accounts are locked due to user actions; as an admin, you may only unlock a locked account.
If you wish to administratively disable an account, set enabled to no.
attributes
dictionary
A dict of custom LDAP attributes to set on the user.
This can be used to set custom attributes that are not exposed as module parameters, e.g. telephoneNumber.
See the examples on how to format this parameter.
city
string
Configures the user's city.
company
string
Configures the user's company name.
country
string
Configures the user's country code.
Note that this is a two-character ISO 3166 code.
delegates
list / elements=string
added in 1.10.0
Specifies an array of principal objects. This parameter sets the msDS-AllowedToActOnBehalfOfOtherIdentity attribute of a computer account object.
Must be specified as a distinguished name CN=shenetworks,CN=Users,DC=ansible,DC=test

aliases: principals_allowed_to_delegate
description
string
Description of the user
domain_password
string
The password for username.
domain_server
string
Specifies the Active Directory Domain Services instance to connect to.
Can be in the form of an FQDN or NetBIOS name.
If not specified then the value is based on the domain of the computer running PowerShell.
domain_username
string
The username to use when interacting with AD.
If this is not set then the user Ansible used to log in with will be used instead when using CredSSP or Kerberos with credential delegation.
email
string
Configures the user's email address.
This is a record in AD and does not do anything to configure any email servers or systems.
enabled
boolean
    Choices:
  • no
  • yes ←
yes will enable the user account.
no will disable the account.
firstname
string
Configures the user's first name (given name).
groups
list / elements=string
Adds or removes the user from this list of groups, depending on the value of groups_action.
To remove all but the Principal Group, set groups=<principal group name> and groups_action=replace.
Note that users cannot be removed from their principal group (for example, "Domain Users").
groups_action
string
    Choices:
  • add
  • remove
  • replace ←
If add, the user is added to each group in groups where not already a member.
If remove, the user is removed from each group in groups.
If replace, the user is added as a member of each group in groups and removed from any other groups.
groups_missing_behaviour
string
added in 1.10.0
    Choices:
  • fail ←
  • ignore
  • warn
Controls what happens when a group specified by groups is an invalid group name.
fail is the default and will return an error any groups do not exist.
ignore will ignore any groups that does not exist.
warn will display a warning for any groups that do not exist but will continue without failing.
identity
string
Identity parameter used to find the User in the Active Directory.
This value can be in the forms Distinguished Name, objectGUID, objectSid or sAMAccountName.
Default to name if not set.
name
string / required
Name of the user to create, remove or modify.
password
string
Optionally set the user's password to this (plain text) value.
To enable an account - enabled - a password must already be configured on the account, or you must provide a password here.
password_expired
boolean
    Choices:
  • no
  • yes
yes will require the user to change their password at next login.
no will clear the expired password flag.
This is mutually exclusive with password_never_expires.
password_never_expires
boolean
    Choices:
  • no
  • yes
yes will set the password to never expire.
no will allow the password to expire.
This is mutually exclusive with password_expired.
path
string
Container or OU for the new user; if you do not specify this, the user will be placed in the default container for users in the domain.
Setting the path is only available when a new user is created; if you specify a path on an existing user, the user's path will not be updated - you must delete (e.g., state=absent) the user and then re-add the user with the appropriate path.
postal_code
string
Configures the user's postal code / zip code.
sam_account_name
string
added in 1.7.0
Configures the SAM Account Name (sAMAccountName) for the account.
This is allowed to a maximum of 20 characters due to pre-Windows 2000 restrictions.
Default to the <username> specified in upn or name if not set.
spn
list / elements=string
added in 1.10.0
Specifies the service principal name(s) for the account. This parameter sets the ServicePrincipalNames property of the account. The LDAP display name (ldapDisplayName) for this property is servicePrincipalName.

aliases: spns
spn_action
string
added in 1.10.0
    Choices:
  • add
  • remove
  • replace ←
If add, the SPNs are added to the user.
If remove, the SPNs are removed from the user.
If replace, the defined set of SPN's overwrite the current set of SPNs.
state
string
    Choices:
  • absent
  • present ←
  • query
When present, creates or updates the user account.
When absent, removes the user account if it exists.
When query, retrieves the user account details without making any changes.
state_province
string
Configures the user's state or province.
street
string
Configures the user's street address.
surname
string
Configures the user's last name (surname).

aliases: lastname
update_password
string
    Choices:
  • always ←
  • on_create
  • when_changed
always will always update passwords.
on_create will only set the password for newly created users.
when_changed will only set the password when changed.
upn
string
Configures the User Principal Name (UPN) for the account.
This is not required, but is best practice to configure for modern versions of Active Directory.
The format is <username>@<domain>.
user_cannot_change_password
boolean
    Choices:
  • no
  • yes
yes will prevent the user from changing their password.
no will allow the user to change their password.

Note

  • Works with Windows 2012R2 and newer.
  • If running on a server that is not a Domain Controller, credential delegation through CredSSP or Kerberos with delegation must be used or the domain_username, domain_password must be set.
  • Note that some individuals have confirmed successful operation on Windows 2008R2 servers with AD and AD Web Services enabled, but this has not received the same degree of testing as Windows 2012R2.
.. seealso::

   :ref:`ansible.windows.win_domain_module`
      The official documentation on the **ansible.windows.win_domain** module.
   :ref:`ansible.windows.win_domain_controller_module`
      The official documentation on the **ansible.windows.win_domain_controller** module.
   :ref:`community.windows.win_domain_computer_module`
      The official documentation on the **community.windows.win_domain_computer** module.
   :ref:`community.windows.win_domain_group_module`
      The official documentation on the **community.windows.win_domain_group** module.
   :ref:`ansible.windows.win_domain_membership_module`
      The official documentation on the **ansible.windows.win_domain_membership** module.
   :ref:`ansible.windows.win_user_module`
      The official documentation on the **ansible.windows.win_user** module.
   :ref:`community.windows.win_user_profile_module`
      The official documentation on the **community.windows.win_user_profile** module.


- name: Ensure user bob is present with address information
  community.windows.win_domain_user:
    name: bob
    firstname: Bob
    surname: Smith
    company: BobCo
    password: B0bP4ssw0rd
    state: present
    groups:
      - Domain Admins
    street: 123 4th St.
    city: Sometown
    state_province: IN
    postal_code: 12345
    country: US
    attributes:
      telephoneNumber: 555-123456

- name: Ensure user bob is created and use custom credentials to create the user
  community.windows.win_domain_user:
    name: bob
    firstname: Bob
    surname: Smith
    password: B0bP4ssw0rd
    state: present
    domain_username: DOMAIN\admin-account
    domain_password: SomePas2w0rd
    domain_server: [email protected]

- name: Ensure user bob is present in OU ou=test,dc=domain,dc=local
  community.windows.win_domain_user:
    name: bob
    password: B0bP4ssw0rd
    state: present
    path: ou=test,dc=domain,dc=local
    groups:
      - Domain Admins

- name: Ensure user bob is absent
  community.windows.win_domain_user:
    name: bob
    state: absent

- name: Ensure user has spn's defined
  community.windows.win_domain_user:
    name: liz.kenyon
    spn:
      - MSSQLSvc/us99db-svr95:1433
      - MSSQLSvc/us99db-svr95.vmware.com:1433

- name: Ensure user has spn added
  community.windows.win_domain_user:
    name: liz.kenyon
    spn_action: add
    spn:
      - MSSQLSvc/us99db-svr95:2433

- name: Ensure user is created with delegates and spn's defined
  community.windows.win_domain_user:
    name: shmemmmy
    password: The3rubberducki33!
    state: present
    groups:
      - Domain Admins
      - Enterprise Admins
    delegates:
      - CN=shenetworks,CN=Users,DC=ansible,DC=test
      - CN=mk.ai,CN=Users,DC=ansible,DC=test
      - CN=jessiedotjs,CN=Users,DC=ansible,DC=test
    spn:
      - MSSQLSvc/us99db-svr95:2433

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
account_locked
boolean
always
true if the account is locked

changed
boolean
always
true if the account changed during execution

city
string
always
The user city

Sample:
Indianapolis
company
string
always
The user company

Sample:
RedHat
country
string
always
The user country

Sample:
US
created
boolean
always
Whether a user was created

Sample:
True
delegates
list / elements=string
added in 1.10.0
always
Principals allowed to delegate

Sample:
['CN=svc.tech.unicorn,CN=Users,DC=ansible,DC=test', 'CN=geoff,CN=Users,DC=ansible,DC=test']
description
string
always
A description of the account

Sample:
Server Administrator
distinguished_name
string
always
DN of the user account

Sample:
CN=nick,OU=test,DC=domain,DC=local
email
string
always
The user email address

Sample:
enabled
string
always
true if the account is enabled and false if disabled

Sample:
True
firstname
string
always
The user first name

Sample:
Nick
groups
list
always
AD Groups to which the account belongs

Sample:
['Domain Admins', 'Domain Users']
msg
string
always
Summary message of whether the user is present or absent

Sample:
User nick is present
name
string
always
The username on the account

Sample:
nick
password_expired
boolean
always
true if the account password has expired

password_updated
boolean
always
true if the password changed during this execution

Sample:
True
postal_code
string
always
The user postal code

Sample:
46033
sam_account_name
string
added in 1.7.0
always
The SAM Account Name of the account

Sample:
nick
sid
string
always
The SID of the account

Sample:
S-1-5-21-2752426336-228313920-2202711348-1175
spn
list
added in 1.10.0
always
The service principal names

Sample:
['HTTPSvc/ws1intel-svc1', 'HTTPSvc/ws1intel-svc1.vmware.com']
state
string
always
The state of the user account

Sample:
present
state_province
string
always
The user state or province

Sample:
IN
street
string
always
The user street address

Sample:
123 4th St.
surname
string
always
The user last name

Sample:
Doe
upn
string
always
The User Principal Name of the account

Sample:
user_cannot_change_password
string
always
true if the user is not allowed to change password



Authors

  • Nick Chandler (@nwchandler)
  • Joe Zollo (@zollo)