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: infektiolo...@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: infektiolo...@uniklinik-ulm.de
objectClass: top
objectClass: person
objectClass: inetOrgPerson
objectClass: mozillaAbPersonAlpha
sn: Veronika

Thunderbird exported the entry like this :

dn: cn="Lehmann, Veronika",mail=infektiolo...@uniklinik-ulm.de
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mozillaAbPersonAlpha
givenName: Lehmann,
sn: Veronika
cn: "Lehmann, Veronika"
mail: infektiolo...@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

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev

Reply via email to