Christoph Holtermann wrote:
> 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 :

Can you please elaborate on which exact problems you have with OpenLDAP?

> dn: cn=Lehmann\, Veronika,dc=Adressbuch,dc=christoph

This looks like a perfectly valid DN string representation to me.

> cn: Lehmann\, Veronika

This is wrong since the attribute value for cn is supposed to be
'Lehmann, Veronika' not 'Lehmann\\, Veronika' (strings here in Python
string notation with single \ escaped to \\). OpenLDAP is pretty strict
when checking the characteristic attribute used in the RDN of entry.

> I found out that an encoding like "\2C" is accepted, like :
> 
> dn: cn=Lehmann\2C Veronika,dc=Adressbuch,dc=christoph

Yes, that's an alternate style also valid according to RFC 4514.

> 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

Glancing over this I don't understand your code. What is this function
supposed to do?

At least this looks correct to me:

Python 2.6 (r26:66714, Feb  3 2009, 20:52:03)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ldap
>>> ldap.explode_dn('cn=Lehmann\, Veronika,dc=Adressbuch,dc=christoph')
['cn=Lehmann\\, Veronika', 'dc=Adressbuch', 'dc=christoph']
>>>

Ciao, Michael.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev

Reply via email to