--
John Dennis <jden...@redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
>From bdcbdc28eb4c70042daa5424895f991ff4886a79 Mon Sep 17 00:00:00 2001
From: John Dennis <jden...@redhat.com>
Date: Mon, 16 Apr 2012 18:48:57 -0400
Subject: [PATCH 73] don't append basedn to container if it is included
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

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.
---
 ipalib/plugins/migration.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 89076f6..74cdd6c 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -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):
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to