ad_user
manages User objects in an Active Directory tree.
# basic example
variable principal_name { default = "testuser" }
variable samaccountname { default = "testuser" }
resource "ad_user" "u" {
principal_name = var.principal_name
sam_account_name = var.samaccountname
display_name = "Terraform Test User"
custom_attributes = jsonencode({
"carLicense": ["This is", "a multi-value", "attribute"],
"comment": "and this is a single value attribute"
})
}
# all user attributes
variable principal_name2 { default = "testuser2" }
variable samaccountname2 { default = "testuser2" }
variable container { default = "CN=Users,DC=contoso,DC=com" }
resource "ad_user" "u2" {
principal_name = var.principal_name2
sam_account_name = var.samaccountname2
display_name = "Terraform Test User"
container = var.container
initial_password = "Password"
city = "City"
company = "Company"
country = "us"
department = "Department"
description = "Description"
division = "Division"
email_address = "some@email.com"
employee_id = "id"
employee_number = "number"
fax = "Fax"
given_name = "GivenName"
home_directory = "HomeDirectory"
home_drive = "HomeDrive"
home_phone = "HomePhone"
home_page = "HomePage"
initials = "Initia"
mobile_phone = "MobilePhone"
office = "Office"
office_phone = "OfficePhone"
organization = "Organization"
other_name = "OtherName"
po_box = "POBox"
postal_code = "PostalCode"
state = "State"
street_address = "StreetAddress"
surname = "Surname"
title = "Title"
smart_card_logon_required = false
trusted_for_delegation = true
}
display_name
(String) The Display Name of an Active Directory user.principal_name
(String) The Principal Name of an Active Directory user.sam_account_name
(String) The pre-win2k user logon name.cannot_change_password
(Boolean) If set to true, the user will not be allowed to change their password.city
(String) Specifies the user's town or city. This parameter sets the City property of a user object.company
(String) Specifies the user's company. This parameter sets the Company property of a user object.container
(String) A DN of the container object that will be holding the user.country
(String) Specifies the country by setting the country code (refer to ISO 3166)custom_attributes
(String) JSON encoded map that represents key/value pairs for custom attributes. Please note that terraform import
will not import these attributes.department
(String) Specifies the user's department. This parameter sets the Department property of a user object.description
(String) Specifies a description of the object. This parameter sets the value of the Description property for the user object.division
(String) Specifies the user's division. This parameter sets the Division property of a user object.email_address
(String) Specifies the user's e-mail address. This parameter sets the EmailAddress property of a user object.employee_id
(String) Specifies the user's employee ID. This parameter sets the EmployeeID property of a user object.employee_number
(String) Specifies the user's employee number. This parameter sets the EmployeeNumber property of a user object.enabled
(Boolean) If set to false, the user will be disabled.fax
(String) Specifies the user's fax phone number. This parameter sets the Fax property of a user object.given_name
(String) Specifies the user's given name. This parameter sets the GivenName property of a user object.home_directory
(String) Specifies a user's home directory. This parameter sets the HomeDirectory property of a user object.home_drive
(String) Specifies a drive that is associated with the UNC path defined by the HomeDirectory property. The drive letter is specified as home_page
(String) Specifies the URL of the home page of the object. This parameter sets the homePage property of a user object.home_phone
(String) Specifies the user's home telephone number. This parameter sets the HomePhone property of a user object.id
(String) The ID of this resource.initial_password
(String) The user's initial password. This will be set on creation but will not be enforced in subsequent plans.initials
(String) Specifies the initials that represent part of a user's name. Maximum 6 char.mobile_phone
(String) Specifies the user's mobile phone number. This parameter sets the MobilePhone property of a user object.office
(String) Specifies the location of the user's office or place of business. This parameter sets the Office property of a user object.office_phone
(String) Specifies the user's office telephone number. This parameter sets the OfficePhone property of a user object.organization
(String) Specifies the user's organization. This parameter sets the Organization property of a user object.other_name
(String) Specifies a name in addition to a user's given name and surname, such as the user's middle name.password_never_expires
(Boolean) If set to true, the password for this user will not expire.po_box
(String) Specifies the user's post office box number. This parameter sets the POBox property of a user object.postal_code
(String) Specifies the user's postal code or zip code. This parameter sets the PostalCode property of a user object.smart_card_logon_required
(Boolean) If set to true, a smart card is required to logon. This parameter sets the SmartCardLoginRequired property for a user object.state
(String) Specifies the user's or Organizational Unit's state or province. This parameter sets the State property of a user object.street_address
(String) Specifies the user's street address. This parameter sets the StreetAddress property of a user object.surname
(String) Specifies the user's last name or surname. This parameter sets the Surname property of a user object.title
(String) Specifies the user's title. This parameter sets the Title property of a user objecttrusted_for_delegation
(Boolean) If set to true, the user account is trusted for Kerberos delegation. A service that runs under an account that is trusted for Kerberos delegation can assume the identity of a client requesting the service. This parameter sets the TrustedForDelegation property of an account object.dn
(String) The distinguished name of the user object.sid
(String) The SID of the user object.Import is supported using the following syntax:
$ terraform import ad_user 9CB8219C-31FF-4A85-A7A3-9BCBB6A41D02