Problem with names that include ","

Christoph Holtermann c.holtermann at gmx.de
Mon Jun 1 14:42:13 CEST 2009


Hello !

I am working on a filter that makes Thunderbirds LDIF-Output
importable to OpenLDAP. It works quite fine except for names
that include ",". OpenLDAP dislikes the output that is produced
like :

dn: cn=Lehmann\, Veronika,dc=Adressbuch,dc=christoph
cn: Lehmann\, Veronika
givenName: Lehmann,
mail: infektiologie at uniklinik-ulm.de
objectClass: top
objectClass: person
objectClass: inetOrgPerson
objectClass: mozillaAbPersonAlpha
sn: Veronika

I found out that an encoding like "\2C" is accepted, like :

dn: cn=Lehmann\2C Veronika,dc=Adressbuch,dc=christoph
cn: Lehmann, Veronika
givenName: Lehmann,
mail: infektiologie at uniklinik-ulm.de
objectClass: top
objectClass: person
objectClass: inetOrgPerson
objectClass: mozillaAbPersonAlpha
sn: Veronika

Thunderbird exported the entry like this :

dn: cn="Lehmann, Veronika",mail=infektiologie at uniklinik-ulm.de
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mozillaAbPersonAlpha
givenName: Lehmann,
sn: Veronika
cn: "Lehmann, Veronika"
mail: infektiologie at uniklinik-ulm.de
modifytimestamp: 0Z

This is about one of the last things that I have to change by
hand. Maybe someone can help me with this encoding problem.

The code that is about that problem looks like :

basedn='dc=Adressbuch,dc=christoph'

def fix_dn(self, dn):
 try:
  self.head=ldap.dn.explode_dn(dn)[0]
  for i in range(len(dn_warning)):
   if self.head.find(dn_warning[i])>-1:
    print "dn :",self.head, "contains '",dn_warning[i],"' - change
manually !"
  return self.head + ',' + basedn
 except:
  if dn==None:
   print "No dn specified"
   return None

regards,

C. Holtermann




More information about the python-ldap mailing list