Changeset 983 for pykota/trunk/pykota/storages/ldap.py
- Timestamp:
- 05/01/03 23:08:44 (22 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldap.py
r979 r983 21 21 # 22 22 # $Log$ 23 # Revision 1.4 2003/05/01 21:08:44 jalet 24 # More work on LDAP 25 # 23 26 # Revision 1.3 2003/04/30 17:40:02 jalet 24 27 # I've got my assigned number for LDAP by the IANA. … … 58 61 self.database = ldap.initialize(host) 59 62 self.database.simple_bind_s(user, passwd) 60 # TODO : dbname will be the base dn63 self.basedn = dbname 61 64 except ldap.SERVER_DOWN : 62 65 raise PyKotaStorageError, "LDAP backend for PyKota seems to be down !" # TODO : translate … … 70 73 self.closed = 1 71 74 72 def doQuery(self, query) : 73 """Does a query.""" 74 pass 75 76 def doQuote(self, field) : 77 """Quotes a field for use as a string in LDAP queries.""" 78 pass 79 80 def doParseResult(self, result) : 81 """Returns the result as a list of Python mappings.""" 82 pass 75 def doSearch(self, key, fields, base="") : 76 """Does an LDAP search query.""" 77 try : 78 # prepends something more restrictive at the beginning of the base dn 79 newbase = ",".join([base, self.basedn]) 80 if newbase.startswith(",") : 81 newbase = newbase[1:] 82 result = self.database.search_s(newbase, ldap.SCOPE_SUBTREE, key, fields) 83 except ldap.NO_SUCH_OBJECT : 84 return 85 else : 86 return result 83 87 84 88 def getMatchingPrinters(self, printerpattern) : … … 100 104 def getUserId(self, username) : 101 105 """Returns a userid given a username.""" 102 pass 106 result = self.doSearch("uid=%s" % username, ["uid"], base="ou=People") 107 if result is not None : 108 (userid, dummy) = result[0] 109 return userid 103 110 104 111 def getGroupId(self, groupname) : 105 112 """Returns a groupid given a grupname.""" 106 pass 113 result = self.doSearch("cn=%s" % groupname, ["cn"], base="ou=Group") 114 if result is not None : 115 (groupid, dummy) = result[0] 116 return groupid 107 117 108 118 def getJobHistoryId(self, jobid, userid, printerid) :