From 220941cad39f1d0e5d75c219e62ec11d9ec0799b Mon Sep 17 00:00:00 2001 From: Nico von Geyso Date: Fri, 28 Sep 2012 22:21:53 +0200 Subject: added possibility to delete service passwords --- account.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'account.py') diff --git a/account.py b/account.py index 14af184..2ef2e41 100644 --- a/account.py +++ b/account.py @@ -276,16 +276,23 @@ class AccountService: for service, passwords in account.new_password_services.items(): dn = self._format_dn([('uid',account.uid),('cn',service),('ou','services')]) + old, new = passwords - if service not in account.services: - attr = [('objectClass', ['top', 'servicePassword']), ('uid', account.uid)] - self.connection.add_s(dn, attr) + if new != None: + if service not in account.services: + attr = [('objectClass', ['top', 'servicePassword']), ('uid', account.uid)] + self.connection.add_s(dn, attr) + + if as_admin: + self.connection.passwd_s(dn, None, new) + else: + self.connection.passwd_s(dn, old, new) - old, new = passwords - if as_admin: - self.connection.passwd_s(dn, None, new) else: - self.connection.passwd_s(dn, old, new) + s = service.lower() + if s in account.services: + self.connection.delete_s(dn) + account.services.remove(s) account.new_password_services = {} @@ -321,6 +328,9 @@ class Account: return "" % self.uid + def reset_password(self, service): + self.new_password_services[service] = (None, None) + def change_password(self, new_password, old_password='', service=None): """ Changes a password for a given service. You have to use the -- cgit v1.2.3-1-g7c22