allow specifying case insensitive attributes for compare
This commit is contained in:
parent
a57b1b6086
commit
6e0e7a360e
|
@ -54,6 +54,9 @@ Base DN of the source is remapped to another DN in the target directory''')
|
|||
type=or_type(source_uri, argparse.FileType('r')),
|
||||
help='URL of an LDAP directory (ldapi://, ldap:// or ldaps://) or path of '
|
||||
'and LDIF file')
|
||||
parser.add_argument('--case-insensitive-attribute',
|
||||
action='append',
|
||||
help='indicate that the attribute must be compared case insensitively')
|
||||
parser.add_argument('--source-base-dn',
|
||||
required=True,
|
||||
help='base DN of the source')
|
||||
|
@ -127,7 +130,8 @@ Base DN of the source is remapped to another DN in the target directory''')
|
|||
synchronize = Synchronize(source, options.source_base_dn,
|
||||
target_conn, options.target_base_dn,
|
||||
pivot_attributes=options.object_class_pivot,
|
||||
attributes=attributes)
|
||||
attributes=attributes,
|
||||
case_insensitive_attribute=options.case_insensitive_attribute)
|
||||
|
||||
synchronize.build_actions()
|
||||
if options.verbose:
|
||||
|
|
|
@ -122,9 +122,10 @@ class Synchronize(object):
|
|||
|
||||
# actions
|
||||
actions = None
|
||||
case_insensitive_attribute = None
|
||||
|
||||
def __init__(self, source, source_dn, target_conn, target_dn, attributes=None, all_filter=None,
|
||||
pivot_attributes=None, logger=None):
|
||||
pivot_attributes=None, logger=None, case_insensitive_attribute=None):
|
||||
self.source = source
|
||||
self.source_dn = source_dn
|
||||
self.target_conn = target_conn
|
||||
|
@ -133,6 +134,7 @@ class Synchronize(object):
|
|||
self.all_filter = all_filter or self.all_filter
|
||||
self.pivot_attributes = pivot_attributes or self.pivot_attributes
|
||||
self.logger = logger or logging.getLogger(__name__)
|
||||
self.case_insensitive_attribute = map(istr, case_insensitive_attribute or self.case_insensitive_attribute or [])
|
||||
self.errors = []
|
||||
|
||||
def massage_dn(self, old_dn):
|
||||
|
@ -152,6 +154,8 @@ class Synchronize(object):
|
|||
raise Exception('entry has unknown objectclasses %s' % entry['objectclass'])
|
||||
if len(value) != 1:
|
||||
raise Exception('entry pivot attribute %s must have only one value' % attr)
|
||||
if attr in self.case_insensitive_attribute:
|
||||
value = map(istr, value)
|
||||
return objc, attr, value[0]
|
||||
|
||||
def get_target_entries(self, filterstr=None, attributes=[]):
|
||||
|
|
Loading…
Reference in New Issue