mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
KCC: default to not loading new samdb when we already have one
This should make things simpler in the --import-ldif case. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
76f195a279
commit
acd77283cc
@ -2348,13 +2348,21 @@ class KCC(object):
|
||||
for dsa in site.dsa_table.values()])
|
||||
return dsas
|
||||
|
||||
def load_samdb(self, dburl, lp, creds):
|
||||
def load_samdb(self, dburl, lp, creds, force=False):
|
||||
"""Load the database using an url, loadparm, and credentials
|
||||
|
||||
If force is False, the samdb won't be reloaded if it already
|
||||
exists.
|
||||
|
||||
:param dburl: a database url.
|
||||
:param lp: a loadparm object.
|
||||
:param creds: a Credentials object.
|
||||
:param force: a boolean indicating whether to overwrite.
|
||||
|
||||
"""
|
||||
if self.samdb is not None and not force:
|
||||
return
|
||||
|
||||
self.samdb = SamDB(url=dburl,
|
||||
session_info=system_session(),
|
||||
credentials=creds, lp=lp)
|
||||
@ -2411,11 +2419,8 @@ class KCC(object):
|
||||
determine link availability (boolean, default False)
|
||||
:return: 1 on error, 0 otherwise
|
||||
"""
|
||||
# We may already have a samdb setup if we are
|
||||
# currently importing an ldif for a test run
|
||||
if self.samdb is None:
|
||||
try:
|
||||
self.load_samdb(dburl, lp, creds)
|
||||
self.load_samdb(dburl, lp, creds, force=False)
|
||||
except ldb.LdbError, (num, msg):
|
||||
logger.error("Unable to open sam database %s : %s" %
|
||||
(dburl, msg))
|
||||
|
@ -301,7 +301,7 @@ if opts.importldif:
|
||||
sys.exit(rc)
|
||||
|
||||
if opts.list_valid_dsas:
|
||||
kcc.load_samdb(opts.dburl, lp, creds)
|
||||
kcc.load_samdb(opts.dburl, lp, creds, force=False)
|
||||
print '\n'.join(kcc.list_dsas())
|
||||
sys.exit()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user