don't append basedn to container if it is included

ticket #2566

When specifying a container to ds-migrate we should not automatically
append the basedn if it is provided by the end-user.

This is easy to detect using DN objects because DN objects have a
endswith() method which can easily and correctly ascertain if a base
already exists.
This commit is contained in:
John Dennis 2012-04-16 18:48:57 -04:00 committed by Rob Crittenden
parent c64bcafa13
commit 72efa64c81

View File

@ -589,13 +589,19 @@ can use their Kerberos accounts.''')
def _get_search_bases(self, options, ds_base_dn, migrate_order):
search_bases = dict()
ds_base_dn = DN(ds_base_dn)
for ldap_obj_name in migrate_order:
container = options.get('%scontainer' % to_cli(ldap_obj_name))
if container:
search_base = str(DN(container, ds_base_dn))
container = DN(container)
# Don't append base dn if user already appended it in the container dn
if container.endswith(ds_base_dn):
search_base = container
else:
search_base = DN(container, ds_base_dn)
else:
search_base = ds_base_dn
search_bases[ldap_obj_name] = search_base
search_bases[ldap_obj_name] = str(search_base)
return search_bases
def migrate(self, ldap, config, ds_ldap, ds_base_dn, options):