in ad-joining/register-computer/ad/domain.py [0:0]
def add_computer(self, ou, computer_name, upn, project_id, zone, instance_name):
WORKSTATION_TRUST_ACCOUNT = 0x1000
PASSWD_NOTREQD = 0x20
dn = "CN=%s,%s" % (computer_name, ou)
try:
self.__connection.add(
dn,
[ # objectClass
"computer" ,
"organizationalPerson",
"person",
"user",
"top"
],
{
# Mandatory attributes for a computer object.
"objectClass": "computer",
"sAMAccountName": computer_name + "$",
"userPrincipalName": upn,
"userAccountControl": WORKSTATION_TRUST_ACCOUNT | PASSWD_NOTREQD,
ActiveDirectoryConnection.LDAP_ATTRIBUTE_PROJECT_ID: project_id,
ActiveDirectoryConnection.LDAP_ATTRIBUTE_ZONE: zone,
ActiveDirectoryConnection.LDAP_ATTRIBUTE_INSTANCE_NAME: instance_name
})
return dn
except ldap3.core.exceptions.LDAPEntryAlreadyExistsResult as e:
raise AlreadyExistsException(e)