From 84546333cae64f9ea0765e3cc36f1f92674a1a08 Mon Sep 17 00:00:00 2001 From: Marian Sigler Date: Fri, 28 Sep 2012 01:32:27 +0200 Subject: create servicePassword ldap object if it does not already exist --- account.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'account.py') diff --git a/account.py b/account.py index 1361669..f25e170 100644 --- a/account.py +++ b/account.py @@ -84,7 +84,7 @@ class AccountService: dn = self._format_dn([('ou', 'services')]) filterstr = '(uid=%s)' % self._escape(uid) - data_service = self.connection.search_s(dn,ldap.SCOPE_SUBTREE,filterstr) + data_service = self.connection.search_s(dn, ldap.SCOPE_SUBTREE, filterstr) services = [] for entry in data_service: @@ -269,6 +269,11 @@ class AccountService: for service, passwords in account.new_password_services.items(): dn = self._format_dn([('uid',account.uid),('cn',service),('ou','services')]) + + if service not in account.services: + attr = [('objectClass', ['top', 'servicePassword']), ('uid', account.uid)] + self.connection.add_s(dn, attr) + old, new = passwords if as_admin: self.connection.passwd_s(dn, None, new) -- cgit v1.2.3-1-g7c22