From f58afbcdd9ae3551060be1f6c3b3c98200827e28 Mon Sep 17 00:00:00 2001 From: Christian Connert Date: Tue, 9 Jul 2019 15:18:55 +0200 Subject: [PATCH] Revert "Updated AD backend for user creation" This reverts commit e90f27bc8d97fbb8cecba939e1a24f3324a78592. --- ldapcherry/backend/backendAD.py | 31 +------------------------------ ldapcherry/version.py | 2 +- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/ldapcherry/backend/backendAD.py b/ldapcherry/backend/backendAD.py index 7fb5c64..bb84bf3 100644 --- a/ldapcherry/backend/backendAD.py +++ b/ldapcherry/backend/backendAD.py @@ -200,12 +200,6 @@ class Backend(ldapcherry.backend.backendLdap.Backend): else: dn = self._byte_p2(name) - ldap_client.modify_s( - dn, - [(ldap.MOD_REPLACE, 'unicodePwd', [password_value])] - ) - return - attrs = {} attrs['unicodePwd'] = self._modlist(self._byte_p2(password_value)) @@ -223,31 +217,8 @@ class Backend(ldapcherry.backend.backendLdap.Backend): def add_user(self, attrs): password = attrs['unicodePwd'] del(attrs['unicodePwd']) - attrs['userPrincipalName'] = '%(name)s@%(domain)s' % { - 'name': attrs['sAMAccountName'], 'domain': self.domain - } super(Backend, self).add_user(attrs) - - ldap_client = self._bind() - - dn = self._byte_p2('CN=%(cn)s,%(user_dn)s' % { - 'cn': attrs['cn'], 'user_dn': self.userdn - }) - - # Set password - encoded_password = '"{}"'.format(password).encode('utf-16-le') - ldap_client.modify_s( - dn, - [(ldap.MOD_REPLACE, 'unicodePwd', [encoded_password])] - ) - - # Enable user account - ldap_client.modify_s( - dn, - [(ldap.MOD_REPLACE, 'UserAccountControl', [b'512'])] - ) - - ldap_client.unbind_s() + self._set_password(attrs['cn'], password) def set_attrs(self, username, attrs): if 'unicodePwd' in attrs: diff --git a/ldapcherry/version.py b/ldapcherry/version.py index 5a89ad8..45fdd7b 100644 --- a/ldapcherry/version.py +++ b/ldapcherry/version.py @@ -5,4 +5,4 @@ # ldapCherry # Copyright (c) 2014 Carpentier Pierre-Francois -version = '1.1.3' +version = '1.1.2'