summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2018-10-29 17:28:56 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-11-21 07:46:19 +0100
commitbbd082e7929010545deb5ce59e370ebe934aa23e (patch)
treef5f6fca6e2ce10b7a89bd31dc47d5ac8574e2103 /python
parent047138708965d61c122dce64d57a42419e21e501 (diff)
downloadsamba-bbd082e7929010545deb5ce59e370ebe934aa23e.tar.gz
netcmd/ldapcmp: avoid modifying data while looping on dict
Just define another dict for return value, seems no need to modify original dict. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/ldapcmp.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py
index 338dc049fd2..69aab8b779f 100644
--- a/python/samba/netcmd/ldapcmp.py
+++ b/python/samba/netcmd/ldapcmp.py
@@ -208,13 +208,15 @@ class LDAPBase(object):
res = dict(res[0])
# 'Dn' element is not iterable and we have it as 'distinguishedName'
del res["dn"]
- for key in list(res.keys()):
- vals = list(res[key])
- del res[key]
+
+ attributes = {}
+ for key, vals in res.items():
name = self.get_attribute_name(key)
- res[name] = self.get_attribute_values(object_dn, key, vals)
+ # sort vals and return a list, help to compare
+ vals = sorted(vals)
+ attributes[name] = self.get_attribute_values(object_dn, key, vals)
- return res
+ return attributes
def get_descriptor_sddl(self, object_dn):
res = self.ldb.search(base=object_dn, scope=SCOPE_BASE, attrs=["nTSecurityDescriptor"])