File 0017-join-add-all-attributes-while-creating-computer-obje.patch of Package adcli
xxxxxxxxxx
1
From 07ea3d55f318b7feeef08ee1c160112310828dd2 Mon Sep 17 00:00:00 2001
2
From: Sumit Bose <sbose@redhat.com>
3
Date: Mon, 11 Jun 2018 09:44:49 +0200
4
Subject: [PATCH 17/25] join: add all attributes while creating computer object
5
6
It is possible to create special accounts which can only join a computer
7
to a domain but is not allowed to do any further operations which the
8
computer object. As a result if such an account is used during the join
9
only the ldapadd operation is permitted but not any later ldapmodify
10
operation. To create the computer object correctly in this case all
11
attributes must be added while the object is created and not later.
12
13
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1542354
14
---
15
library/adenroll.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
16
1 file changed, 47 insertions(+), 5 deletions(-)
17
18
diff --git a/library/adenroll.c b/library/adenroll.c
19
index 923a811..deaef0f 100644
20
--- a/library/adenroll.c
21
+++ b/library/adenroll.c
22
23
is_2008_or_later = adcli_conn_server_has_capability (enroll->conn, ADCLI_CAP_V60_OID);
24
25
/* In 2008 or later, use the msDS-supportedEncryptionTypes attribute */
26
- if (is_2008_or_later) {
27
+ if (is_2008_or_later && enroll->computer_attributes != NULL) {
28
value = _adcli_ldap_parse_value (ldap, enroll->computer_attributes,
29
"msDS-supportedEncryptionTypes");
30
31
32
return ADCLI_SUCCESS;
33
}
34
35
-
36
static adcli_result
37
create_computer_account (adcli_enroll *enroll,
38
LDAP *ldap)
39
40
char *vals_sAMAccountName[] = { enroll->computer_sam, NULL };
41
LDAPMod sAMAccountName = { LDAP_MOD_ADD, "sAMAccountName", { vals_sAMAccountName, } };
42
char *vals_userAccountControl[] = { "69632", NULL }; /* WORKSTATION_TRUST_ACCOUNT | DONT_EXPIRE_PASSWD */
43
- LDAPMod userAccountControl = { LDAP_MOD_REPLACE, "userAccountControl", { vals_userAccountControl, } };
44
+ LDAPMod userAccountControl = { LDAP_MOD_ADD, "userAccountControl", { vals_userAccountControl, } };
45
+ char *vals_supportedEncryptionTypes[] = { NULL, NULL };
46
+ LDAPMod encTypes = { LDAP_MOD_ADD, "msDS-supportedEncryptionTypes", { vals_supportedEncryptionTypes, } };
47
+ char *vals_dNSHostName[] = { enroll->host_fqdn, NULL };
48
+ LDAPMod dNSHostName = { LDAP_MOD_ADD, "dNSHostName", { vals_dNSHostName, } };
49
+ char *vals_operatingSystem[] = { enroll->os_name, NULL };
50
+ LDAPMod operatingSystem = { LDAP_MOD_ADD, "operatingSystem", { vals_operatingSystem, } };
51
+ char *vals_operatingSystemVersion[] = { enroll->os_version, NULL };
52
+ LDAPMod operatingSystemVersion = { LDAP_MOD_ADD, "operatingSystemVersion", { vals_operatingSystemVersion, } };
53
+ char *vals_operatingSystemServicePack[] = { enroll->os_service_pack, NULL };
54
+ LDAPMod operatingSystemServicePack = { LDAP_MOD_ADD, "operatingSystemServicePack", { vals_operatingSystemServicePack, } };
55
+ char *vals_userPrincipalName[] = { enroll->user_principal, NULL };
56
+ LDAPMod userPrincipalName = { LDAP_MOD_ADD, "userPrincipalName", { vals_userPrincipalName, }, };
57
+ LDAPMod servicePrincipalName = { LDAP_MOD_ADD, "servicePrincipalName", { enroll->service_principals, } };
58
+
59
+ char *val = NULL;
60
61
int ret;
62
+ size_t c;
63
+ size_t m;
64
65
- LDAPMod *mods[] = {
66
+ LDAPMod *all_mods[] = {
67
&objectClass,
68
&sAMAccountName,
69
&userAccountControl,
70
- NULL,
71
+ &encTypes,
72
+ &dNSHostName,
73
+ &operatingSystem,
74
+ &operatingSystemVersion,
75
+ &operatingSystemServicePack,
76
+ &userPrincipalName,
77
+ &servicePrincipalName,
78
+ NULL
79
};
80
81
+ size_t mods_count = sizeof (all_mods) / sizeof (LDAPMod *);
82
+ LDAPMod *mods[mods_count];
83
+
84
if (adcli_enroll_get_trusted_for_delegation (enroll)) {
85
vals_userAccountControl[0] = "593920"; /* WORKSTATION_TRUST_ACCOUNT | DONT_EXPIRE_PASSWD | TRUSTED_FOR_DELEGATION */
86
}
87
88
+ ret = calculate_enctypes (enroll, &val);
89
+ if (ret != ADCLI_SUCCESS) {
90
+ return ret;
91
+ }
92
+ vals_supportedEncryptionTypes[0] = val;
93
+
94
+ m = 0;
95
+ for (c = 0; c < mods_count - 1; c++) {
96
+ /* Skip empty LDAP sttributes */
97
+ if (all_mods[c]->mod_vals.modv_strvals[0] != NULL) {
98
+ mods[m++] = all_mods[c];
99
+ }
100
+ }
101
+ mods[m] = NULL;
102
+
103
ret = ldap_add_ext_s (ldap, enroll->computer_dn, mods, NULL, NULL);
104
+ free (val);
105
106
/*
107
* Hand to head. This is really dumb... AD returns
108
--
109
2.16.4
110
111