[sysadmin-bin] Stop looking for the memberUid field, FreeIPA uses member by default



commit 9ba54bd6fdbfd750c5c8d1f2ffecff865c5d2868
Author: Andrea Veri <averi redhat com>
Date:   Thu Jun 22 14:08:15 2017 +0200

    Stop looking for the memberUid field, FreeIPA uses member by default

 reset-my-password.py |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/reset-my-password.py b/reset-my-password.py
index 7ee2859..5302736 100755
--- a/reset-my-password.py
+++ b/reset-my-password.py
@@ -25,18 +25,22 @@ except ldap.LDAPError, e:
 
 def _parse_members_from_group(group):
 
-    filter = ldap.filter.filter_format('(&(objectClass=posixgroup)(cn=%s))', (group, ))
-    results = l.search_s(LDAP_GROUP_BASE, ldap.SCOPE_SUBTREE, filter, ('memberUid', ))
+   filter = ldap.filter.filter_format('(&(objectClass=posixGroup)(cn=%s))', (group, ))
+    results = l.search_s(LDAP_GROUP_BASE, ldap.SCOPE_SUBTREE, filter, ('member', ))
 
     members = set()
 
     for _, attr in results:
-        members.update(attr['memberUid'])
+        for userid in attr['member']:
+            splitentry = userid.split(',')
+            singleentry = splitentry[0]
+            splitteduid = singleentry.split('=')
+            uid = splitteduid[1]
 
+            members.add(uid)
 
     return members
 
-
 def _get_attributes_from_ldap(userid, attr):
     filter = ldap.filter.filter_format('(uid=%s)', (userid, ))
     results = l.search_s(LDAP_USER_BASE, ldap.SCOPE_SUBTREE, filter, ('uid', attr, ))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]