diff options
-rw-r--r-- | account.py | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -108,7 +108,7 @@ class AccountService: dn = 'uid=%s,ou=users,%s' % (account.uid, self.base_dn) attr = [ - ('objectClass', ['top','inetOrgPerson']), ('uid',account.uid), + ('objectClass', ['top','inetOrgPerson']), ('uid', account.uid), ('sn', ' '), ('cn', ' '), ('mail', account.mail), ('userPassword', account.password) ] @@ -139,20 +139,20 @@ class AccountService: self._unbind() - def delete(self, account, admin_user = None, admin_pass = None): + def delete(self, account, password=None, as_admin=False): """ Deletes an account permanently. """ + if isinstance(account, basestring): + raise NotImplementedError() + else: + user = account.dn + password = account.password + if as_admin: self._bind_as_admin() else: - if isinstance(account, basestring): - user = 'uid=%s,ou=users,%s' % (account, self.base_dn) - else: - user = account.dn - - password = account.password self._bind('%s,%s' % (user, self.base_dn), password) dn = ['uid=%s,cn=%s,ou=services,%s' % (account.uid,s,self.base_dn) for s in account.services] @@ -169,7 +169,7 @@ class AccountService: self.connection.simple_bind_s(dn, password) - def _bind_as_admin(): + def _bind_as_admin(self): self._bind('cn=%s,%s' % (self.admin_user, self.base_dn), self.admin_pass) @@ -204,11 +204,11 @@ class Account: For each service a spline user can have a different password. """ def __init__(self, uid, mail, services = [], dn = None, password = None): - self.uid = uid - self.mail = mail + self.uid = uid.encode('utf8') if isinstance(uid, unicode) else uid + self.mail = mail.encode('utf8') if isinstance(mail, unicode) else mail self.services = services self.dn = dn - self.password = password + self.password = password.encode('utf8') if isinstance(password, unicode) else password self.new_password_root = None self.new_password_services = {} |