flit wrote: > > I am struggling with some ldap files. More general you are struggling with multiple attribute values of DN syntax stored in a single field of a CSV file.
> I am using the csv module to work with this files (I exported the ldap > to a csv file). I guess you have MS AD and used MS tools for CSV export. > I have this string on a field > CN=pointhairedpeoplethatsux,OU=Groups,OU=Hatepeople,OU=HR,DC=fabrika,DC=com;CN=pointhairedboss,OU=Groups,OU=Hatepeople,OU=HR,DC=fabrika,DC=com > this string is all the groups one user has membership. It seems they are using ; as a delimiter for multi-valued attributes in a single CSV field. Note that ; is also a special character for LDAPv2-DNs. So a naive parsing will fail under special circumstances. I'd recommend to export your data as LDIF and use the module 'ldif' from python-ldap to extract the entry records. You can use this module separately simply by placing the file ldif.py under site-packages/ if you don't need the rest of python-ldap. > So what I am trying to do. > read this string > and extract only the CNs This is another issue. Note that in general DN parsing is more complex than simply using string.split(). If you are sure that all the attribute values used in your DNs don't have any special chars you could use string.split(). But you should definitely cross-check with RFC 4514 or use a decent DN parser. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list