import ldap import ldap.sasl import ldap.modlist class Matrix: ''' def connection_ldap(self): try: self.connect_ldap=ldap.initialize('ldap://localhost:389',trace_level=0) self.connect_ldap.protocol_version=3 password = "lliurex" self.connect_ldap.bind_s("cn=admin,dc=ma5,dc=lliurex,dc=net",password) return True except Exception as e: print "\n\nError" + str(e) + "\n\n" self.connect_ldap = None return False ''' def get_users(self): objects['SlapdManager'].connection_ldap() #self.connection_ldap() all_results = objects['SlapdManager'].connect_ldap.search_s('dc=ma5,dc=lliurex,dc=net',ldap.SCOPE_SUBTREE) dic_all_results = map(list,all_results) dic_all_results.pop(0) return dic_all_results if __name__ == '__main__': a = Matrix() a.connection_ldap() for x in a.respuesta(): print x