|
|
7ddab3 |
From cbe33b3e6d0d3415e4642d71942380d1793311f1 Mon Sep 17 00:00:00 2001
|
|
|
7ddab3 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
7ddab3 |
Date: Mon, 11 Jun 2018 09:44:49 +0200
|
|
|
7ddab3 |
Subject: [PATCH 20/23] join: add all attributes while creating computer object
|
|
|
7ddab3 |
|
|
|
7ddab3 |
It is possible to create special accounts which can only join a computer
|
|
|
7ddab3 |
to a domain but is not allowed to do any further operations which the
|
|
|
7ddab3 |
computer object. As a result if such an account is used during the join
|
|
|
7ddab3 |
only the ldapadd operation is permitted but not any later ldapmodify
|
|
|
7ddab3 |
operation. To create the computer object correctly in this case all
|
|
|
7ddab3 |
attributes must be added while the object is created and not later.
|
|
|
7ddab3 |
|
|
|
7ddab3 |
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1542354
|
|
|
7ddab3 |
---
|
|
|
7ddab3 |
library/adenroll.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
|
|
|
7ddab3 |
1 file changed, 47 insertions(+), 5 deletions(-)
|
|
|
7ddab3 |
|
|
|
7ddab3 |
diff --git a/library/adenroll.c b/library/adenroll.c
|
|
|
7ddab3 |
index 75ac1e4..b508caf 100644
|
|
|
7ddab3 |
--- a/library/adenroll.c
|
|
|
7ddab3 |
+++ b/library/adenroll.c
|
|
|
7ddab3 |
@@ -573,7 +573,7 @@ calculate_enctypes (adcli_enroll *enroll, char **enctype)
|
|
|
7ddab3 |
is_2008_or_later = adcli_conn_server_has_capability (enroll->conn, ADCLI_CAP_V60_OID);
|
|
|
7ddab3 |
|
|
|
7ddab3 |
/* In 2008 or later, use the msDS-supportedEncryptionTypes attribute */
|
|
|
7ddab3 |
- if (is_2008_or_later) {
|
|
|
7ddab3 |
+ if (is_2008_or_later && enroll->computer_attributes != NULL) {
|
|
|
7ddab3 |
value = _adcli_ldap_parse_value (ldap, enroll->computer_attributes,
|
|
|
7ddab3 |
"msDS-supportedEncryptionTypes");
|
|
|
7ddab3 |
|
|
|
7ddab3 |
@@ -618,7 +618,6 @@ calculate_enctypes (adcli_enroll *enroll, char **enctype)
|
|
|
7ddab3 |
return ADCLI_SUCCESS;
|
|
|
7ddab3 |
}
|
|
|
7ddab3 |
|
|
|
7ddab3 |
-
|
|
|
7ddab3 |
static adcli_result
|
|
|
7ddab3 |
create_computer_account (adcli_enroll *enroll,
|
|
|
7ddab3 |
LDAP *ldap)
|
|
|
7ddab3 |
@@ -628,22 +627,65 @@ create_computer_account (adcli_enroll *enroll,
|
|
|
7ddab3 |
char *vals_sAMAccountName[] = { enroll->computer_sam, NULL };
|
|
|
7ddab3 |
LDAPMod sAMAccountName = { LDAP_MOD_ADD, "sAMAccountName", { vals_sAMAccountName, } };
|
|
|
7ddab3 |
char *vals_userAccountControl[] = { "69632", NULL }; /* WORKSTATION_TRUST_ACCOUNT | DONT_EXPIRE_PASSWD */
|
|
|
7ddab3 |
- LDAPMod userAccountControl = { LDAP_MOD_REPLACE, "userAccountControl", { vals_userAccountControl, } };
|
|
|
7ddab3 |
+ LDAPMod userAccountControl = { LDAP_MOD_ADD, "userAccountControl", { vals_userAccountControl, } };
|
|
|
7ddab3 |
+ char *vals_supportedEncryptionTypes[] = { NULL, NULL };
|
|
|
7ddab3 |
+ LDAPMod encTypes = { LDAP_MOD_ADD, "msDS-supportedEncryptionTypes", { vals_supportedEncryptionTypes, } };
|
|
|
7ddab3 |
+ char *vals_dNSHostName[] = { enroll->host_fqdn, NULL };
|
|
|
7ddab3 |
+ LDAPMod dNSHostName = { LDAP_MOD_ADD, "dNSHostName", { vals_dNSHostName, } };
|
|
|
7ddab3 |
+ char *vals_operatingSystem[] = { enroll->os_name, NULL };
|
|
|
7ddab3 |
+ LDAPMod operatingSystem = { LDAP_MOD_ADD, "operatingSystem", { vals_operatingSystem, } };
|
|
|
7ddab3 |
+ char *vals_operatingSystemVersion[] = { enroll->os_version, NULL };
|
|
|
7ddab3 |
+ LDAPMod operatingSystemVersion = { LDAP_MOD_ADD, "operatingSystemVersion", { vals_operatingSystemVersion, } };
|
|
|
7ddab3 |
+ char *vals_operatingSystemServicePack[] = { enroll->os_service_pack, NULL };
|
|
|
7ddab3 |
+ LDAPMod operatingSystemServicePack = { LDAP_MOD_ADD, "operatingSystemServicePack", { vals_operatingSystemServicePack, } };
|
|
|
7ddab3 |
+ char *vals_userPrincipalName[] = { enroll->user_principal, NULL };
|
|
|
7ddab3 |
+ LDAPMod userPrincipalName = { LDAP_MOD_ADD, "userPrincipalName", { vals_userPrincipalName, }, };
|
|
|
7ddab3 |
+ LDAPMod servicePrincipalName = { LDAP_MOD_ADD, "servicePrincipalName", { enroll->service_principals, } };
|
|
|
7ddab3 |
+
|
|
|
7ddab3 |
+ char *val = NULL;
|
|
|
7ddab3 |
|
|
|
7ddab3 |
int ret;
|
|
|
7ddab3 |
+ size_t c;
|
|
|
7ddab3 |
+ size_t m;
|
|
|
7ddab3 |
|
|
|
7ddab3 |
- LDAPMod *mods[] = {
|
|
|
7ddab3 |
+ LDAPMod *all_mods[] = {
|
|
|
7ddab3 |
&objectClass,
|
|
|
7ddab3 |
&sAMAccountName,
|
|
|
7ddab3 |
&userAccountControl,
|
|
|
7ddab3 |
- NULL,
|
|
|
7ddab3 |
+ &encTypes,
|
|
|
7ddab3 |
+ &dNSHostName,
|
|
|
7ddab3 |
+ &operatingSystem,
|
|
|
7ddab3 |
+ &operatingSystemVersion,
|
|
|
7ddab3 |
+ &operatingSystemServicePack,
|
|
|
7ddab3 |
+ &userPrincipalName,
|
|
|
7ddab3 |
+ &servicePrincipalName,
|
|
|
7ddab3 |
+ NULL
|
|
|
7ddab3 |
};
|
|
|
7ddab3 |
|
|
|
7ddab3 |
+ size_t mods_count = sizeof (all_mods) / sizeof (LDAPMod *);
|
|
|
7ddab3 |
+ LDAPMod *mods[mods_count];
|
|
|
7ddab3 |
+
|
|
|
7ddab3 |
if (adcli_enroll_get_trusted_for_delegation (enroll)) {
|
|
|
7ddab3 |
vals_userAccountControl[0] = "593920"; /* WORKSTATION_TRUST_ACCOUNT | DONT_EXPIRE_PASSWD | TRUSTED_FOR_DELEGATION */
|
|
|
7ddab3 |
}
|
|
|
7ddab3 |
|
|
|
7ddab3 |
+ ret = calculate_enctypes (enroll, &val;;
|
|
|
7ddab3 |
+ if (ret != ADCLI_SUCCESS) {
|
|
|
7ddab3 |
+ return ret;
|
|
|
7ddab3 |
+ }
|
|
|
7ddab3 |
+ vals_supportedEncryptionTypes[0] = val;
|
|
|
7ddab3 |
+
|
|
|
7ddab3 |
+ m = 0;
|
|
|
7ddab3 |
+ for (c = 0; c < mods_count - 1; c++) {
|
|
|
7ddab3 |
+ /* Skip empty LDAP sttributes */
|
|
|
7ddab3 |
+ if (all_mods[c]->mod_vals.modv_strvals[0] != NULL) {
|
|
|
7ddab3 |
+ mods[m++] = all_mods[c];
|
|
|
7ddab3 |
+ }
|
|
|
7ddab3 |
+ }
|
|
|
7ddab3 |
+ mods[m] = NULL;
|
|
|
7ddab3 |
+
|
|
|
7ddab3 |
ret = ldap_add_ext_s (ldap, enroll->computer_dn, mods, NULL, NULL);
|
|
|
7ddab3 |
+ free (val);
|
|
|
7ddab3 |
|
|
|
7ddab3 |
/*
|
|
|
7ddab3 |
* Hand to head. This is really dumb... AD returns
|
|
|
7ddab3 |
--
|
|
|
7ddab3 |
2.14.4
|
|
|
7ddab3 |
|