All pastes #574947 Raw Edit

Stuff

public python v1 · immutable
·published 2007-06-18 20:08 UTC
rendered paste body
import ldapclass ldapserver:        def __init__(self, url):                self.connection = ldap.initialize("ldap://localhost/")                self.connection.protocol_version = ldap.VERSION3                self.connection.bind_s("", "", ldap.AUTH_SIMPLE);        def query(self, base, query, attributes=None):                result_set = {}                result_id = self.connection.search(base, ldap.SCOPE_SUBTREE, query, attributes)                for result in self.connection.result(result_id)[1]:                        result_set[result[0]] = result[1]                return result_setclass application:        dn = ""        name = ""        packageName = ""        icon = ""        description = ""        binary = ""        def __init__(self, dn):                self.dn = dn                self.ldapserver = ldapserver("ldap://localhost/")                self.data = self.ldapserver.query(self.dn, "objectClass=*")                self.name = self.data[self.dn]['gosaApplicationName']                self.packageName = self.data[self.dn]['gosaApplicationPackage']                self.icon = self.data[self.dn]['gosaApplicationIcon']                self.binary = self.data[self.dn]['gosaApplicationExecute']                self.description = self.data[self.dn]['description']        def write(self, filename=None):                print self.packageNamex = ldapserver("ldap://localhost/")apps = x.query("dc=nodomain", "objectClass=gosaApplication")applist = []for i in apps:        applist.append(application(i))for app in applist:        app.write()