Changeset 2191

Show
Ignore:
Timestamp:
04/01/05 11:27:31 (20 years ago)
Author:
jerome
Message:

Hopefully final fix for LDAP attributes' names case (in)sensitivity

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2188 r2191  
    4040    import ldap 
    4141    import ldap.modlist 
     42    import ldap.cidict 
    4243except ImportError :     
    4344    import sys 
     
    158159            else :      
    159160                self.tool.logdebug("QUERY : Result : %s" % result) 
     161                result = [ (dn, ldap.cidict.cidict(attrs)) for (dn, attrs) in result ] 
    160162                if self.useldapcache : 
    161163                    for (dn, attributes) in result : 
     
    167169    def doAdd(self, dn, fields) : 
    168170        """Adds an entry in the LDAP directory.""" 
    169         fields = self.normalizeFields(fields) 
     171        fields = self.normalizeFields(ldap.cidict.cidict(fields)) 
    170172        message = "" 
    171173        for tryit in range(3) : 
     
    213215    def doModify(self, dn, fields, ignoreold=1, flushcache=0) : 
    214216        """Modifies an entry in the LDAP directory.""" 
     217        fields = ldap.cidict.cidict(fields) 
    215218        for tryit in range(3) : 
    216219            try : 
     
    246249                modentry = [] 
    247250                for (mop, mtyp, mval) in entry : 
    248                     if mtyp != "createTimestamp" : 
     251                    if mtyp and (mtyp.lower() != "createtimestamp") : 
    249252                        modentry.append((mop, mtyp, mval)) 
    250253                self.tool.logdebug("MODIFY : %s ==> %s ==> %s" % (fields, entry, modentry)) 
     
    278281        """    
    279282        result = [] 
    280         for record in records : 
    281             attrval = record[1].get(attribute, [None])[0] 
     283        for (dn, record) in records : 
     284            attrval = record.get(attribute, [None])[0] 
    282285            if attrval is None : 
    283                 self.tool.printInfo("Object %s has no %s attribute !" % (record[0], attribute), "error") 
     286                self.tool.printInfo("Object %s has no %s attribute !" % (dn, attribute), "error") 
    284287            else :     
    285288                result.append(attrval) 
     
    690693                message = _("Unable to find an existing objectClass %s entry with %s=%s to attach pykotaAccount objectClass") % (where, self.info["userrdn"], user.Name) 
    691694                if action.lower() == "warn" :     
    692                     self.tool.printInfo("%s. A new entry will be created instead." % message, "warn") 
     695                    self.tool.printInfo(_("%s. A new entry will be created instead.") % message, "warn") 
    693696                else : # 'fail' or incorrect setting 
    694697                    raise PyKotaStorageError, "%s. Action aborted. Please check your configuration." % message