report entry dn when an error occur in ListLDIFParser.add()
This commit is contained in:
parent
5585368307
commit
6fa48fbeb5
|
@ -5,6 +5,10 @@ from ldap.dn import dn2str
|
|||
from ldaptools.utils import idict, str2dn
|
||||
|
||||
|
||||
class AddError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ListLDIFParser(ldif.LDIFParser):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.entries = []
|
||||
|
@ -18,7 +22,10 @@ class ListLDIFParser(ldif.LDIFParser):
|
|||
|
||||
def add(self, conn):
|
||||
for dn, entry in self.entries:
|
||||
conn.add_s(dn, ldap.modlist.addModlist(entry))
|
||||
try:
|
||||
conn.add_s(dn, ldap.modlist.addModlist(entry))
|
||||
except Exception, e:
|
||||
raise AddError('error when adding %s' % dn, e)
|
||||
|
||||
def __iter__(self):
|
||||
for dn, attributes in self.entries:
|
||||
|
|
Loading…
Reference in New Issue