def create_user_source(self, user_list=None, source=None, host=None): for user in user_list: userid = user['id'] password = user['password'] user_name = user['name'] if source == 'ldap': LdapUser(userid, password, host).user_setup() if source == 'builtin': payload = "name=" + user_name + "&roles=&password=" + password InternalUser(userid, payload, host).user_setup()
def search_result_to_users(self, search_result): ad_users=[] for i in search_result: user = LdapUser() user.login = i[0][1]['sAMAccountName'][0] user.first_name = i[0][1]['givenName'][0] if 'givenName' in i[0][1] else '' user.display_name = i[0][1]['displayName'][0] if 'displayName' in i[0][1] else '' user.last_name = i[0][1]['sn'][0] if 'sn' in i[0][1] else '' user.tel = i[0][1]['telephoneNumber'][0] if 'telephoneNumber' in i[0][1] else '' user.department = i[0][1]['department'][0] if 'department' in i[0][1] else '' user.title = i[0][1]['title'][0] if 'title' in i[0][1] else '' user.description = i[0][1]['description'][0] if 'description' in i[0][1] else '' user.mail = i[0][1]['mail'][0] if 'mail' in i[0][1] else '' user.info = i[0][1]['info'][0] if 'info' in i[0][1] else '' ad_users.append(user) return ad_users