summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2011-09-06 16:15:04 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-09-07 12:16:40 +0200
commit47f7e3c525a79586008f14ad3cb2cb3311917524 (patch)
tree91d892be2bb6a3e4bd7e62d07d33802061a25e6c /source4/scripting
parent2fc233b78f35e4bc5062869d77985567d61d0f8a (diff)
downloadsamba-47f7e3c525a79586008f14ad3cb2cb3311917524.tar.gz
samba-47f7e3c525a79586008f14ad3cb2cb3311917524.tar.bz2
samba-47f7e3c525a79586008f14ad3cb2cb3311917524.zip
samba-tool: Add --filter option to ldapcmp to ignore specified attributes
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/python/samba/netcmd/ldapcmp.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/source4/scripting/python/samba/netcmd/ldapcmp.py b/source4/scripting/python/samba/netcmd/ldapcmp.py
index 8abc020687..1db1372eef 100755
--- a/source4/scripting/python/samba/netcmd/ldapcmp.py
+++ b/source4/scripting/python/samba/netcmd/ldapcmp.py
@@ -412,7 +412,7 @@ class Descriptor(object):
return (self_aces == [] and other_aces == [], res)
class LDAPObject(object):
- def __init__(self, connection, dn, summary):
+ def __init__(self, connection, dn, summary, filter_list):
self.con = connection
self.two_domains = self.con.two_domains
self.quiet = self.con.quiet
@@ -434,7 +434,10 @@ class LDAPObject(object):
"repsFrom", "dSCorePropagationData", "msExchServer1HighestUSN",
"replUpToDateVector", "repsTo", "whenChanged", "uSNChanged", "uSNCreated",
# Schema Naming Context
- "prefixMap",]
+ "prefixMap"]
+ if filter_list:
+ self.ignore_attributes += filter_list
+
self.dn_attributes = []
self.domain_attributes = []
self.servername_attributes = []
@@ -662,7 +665,7 @@ class LDAPObject(object):
class LDAPBundel(object):
- def __init__(self, connection, context, dn_list=None):
+ def __init__(self, connection, context, dn_list=None, filter_list=None):
self.con = connection
self.two_domains = self.con.two_domains
self.quiet = self.con.quiet
@@ -674,6 +677,7 @@ class LDAPBundel(object):
self.summary["df_value_attrs"] = []
self.summary["known_ignored_dn"] = []
self.summary["abnormal_ignored_dn"] = []
+ self.filter_list = filter_list
if dn_list:
self.dn_list = dn_list
elif context.upper() in ["DOMAIN", "CONFIGURATION", "SCHEMA"]:
@@ -751,7 +755,8 @@ class LDAPBundel(object):
try:
object1 = LDAPObject(connection=self.con,
dn=self.dn_list[index],
- summary=self.summary)
+ summary=self.summary,
+ filter_list=self.filter_list)
except LdbError, (enum, estr):
if enum == ERR_NO_SUCH_OBJECT:
self.log( "\n!!! Object not found: %s" % self.dn_list[index] )
@@ -760,7 +765,8 @@ class LDAPBundel(object):
try:
object2 = LDAPObject(connection=other.con,
dn=other.dn_list[index],
- summary=other.summary)
+ summary=other.summary,
+ filter_list=self.filter_list)
except LdbError, (enum, estr):
if enum == ERR_NO_SUCH_OBJECT:
self.log( "\n!!! Object not found: %s" % other.dn_list[index] )
@@ -865,12 +871,15 @@ class cmd_ldapcmp(Command):
help="Pass search base that will build DN list for the second DC. Used when --two or when compare two different DNs."),
Option("--scope", dest="scope", default="SUB",
help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"),
+ Option("--filter", dest="filter", default="",
+ help="List of comma separated attributes to ignore in the comparision"),
]
def run(self, URL1, URL2,
context1=None, context2=None, context3=None,
- two=False, quiet=False, verbose=False, descriptor=False, sort_aces=False, view="section",
- base="", base2="", scope="SUB", credopts=None, sambaopts=None, versionopts=None):
+ two=False, quiet=False, verbose=False, descriptor=False, sort_aces=False,
+ view="section", base="", base2="", scope="SUB", filter="",
+ credopts=None, sambaopts=None, versionopts=None):
lp = sambaopts.get_loadparm()
@@ -926,13 +935,15 @@ class cmd_ldapcmp(Command):
verbose=verbose, view=view, base=base2, scope=scope)
assert len(con2.base_dn) > 0
+ filter_list = filter.split(",")
+
status = 0
for context in contexts:
if not quiet:
print "\n* Comparing [%s] context..." % context
- b1 = LDAPBundel(con1, context=context)
- b2 = LDAPBundel(con2, context=context)
+ b1 = LDAPBundel(con1, context=context, filter_list=filter_list)
+ b2 = LDAPBundel(con2, context=context, filter_list=filter_list)
if b1 == b2:
if not quiet: