mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-24 10:14:31 +01:00
Revert "Updated AD backend for user creation"
This reverts commit e90f27bc8d
.
This commit is contained in:
parent
e196098c6c
commit
f58afbcdd9
@ -200,12 +200,6 @@ class Backend(ldapcherry.backend.backendLdap.Backend):
|
|||||||
else:
|
else:
|
||||||
dn = self._byte_p2(name)
|
dn = self._byte_p2(name)
|
||||||
|
|
||||||
ldap_client.modify_s(
|
|
||||||
dn,
|
|
||||||
[(ldap.MOD_REPLACE, 'unicodePwd', [password_value])]
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
attrs = {}
|
attrs = {}
|
||||||
|
|
||||||
attrs['unicodePwd'] = self._modlist(self._byte_p2(password_value))
|
attrs['unicodePwd'] = self._modlist(self._byte_p2(password_value))
|
||||||
@ -223,31 +217,8 @@ class Backend(ldapcherry.backend.backendLdap.Backend):
|
|||||||
def add_user(self, attrs):
|
def add_user(self, attrs):
|
||||||
password = attrs['unicodePwd']
|
password = attrs['unicodePwd']
|
||||||
del(attrs['unicodePwd'])
|
del(attrs['unicodePwd'])
|
||||||
attrs['userPrincipalName'] = '%(name)s@%(domain)s' % {
|
|
||||||
'name': attrs['sAMAccountName'], 'domain': self.domain
|
|
||||||
}
|
|
||||||
super(Backend, self).add_user(attrs)
|
super(Backend, self).add_user(attrs)
|
||||||
|
self._set_password(attrs['cn'], password)
|
||||||
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()
|
|
||||||
|
|
||||||
def set_attrs(self, username, attrs):
|
def set_attrs(self, username, attrs):
|
||||||
if 'unicodePwd' in attrs:
|
if 'unicodePwd' in attrs:
|
||||||
|
@ -5,4 +5,4 @@
|
|||||||
# ldapCherry
|
# ldapCherry
|
||||||
# Copyright (c) 2014 Carpentier Pierre-Francois
|
# Copyright (c) 2014 Carpentier Pierre-Francois
|
||||||
|
|
||||||
version = '1.1.3'
|
version = '1.1.2'
|
||||||
|
Loading…
Reference in New Issue
Block a user