From 813557629f33bdd672a27430d2f073888a0127e5 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 20 Apr 2012 09:39:53 +1000 Subject: s4-upgradedns: Update serverdn with only the attributes that have changed This fixes the issue of ldb 'Operations Error' when trying to modify hasPartialReplicaNCs attribute. Autobuild-User: Amitay Isaacs Autobuild-Date: Tue May 1 05:28:04 CEST 2012 on sn-devel-104 --- source4/scripting/bin/samba_upgradedns | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/samba_upgradedns b/source4/scripting/bin/samba_upgradedns index 5a335a91f4..bd6a8b9371 100755 --- a/source4/scripting/bin/samba_upgradedns +++ b/source4/scripting/bin/samba_upgradedns @@ -390,24 +390,34 @@ if __name__ == '__main__': for nc in ncs: partial_nclist.append(nc) - modified = False + modified_master = False + modified_partial = False for nc in dns_nclist: if nc not in master_nclist: master_nclist.append(nc) - modified = True + modified_master = True if nc in partial_nclist: partial_nclist.remove(nc) - modified = True + modified_partial = True - if modified: + if modified_master or modified_partial: logger.debug("Updating msDS-hasMasterNCs and hasPartialReplicaNCs attributes") - msg["msDS-hasMasterNCs"] = ldb.MessageElement(master_nclist, - ldb.FLAG_MOD_REPLACE, - "msDS-hasMasterNCs") - msg["hasPartialReplicaNCs"] = ldb.MessageElement(partial_nclist, - ldb.FLAG_MOD_REPLACE, - "hasPartialReplicaNCs") - ldbs.sam.modify(msg) + m = ldb.Message() + m.dn = msg.dn + if modified_master: + m["msDS-hasMasterNCs"] = ldb.MessageElement(master_nclist, + ldb.FLAG_MOD_REPLACE, + "msDS-hasMasterNCs") + if modified_partial: + if partial_nclist: + m["hasPartialReplicaNCs"] = ldb.MessageElement(partial_nclist, + ldb.FLAG_MOD_REPLACE, + "hasPartialReplicaNCs") + else: + m["hasPartialReplicaNCs"] = ldb.MessageElement(ncs, + ldb.FLAG_MOD_DELETE, + "hasPartialReplicaNCs") + ldbs.sam.modify(m) except Exception: raise -- cgit