[PATCH 8/8] s4: fix problems

Matthieu Patou mat at matws.net
Thu Nov 26 16:52:25 MST 2009


 * transaction were not always started
 * object where string when expcted to be int or ldb_message
---
 source4/scripting/bin/upgradeprovision |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/source4/scripting/bin/upgradeprovision b/source4/scripting/bin/upgradeprovision
index f8f1924..19bec55 100755
--- a/source4/scripting/bin/upgradeprovision
+++ b/source4/scripting/bin/upgradeprovision
@@ -45,7 +45,8 @@ import ldb
 import samba.getopt as options
 from samba.samdb import SamDB
 from samba import param
-from samba.provision import  ProvisionNames,provision_paths_from_lp,find_setup_dir,FILL_FULL,provision, get_domain_descriptor, get_config_descriptor
+from samba import glue
+from samba.provision import  ProvisionNames,provision_paths_from_lp,find_setup_dir,FILL_FULL,provision, get_domain_descriptor, get_config_descriptor, secretsdb_self_join
 from samba.provisionexceptions import ProvisioningError
 from samba.schema import get_dnsyntax_attributes, get_linked_attributes, Schema, get_schema_descriptor
 from samba.dcerpc import misc, security
@@ -699,15 +700,14 @@ def update_machine_account_password(newpaths,paths,creds,session,names):
 	secrets_ldb.transaction_start()
 	secrets_msg = secrets_ldb.search(expression=("samAccountName=%s$" % names.netbiosname), attrs=["secureChannelType"])
 	sam_ldb = Ldb(paths.samdb, session_info=session, credentials=creds,lp=lp)
-	if secrets_msg[0]["secureChannelType"][0] == SEC_CHAN_BDC:
-		sam_ldb.transaction_start()
+	sam_ldb.transaction_start()
+	if int(secrets_msg[0]["secureChannelType"][0]) == SEC_CHAN_BDC:
 		res = sam_ldb.search(expression=("samAccountName=%s$" % names.netbiosname), attrs=[])
 		assert(len(res) == 1)
 		
 		msg = ldb.Message(res[0].dn)
-		machinepass = msg["userPassword"] = glue.generate_random_str(12)
-		for el in msg:
-			el.set_flags(ldb.FLAG_MOD_REPLACE)
+		machinepass = glue.generate_random_str(12)
+		msg["userPassword"] = ldb.MessageElement("userPassword", ldb.FLAG_MOD_REPLACE, "userPassword")
 		sam_ldb.modify(msg)
 
 		res = sam_ldb.search(expression=("samAccountName=%s$" % names.netbiosname), 
-- 
1.6.3.3


--------------040904030402080707020200
Content-Type: text/x-patch;
 name="0001-s4-provision-Make-setting-the-domain-SID-in-the-self.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-s4-provision-Make-setting-the-domain-SID-in-the-self.pa";
 filename*1="tch"



More information about the samba-technical mailing list