summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-06-22 17:38:19 +1000
committerAndrew Tridgell <tridge@samba.org>2011-06-22 11:16:26 +0200
commit6d1fe054dd93b8d282fcf515fc62f5d5ab72e6a8 (patch)
tree059bc7ba71f38e3e819064daf904622ef5f2cd6c /source4/scripting/python
parentff8cdeecfc28be396dcbdc4af6b7e60ab9de45f1 (diff)
downloadsamba-6d1fe054dd93b8d282fcf515fc62f5d5ab72e6a8.tar.gz
samba-6d1fe054dd93b8d282fcf515fc62f5d5ab72e6a8.tar.bz2
samba-6d1fe054dd93b8d282fcf515fc62f5d5ab72e6a8.zip
samba-tool: allow for running dbcheck against a remove ldap server
this is useful for running it against a Windows server
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/netcmd/dbcheck.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py
index d7a492836e..93fe3f6c37 100644
--- a/source4/scripting/python/samba/netcmd/dbcheck.py
+++ b/source4/scripting/python/samba/netcmd/dbcheck.py
@@ -79,15 +79,22 @@ class cmd_dbcheck(Command):
help="cross naming context boundaries"),
Option("-v", "--verbose", dest="verbose", action="store_true", default=False,
help="Print more details of checking"),
+ Option("-H", help="LDB URL for database or target server (defaults to local SAM database)", type=str),
]
- def run(self, DN=None, verbose=False, fix=False, yes=False, cross_ncs=False,
+ def run(self, H=None, DN=None, verbose=False, fix=False, yes=False, cross_ncs=False,
scope="SUB", credopts=None, sambaopts=None, versionopts=None):
self.lp = sambaopts.get_loadparm()
self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
- self.samdb = SamDB(session_info=system_session(), url=None,
+ self.samdb = SamDB(session_info=system_session(), url=H,
credentials=self.creds, lp=self.lp)
+ if H is None:
+ self.local_samdb = self.samdb
+ else:
+ self.local_samdb = SamDB(session_info=system_session(), url=None,
+ credentials=self.creds, lp=self.lp)
+
self.verbose = verbose
self.fix = fix
self.yes = yes
@@ -99,6 +106,8 @@ class cmd_dbcheck(Command):
self.search_scope = scope_map[scope]
controls = []
+ if H is not None:
+ controls.append('paged_results:1:1000')
if cross_ncs:
controls.append("search_options:1:2")
@@ -160,7 +169,7 @@ class cmd_dbcheck(Command):
print("ERROR: Normalisation error for attribute %s in %s" % (attrname, dn))
mod_list = []
for val in values:
- normalised = self.samdb.dsdb_normalise_attributes(self.samdb, attrname, [val])
+ normalised = self.samdb.dsdb_normalise_attributes(self.local_samdb, attrname, [val])
if len(normalised) != 1:
print("Unable to normalise value '%s'" % val)
mod_list.append((val, ''))
@@ -333,7 +342,7 @@ class cmd_dbcheck(Command):
# get the syntax oid for the attribute, so we can can have
# special handling for some specific attribute types
- syntax_oid = self.samdb.get_syntax_oid_from_lDAPDisplayName(attrname)
+ syntax_oid = self.local_samdb.get_syntax_oid_from_lDAPDisplayName(attrname)
if syntax_oid in [ dsdb.DSDB_SYNTAX_BINARY_DN, dsdb.DSDB_SYNTAX_OR_NAME,
dsdb.DSDB_SYNTAX_STRING_DN, ldb.LDB_SYNTAX_DN ]:
@@ -342,7 +351,7 @@ class cmd_dbcheck(Command):
# check for incorrectly normalised attributes
for val in obj[attrname]:
- normalised = self.samdb.dsdb_normalise_attributes(self.samdb, attrname, [val])
+ normalised = self.samdb.dsdb_normalise_attributes(self.local_samdb, attrname, [val])
if len(normalised) != 1 or normalised[0] != val:
self.err_normalise_mismatch(dn, attrname, obj[attrname])
error_count += 1