s4-subdomain: don't delete account DN not created in subdomain join
authorAndrew Tridgell <tridge@samba.org>
Mon, 5 Sep 2011 07:23:48 +0000 (17:23 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 13 Sep 2011 05:38:35 +0000 (15:38 +1000)
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/scripting/python/samba/join.py

index ddc4380a6545acf10317709555bf5776f0b0a51a..e30d699d9286d13ae7c00c5e78f09404c43faf25 100644 (file)
@@ -145,11 +145,14 @@ class dc_join(object):
         try:
             # find the krbtgt link
             print("checking samaccountname")
-            res = ctx.samdb.search(base=ctx.samdb.get_default_basedn(),
-                                   expression='samAccountName=%s' % ldb.binary_encode(ctx.samname),
-                                   attrs=["msDS-krbTgtLink"])
-            if res:
-                ctx.del_noerror(res[0].dn, recursive=True)
+            if ctx.subdomain:
+                res = None
+            else:
+                res = ctx.samdb.search(base=ctx.samdb.get_default_basedn(),
+                                       expression='samAccountName=%s' % ldb.binary_encode(ctx.samname),
+                                       attrs=["msDS-krbTgtLink"])
+                if res:
+                    ctx.del_noerror(res[0].dn, recursive=True)
             if ctx.connection_dn is not None:
                 ctx.del_noerror(ctx.connection_dn)
             if ctx.krbtgt_dn is not None: