Less formal than an actual 'au' object
"""
- def __init__(self, raw_ldap):
+ def __init__(self, raw_cn, raw_atts):
"""
Map core LDAP schema attributes to Evergreen user bits
Easier to replace hard-coded mappings with calls to functions
"""
- self.cname = raw_ldap[0]
- self.ldap_atts = raw_ldap[1]
+ self.cname = raw_cn
+ self.ldap_atts = raw_atts
self.cn = self._simple_map('cn')
self.lang_pref = self._simple_map('preferredLanguage')
results = []
try:
- result_id = con.search(base_dn, search_scope, ldap_filter, attributes)
- while 1:
- result_type, result_data = con.result(result_id, 0)
- if result_data == []:
- break
+ raw_results = con.search_ext_s(base_dn, search_scope, ldap_filter, attributes)
+ for raw_user, raw_atts in raw_results:
+ if raw_atts == []:
+ continue
- user = User(result_data[0])
+ user = User(raw_user, raw_atts)
if ARGS.dump_ldap:
- dump_data(result_data)
+ dump_data(raw_atts)
if ARGS.create_users:
res = create_evergreen_user(auth, user)
if res:
return None
-def retrieve_evergreen_user(auth, user, uid):
+def retrieve_evergreen_user(auth, uid):
"""
Update account for an existing user in Evergreen
if found:
print("Found: %s" % user.usrname)
- egau = retrieve_evergreen_user(auth, user, found)
+ egau = retrieve_evergreen_user(auth, found)
egau.ischanged(True)
egau.active(True)
else:
"""
print()
- print(result_data[0][0])
- for key in result_data[0][1]:
- print(key, result_data[0][1][key])
+ for key in result_data:
+ print(key, result_data[key])
def ldap_query(con, auth):
"""
print >> sys.stderr, exc
sys.exit()
finally:
- con.unbind()
+ con.unbind_ext_s()
return results