diff options
author | Stevan Radaković <stevan.radakovic@linaro.org> | 2013-03-20 17:54:39 +0100 |
---|---|---|
committer | Stevan Radaković <stevan.radakovic@linaro.org> | 2013-03-20 17:54:39 +0100 |
commit | 2453d75627c9489cdb802ae1edb275f627e24843 (patch) | |
tree | e3b2ee7a9afe14185023a70dd29fdfab5fe251d6 | |
parent | e13f1c04da163de99428d7367b4b4ee86b34e70b (diff) |
Implement system user adding.
-rw-r--r-- | scripts/ldap_sync.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/ldap_sync.py b/scripts/ldap_sync.py index 4f7d08f..18692d7 100644 --- a/scripts/ldap_sync.py +++ b/scripts/ldap_sync.py @@ -214,16 +214,14 @@ class LdapClient(): return groups def get_users(self): - """Get all the users in form of dict {username: ssh_key,...}.""" + """Get all the users as list. [username1, username2, ..].""" searchFilter = "(uid=*)" result = self.client.search_s(self.base_dn, ldap.SCOPE_SUBTREE, searchFilter) - users = {} + users = [] for user in result: - # Ignore users who don't have the SSH key. - if 'sshPublicKey' in user[1]: - users[user[1]['uid'][0]] = user[1]['sshPublicKey'][0] + users.append(user[1]['uid'][0]) return users @@ -339,6 +337,11 @@ class LdapSync(): for group in self.get_ldap_groups(): SystemCommand.add_group(group) + def update_system_users(self): + """Add all LDAP groups to system.""" + for user in self.get_ldap_users(): + SystemCommand.add_user(user) + def update_system_memberships(self): """Update system memberships based on the LDAP groups.""" group_users = self.ldap_client.get_group_users(self.get_ldap_groups(), @@ -363,6 +366,7 @@ class LdapSync(): def update_system(self): """Update system groups and memberships.""" sync.update_system_groups() + sync.update_users() sync.update_system_memberships() |