mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
samba python libs: convert 'except X, (tuple)' to 'except X as e'
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Douglas Bagnall
parent
efad273122
commit
91a5941f17
@ -108,7 +108,8 @@ class dbcheck(object):
|
|||||||
attrs=["objectSid"])
|
attrs=["objectSid"])
|
||||||
dnsadmins_sid = ndr_unpack(security.dom_sid, res[0]["objectSid"][0])
|
dnsadmins_sid = ndr_unpack(security.dom_sid, res[0]["objectSid"][0])
|
||||||
self.name_map['DnsAdmins'] = str(dnsadmins_sid)
|
self.name_map['DnsAdmins'] = str(dnsadmins_sid)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e5:
|
||||||
|
(enum, estr) = e5.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
pass
|
pass
|
||||||
@ -198,7 +199,8 @@ class dbcheck(object):
|
|||||||
self.compatibleFeatures = res[0]["compatibleFeatures"]
|
self.compatibleFeatures = res[0]["compatibleFeatures"]
|
||||||
if "requiredFeatures" in res[0]:
|
if "requiredFeatures" in res[0]:
|
||||||
self.requiredFeatures = res[0]["requiredFeatures"]
|
self.requiredFeatures = res[0]["requiredFeatures"]
|
||||||
except ldb.LdbError as (enum, estr):
|
except ldb.LdbError as e6:
|
||||||
|
(enum, estr) = e6.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
pass
|
pass
|
||||||
@ -253,7 +255,8 @@ class dbcheck(object):
|
|||||||
"CN=Deleted Objects\\0ACNF:%s" % str(misc.GUID(guid)))
|
"CN=Deleted Objects\\0ACNF:%s" % str(misc.GUID(guid)))
|
||||||
conflict_dn.add_base(nc)
|
conflict_dn.add_base(nc)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e2:
|
||||||
|
(enum, estr) = e2.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -263,7 +266,8 @@ class dbcheck(object):
|
|||||||
if conflict_dn is not None:
|
if conflict_dn is not None:
|
||||||
try:
|
try:
|
||||||
self.samdb.rename(dn, conflict_dn, ["show_deleted:1", "relax:0", "show_recycled:1"])
|
self.samdb.rename(dn, conflict_dn, ["show_deleted:1", "relax:0", "show_recycled:1"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e1:
|
||||||
|
(enum, estr) = e1.args
|
||||||
self.report("Couldn't move old Deleted Objects placeholder: %s to %s: %s" % (dn, conflict_dn, estr))
|
self.report("Couldn't move old Deleted Objects placeholder: %s to %s: %s" % (dn, conflict_dn, estr))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -596,7 +600,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
try:
|
try:
|
||||||
res = self.samdb.search(base=str(dsdb_dn.dn), scope=ldb.SCOPE_BASE,
|
res = self.samdb.search(base=str(dsdb_dn.dn), scope=ldb.SCOPE_BASE,
|
||||||
attrs=[], controls=controls)
|
attrs=[], controls=controls)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e7:
|
||||||
|
(enum, estr) = e7.args
|
||||||
self.report("unable to find object for DN %s - (%s)" % (dsdb_dn.dn, estr))
|
self.report("unable to find object for DN %s - (%s)" % (dsdb_dn.dn, estr))
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
@ -999,7 +1004,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
try:
|
try:
|
||||||
res = self.samdb.search(base=str(dn), scope=ldb.SCOPE_BASE,
|
res = self.samdb.search(base=str(dn), scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs, controls=controls)
|
attrs=attrs, controls=controls)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e8:
|
||||||
|
(enum, estr) = e8.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -1046,7 +1052,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
controls=["extended_dn:1:1",
|
controls=["extended_dn:1:1",
|
||||||
"search_options:1:2",
|
"search_options:1:2",
|
||||||
"paged_results:1:1000"])
|
"paged_results:1:1000"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e9:
|
||||||
|
(enum, estr) = e9.args
|
||||||
raise
|
raise
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
@ -1198,7 +1205,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
attrs=attrs, controls=["extended_dn:1:1", "show_recycled:1",
|
attrs=attrs, controls=["extended_dn:1:1", "show_recycled:1",
|
||||||
"reveal_internals:0"
|
"reveal_internals:0"
|
||||||
])
|
])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e3:
|
||||||
|
(enum, estr) = e3.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -1924,7 +1932,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
instancetype |= dsdb.INSTANCE_TYPE_IS_NC_HEAD
|
instancetype |= dsdb.INSTANCE_TYPE_IS_NC_HEAD
|
||||||
try:
|
try:
|
||||||
self.samdb.search(base=dn.parent(), scope=ldb.SCOPE_BASE, attrs=[], controls=["show_recycled:1"])
|
self.samdb.search(base=dn.parent(), scope=ldb.SCOPE_BASE, attrs=[], controls=["show_recycled:1"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e4:
|
||||||
|
(enum, estr) = e4.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@ -1995,7 +2004,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
"reveal_internals:0",
|
"reveal_internals:0",
|
||||||
],
|
],
|
||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e10:
|
||||||
|
(enum, estr) = e10.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
if self.in_transaction:
|
if self.in_transaction:
|
||||||
self.report("ERROR: Object %s disappeared during check" % dn)
|
self.report("ERROR: Object %s disappeared during check" % dn)
|
||||||
@ -2303,7 +2313,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
if dn != self.samdb.get_root_basedn() and str(dn.parent()) not in self.dn_set:
|
if dn != self.samdb.get_root_basedn() and str(dn.parent()) not in self.dn_set:
|
||||||
res = self.samdb.search(base=dn.parent(), scope=ldb.SCOPE_BASE,
|
res = self.samdb.search(base=dn.parent(), scope=ldb.SCOPE_BASE,
|
||||||
controls=["show_recycled:1", "show_deleted:1"])
|
controls=["show_recycled:1", "show_deleted:1"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e11:
|
||||||
|
(enum, estr) = e11.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
self.err_missing_parent(obj)
|
self.err_missing_parent(obj)
|
||||||
error_count += 1
|
error_count += 1
|
||||||
@ -2407,7 +2418,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|||||||
try:
|
try:
|
||||||
res = self.samdb.search(base="<SID=%s>" % sid, scope=ldb.SCOPE_BASE,
|
res = self.samdb.search(base="<SID=%s>" % sid, scope=ldb.SCOPE_BASE,
|
||||||
attrs=[])
|
attrs=[])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise
|
raise
|
||||||
res = None
|
res = None
|
||||||
|
@ -92,7 +92,8 @@ class dc_join(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL, attrs=["dn"])
|
ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL, attrs=["dn"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e4:
|
||||||
|
(enum, estr) = e4.args
|
||||||
raise DCJoinException(estr)
|
raise DCJoinException(estr)
|
||||||
|
|
||||||
|
|
||||||
@ -404,7 +405,8 @@ class dc_join(object):
|
|||||||
'''check if a DN exists'''
|
'''check if a DN exists'''
|
||||||
try:
|
try:
|
||||||
res = ctx.samdb.search(base=dn, scope=ldb.SCOPE_BASE, attrs=[])
|
res = ctx.samdb.search(base=dn, scope=ldb.SCOPE_BASE, attrs=[])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e5:
|
||||||
|
(enum, estr) = e5.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
return False
|
return False
|
||||||
raise
|
raise
|
||||||
@ -705,7 +707,8 @@ class dc_join(object):
|
|||||||
ctx.acct_pass,
|
ctx.acct_pass,
|
||||||
force_change_at_next_login=False,
|
force_change_at_next_login=False,
|
||||||
username=ctx.samname)
|
username=ctx.samname)
|
||||||
except ldb.LdbError, (num, _):
|
except ldb.LdbError as e2:
|
||||||
|
(num, _) = e2.args
|
||||||
if num != ldb.ERR_UNWILLING_TO_PERFORM:
|
if num != ldb.ERR_UNWILLING_TO_PERFORM:
|
||||||
pass
|
pass
|
||||||
ctx.net.set_password(account_name=ctx.samname,
|
ctx.net.set_password(account_name=ctx.samname,
|
||||||
@ -754,7 +757,8 @@ class dc_join(object):
|
|||||||
samba.dsdb.UF_ACCOUNTDISABLE)
|
samba.dsdb.UF_ACCOUNTDISABLE)
|
||||||
try:
|
try:
|
||||||
ctx.samdb.add(msg)
|
ctx.samdb.add(msg)
|
||||||
except ldb.LdbError, (num, _):
|
except ldb.LdbError as e:
|
||||||
|
(num, _) = e.args
|
||||||
if num != ldb.ERR_ENTRY_ALREADY_EXISTS:
|
if num != ldb.ERR_ENTRY_ALREADY_EXISTS:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -770,7 +774,8 @@ class dc_join(object):
|
|||||||
ctx.dnspass,
|
ctx.dnspass,
|
||||||
force_change_at_next_login=False,
|
force_change_at_next_login=False,
|
||||||
username=ctx.samname)
|
username=ctx.samname)
|
||||||
except ldb.LdbError, (num, _):
|
except ldb.LdbError as e3:
|
||||||
|
(num, _) = e3.args
|
||||||
if num != ldb.ERR_UNWILLING_TO_PERFORM:
|
if num != ldb.ERR_UNWILLING_TO_PERFORM:
|
||||||
raise
|
raise
|
||||||
ctx.net.set_password(account_name="dns-%s" % ctx.myname,
|
ctx.net.set_password(account_name="dns-%s" % ctx.myname,
|
||||||
@ -965,7 +970,8 @@ class dc_join(object):
|
|||||||
repl.replicate(ctx.rid_manager_dn, source_dsa_invocation_id,
|
repl.replicate(ctx.rid_manager_dn, source_dsa_invocation_id,
|
||||||
destination_dsa_guid,
|
destination_dsa_guid,
|
||||||
exop=drsuapi.DRSUAPI_EXOP_FSMO_RID_ALLOC)
|
exop=drsuapi.DRSUAPI_EXOP_FSMO_RID_ALLOC)
|
||||||
except samba.DsExtendedError, (enum, estr):
|
except samba.DsExtendedError as e1:
|
||||||
|
(enum, estr) = e1.args
|
||||||
if enum == drsuapi.DRSUAPI_EXOP_ERR_FSMO_NOT_OWNER:
|
if enum == drsuapi.DRSUAPI_EXOP_ERR_FSMO_NOT_OWNER:
|
||||||
print "WARNING: Unable to replicate own RID Set, as server %s (the server we joined) is not the RID Master." % ctx.server
|
print "WARNING: Unable to replicate own RID Set, as server %s (the server we joined) is not the RID Master." % ctx.server
|
||||||
print "NOTE: This is normal and expected, Samba will be able to create users after it contacts the RID Master at first startup."
|
print "NOTE: This is normal and expected, Samba will be able to create users after it contacts the RID Master at first startup."
|
||||||
|
@ -152,7 +152,8 @@ class KCC(object):
|
|||||||
self.samdb.get_config_basedn(),
|
self.samdb.get_config_basedn(),
|
||||||
scope=ldb.SCOPE_SUBTREE,
|
scope=ldb.SCOPE_SUBTREE,
|
||||||
expression="(objectClass=interSiteTransport)")
|
expression="(objectClass=interSiteTransport)")
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e2:
|
||||||
|
(enum, estr) = e2.args
|
||||||
raise KCCError("Unable to find inter-site transports - (%s)" %
|
raise KCCError("Unable to find inter-site transports - (%s)" %
|
||||||
estr)
|
estr)
|
||||||
|
|
||||||
@ -186,7 +187,8 @@ class KCC(object):
|
|||||||
self.samdb.get_config_basedn(),
|
self.samdb.get_config_basedn(),
|
||||||
scope=ldb.SCOPE_SUBTREE,
|
scope=ldb.SCOPE_SUBTREE,
|
||||||
expression="(objectClass=siteLink)")
|
expression="(objectClass=siteLink)")
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e3:
|
||||||
|
(enum, estr) = e3.args
|
||||||
raise KCCError("Unable to find inter-site siteLinks - (%s)" % estr)
|
raise KCCError("Unable to find inter-site siteLinks - (%s)" % estr)
|
||||||
|
|
||||||
for msg in res:
|
for msg in res:
|
||||||
@ -249,7 +251,8 @@ class KCC(object):
|
|||||||
self.samdb.get_config_basedn(),
|
self.samdb.get_config_basedn(),
|
||||||
scope=ldb.SCOPE_SUBTREE,
|
scope=ldb.SCOPE_SUBTREE,
|
||||||
expression="(objectClass=site)")
|
expression="(objectClass=site)")
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e4:
|
||||||
|
(enum, estr) = e4.args
|
||||||
raise KCCError("Unable to find sites - (%s)" % estr)
|
raise KCCError("Unable to find sites - (%s)" % estr)
|
||||||
|
|
||||||
for msg in res:
|
for msg in res:
|
||||||
@ -267,7 +270,8 @@ class KCC(object):
|
|||||||
try:
|
try:
|
||||||
res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE,
|
res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE,
|
||||||
attrs=["objectGUID"])
|
attrs=["objectGUID"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e5:
|
||||||
|
(enum, estr) = e5.args
|
||||||
DEBUG_FN("Search for dn '%s' [from %s] failed: %s. "
|
DEBUG_FN("Search for dn '%s' [from %s] failed: %s. "
|
||||||
"This typically happens in --importldif mode due "
|
"This typically happens in --importldif mode due "
|
||||||
"to lack of module support." % (dn, dn_query, estr))
|
"to lack of module support." % (dn, dn_query, estr))
|
||||||
@ -286,7 +290,8 @@ class KCC(object):
|
|||||||
|
|
||||||
res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE,
|
res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE,
|
||||||
attrs=["objectGUID"])
|
attrs=["objectGUID"])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
raise KCCError("Unable to find my nTDSDSA - (%s)" % estr)
|
raise KCCError("Unable to find my nTDSDSA - (%s)" % estr)
|
||||||
|
|
||||||
if len(res) != 1:
|
if len(res) != 1:
|
||||||
@ -326,7 +331,8 @@ class KCC(object):
|
|||||||
self.samdb.get_config_basedn(),
|
self.samdb.get_config_basedn(),
|
||||||
scope=ldb.SCOPE_SUBTREE,
|
scope=ldb.SCOPE_SUBTREE,
|
||||||
expression="(objectClass=crossRef)")
|
expression="(objectClass=crossRef)")
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e6:
|
||||||
|
(enum, estr) = e6.args
|
||||||
raise KCCError("Unable to find partitions - (%s)" % estr)
|
raise KCCError("Unable to find partitions - (%s)" % estr)
|
||||||
|
|
||||||
for msg in res:
|
for msg in res:
|
||||||
@ -2479,7 +2485,8 @@ class KCC(object):
|
|||||||
self.samdb = SamDB(url=dburl,
|
self.samdb = SamDB(url=dburl,
|
||||||
session_info=system_session(),
|
session_info=system_session(),
|
||||||
credentials=creds, lp=lp)
|
credentials=creds, lp=lp)
|
||||||
except ldb.LdbError, (num, msg):
|
except ldb.LdbError as e1:
|
||||||
|
(num, msg) = e1.args
|
||||||
raise KCCError("Unable to open sam database %s : %s" %
|
raise KCCError("Unable to open sam database %s : %s" %
|
||||||
(dburl, msg))
|
(dburl, msg))
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ class NamingContext(object):
|
|||||||
res = samdb.search(base=self.nc_dnstr,
|
res = samdb.search(base=self.nc_dnstr,
|
||||||
scope=ldb.SCOPE_BASE, attrs=attrs)
|
scope=ldb.SCOPE_BASE, attrs=attrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
raise KCCError("Unable to find naming context (%s) - (%s)" %
|
raise KCCError("Unable to find naming context (%s) - (%s)" %
|
||||||
(self.nc_dnstr, estr))
|
(self.nc_dnstr, estr))
|
||||||
msg = res[0]
|
msg = res[0]
|
||||||
@ -301,7 +302,8 @@ class NCReplica(NamingContext):
|
|||||||
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=["repsFrom"])
|
attrs=["repsFrom"])
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e1:
|
||||||
|
(enum, estr) = e1.args
|
||||||
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
||||||
(self.nc_dnstr, estr))
|
(self.nc_dnstr, estr))
|
||||||
|
|
||||||
@ -389,7 +391,8 @@ class NCReplica(NamingContext):
|
|||||||
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=["replUpToDateVector"])
|
attrs=["replUpToDateVector"])
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e2:
|
||||||
|
(enum, estr) = e2.args
|
||||||
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
||||||
(self.nc_dnstr, estr))
|
(self.nc_dnstr, estr))
|
||||||
|
|
||||||
@ -423,7 +426,8 @@ class NCReplica(NamingContext):
|
|||||||
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=["fSMORoleOwner"])
|
attrs=["fSMORoleOwner"])
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e3:
|
||||||
|
(enum, estr) = e3.args
|
||||||
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
||||||
(self.nc_dnstr, estr))
|
(self.nc_dnstr, estr))
|
||||||
|
|
||||||
@ -452,7 +456,8 @@ class NCReplica(NamingContext):
|
|||||||
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.nc_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=["repsTo"])
|
attrs=["repsTo"])
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e4:
|
||||||
|
(enum, estr) = e4.args
|
||||||
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
raise KCCError("Unable to find NC for (%s) - (%s)" %
|
||||||
(self.nc_dnstr, estr))
|
(self.nc_dnstr, estr))
|
||||||
|
|
||||||
@ -644,7 +649,8 @@ class DirectoryServiceAgent(object):
|
|||||||
res = samdb.search(base=self.dsa_dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.dsa_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e5:
|
||||||
|
(enum, estr) = e5.args
|
||||||
raise KCCError("Unable to find nTDSDSA for (%s) - (%s)" %
|
raise KCCError("Unable to find nTDSDSA for (%s) - (%s)" %
|
||||||
(self.dsa_dnstr, estr))
|
(self.dsa_dnstr, estr))
|
||||||
|
|
||||||
@ -705,7 +711,8 @@ class DirectoryServiceAgent(object):
|
|||||||
res = samdb.search(base=self.dsa_dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.dsa_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=ncattrs)
|
attrs=ncattrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e6:
|
||||||
|
(enum, estr) = e6.args
|
||||||
raise KCCError("Unable to find nTDSDSA NCs for (%s) - (%s)" %
|
raise KCCError("Unable to find nTDSDSA NCs for (%s) - (%s)" %
|
||||||
(self.dsa_dnstr, estr))
|
(self.dsa_dnstr, estr))
|
||||||
|
|
||||||
@ -773,7 +780,8 @@ class DirectoryServiceAgent(object):
|
|||||||
scope=ldb.SCOPE_SUBTREE,
|
scope=ldb.SCOPE_SUBTREE,
|
||||||
expression="(objectClass=nTDSConnection)")
|
expression="(objectClass=nTDSConnection)")
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e7:
|
||||||
|
(enum, estr) = e7.args
|
||||||
raise KCCError("Unable to find nTDSConnection for (%s) - (%s)" %
|
raise KCCError("Unable to find nTDSConnection for (%s) - (%s)" %
|
||||||
(self.dsa_dnstr, estr))
|
(self.dsa_dnstr, estr))
|
||||||
|
|
||||||
@ -951,7 +959,8 @@ class NTDSConnection(object):
|
|||||||
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e8:
|
||||||
|
(enum, estr) = e8.args
|
||||||
raise KCCError("Unable to find nTDSConnection for (%s) - (%s)" %
|
raise KCCError("Unable to find nTDSConnection for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
|
|
||||||
@ -1001,7 +1010,8 @@ class NTDSConnection(object):
|
|||||||
res = samdb.search(base=tdnstr,
|
res = samdb.search(base=tdnstr,
|
||||||
scope=ldb.SCOPE_BASE, attrs=attrs)
|
scope=ldb.SCOPE_BASE, attrs=attrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e9:
|
||||||
|
(enum, estr) = e9.args
|
||||||
raise KCCError("Unable to find transport (%s) - (%s)" %
|
raise KCCError("Unable to find transport (%s) - (%s)" %
|
||||||
(tdnstr, estr))
|
(tdnstr, estr))
|
||||||
|
|
||||||
@ -1028,7 +1038,8 @@ class NTDSConnection(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
samdb.delete(self.dnstr)
|
samdb.delete(self.dnstr)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e10:
|
||||||
|
(enum, estr) = e10.args
|
||||||
raise KCCError("Could not delete nTDSConnection for (%s) - (%s)" %
|
raise KCCError("Could not delete nTDSConnection for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
|
|
||||||
@ -1052,7 +1063,8 @@ class NTDSConnection(object):
|
|||||||
if len(msg) != 0:
|
if len(msg) != 0:
|
||||||
found = True
|
found = True
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e11:
|
||||||
|
(enum, estr) = e11.args
|
||||||
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
if enum != ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise KCCError("Unable to search for (%s) - (%s)" %
|
raise KCCError("Unable to search for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
@ -1097,7 +1109,8 @@ class NTDSConnection(object):
|
|||||||
ldb.FLAG_MOD_ADD, "schedule")
|
ldb.FLAG_MOD_ADD, "schedule")
|
||||||
try:
|
try:
|
||||||
samdb.add(m)
|
samdb.add(m)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e12:
|
||||||
|
(enum, estr) = e12.args
|
||||||
raise KCCError("Could not add nTDSConnection for (%s) - (%s)" %
|
raise KCCError("Could not add nTDSConnection for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
|
|
||||||
@ -1120,7 +1133,8 @@ class NTDSConnection(object):
|
|||||||
# of self.dnstr in the database.
|
# of self.dnstr in the database.
|
||||||
samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE)
|
samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e13:
|
||||||
|
(enum, estr) = e13.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise KCCError("nTDSConnection for (%s) doesn't exist!" %
|
raise KCCError("nTDSConnection for (%s) doesn't exist!" %
|
||||||
self.dnstr)
|
self.dnstr)
|
||||||
@ -1166,7 +1180,8 @@ class NTDSConnection(object):
|
|||||||
ldb.MessageElement([], ldb.FLAG_MOD_DELETE, "schedule")
|
ldb.MessageElement([], ldb.FLAG_MOD_DELETE, "schedule")
|
||||||
try:
|
try:
|
||||||
samdb.modify(m)
|
samdb.modify(m)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e14:
|
||||||
|
(enum, estr) = e14.args
|
||||||
raise KCCError("Could not modify nTDSConnection for (%s) - (%s)" %
|
raise KCCError("Could not modify nTDSConnection for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
|
|
||||||
@ -1326,7 +1341,8 @@ class Partition(NamingContext):
|
|||||||
res = samdb.search(base=self.partstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.partstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e15:
|
||||||
|
(enum, estr) = e15.args
|
||||||
raise KCCError("Unable to find partition for (%s) - (%s)" %
|
raise KCCError("Unable to find partition for (%s) - (%s)" %
|
||||||
(self.partstr, estr))
|
(self.partstr, estr))
|
||||||
msg = res[0]
|
msg = res[0]
|
||||||
@ -1466,7 +1482,8 @@ class Site(object):
|
|||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
self_res = samdb.search(base=self.site_dnstr, scope=ldb.SCOPE_BASE,
|
self_res = samdb.search(base=self.site_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=['objectGUID'])
|
attrs=['objectGUID'])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e16:
|
||||||
|
(enum, estr) = e16.args
|
||||||
raise KCCError("Unable to find site settings for (%s) - (%s)" %
|
raise KCCError("Unable to find site settings for (%s) - (%s)" %
|
||||||
(ssdn, estr))
|
(ssdn, estr))
|
||||||
|
|
||||||
@ -1497,7 +1514,8 @@ class Site(object):
|
|||||||
res = samdb.search(self.site_dnstr,
|
res = samdb.search(self.site_dnstr,
|
||||||
scope=ldb.SCOPE_SUBTREE,
|
scope=ldb.SCOPE_SUBTREE,
|
||||||
expression="(objectClass=nTDSDSA)")
|
expression="(objectClass=nTDSDSA)")
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e17:
|
||||||
|
(enum, estr) = e17.args
|
||||||
raise KCCError("Unable to find nTDSDSAs - (%s)" % estr)
|
raise KCCError("Unable to find nTDSDSAs - (%s)" % estr)
|
||||||
|
|
||||||
for msg in res:
|
for msg in res:
|
||||||
@ -1885,7 +1903,8 @@ class Transport(object):
|
|||||||
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e18:
|
||||||
|
(enum, estr) = e18.args
|
||||||
raise KCCError("Unable to find Transport for (%s) - (%s)" %
|
raise KCCError("Unable to find Transport for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
|
|
||||||
@ -2145,7 +2164,8 @@ class SiteLink(object):
|
|||||||
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs, controls=['extended_dn:0'])
|
attrs=attrs, controls=['extended_dn:0'])
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e19:
|
||||||
|
(enum, estr) = e19.args
|
||||||
raise KCCError("Unable to find SiteLink for (%s) - (%s)" %
|
raise KCCError("Unable to find SiteLink for (%s) - (%s)" %
|
||||||
(self.dnstr, estr))
|
(self.dnstr, estr))
|
||||||
|
|
||||||
|
@ -109,7 +109,8 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
|||||||
samdb = SamDB(url=dburl,
|
samdb = SamDB(url=dburl,
|
||||||
session_info=system_session(),
|
session_info=system_session(),
|
||||||
credentials=creds, lp=lp)
|
credentials=creds, lp=lp)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
raise LdifError("Unable to open sam database (%s) : %s" %
|
raise LdifError("Unable to open sam database (%s) : %s" %
|
||||||
(dburl, estr))
|
(dburl, estr))
|
||||||
|
|
||||||
@ -396,7 +397,8 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
|||||||
# Write rootdse output
|
# Write rootdse output
|
||||||
write_search_result(samdb, f, res)
|
write_search_result(samdb, f, res)
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e1:
|
||||||
|
(enum, estr) = e1.args
|
||||||
raise LdifError("Error processing (%s) : %s" % (sstr, estr))
|
raise LdifError("Error processing (%s) : %s" % (sstr, estr))
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -428,7 +428,8 @@ def get_last_provision_usn(sam):
|
|||||||
entry = sam.search(expression="%s=*" % LAST_PROVISION_USN_ATTRIBUTE,
|
entry = sam.search(expression="%s=*" % LAST_PROVISION_USN_ATTRIBUTE,
|
||||||
base="@PROVISION", scope=ldb.SCOPE_BASE,
|
base="@PROVISION", scope=ldb.SCOPE_BASE,
|
||||||
attrs=[LAST_PROVISION_USN_ATTRIBUTE, "provisionnerID"])
|
attrs=[LAST_PROVISION_USN_ATTRIBUTE, "provisionnerID"])
|
||||||
except ldb.LdbError, (ecode, emsg):
|
except ldb.LdbError as e1:
|
||||||
|
(ecode, emsg) = e1.args
|
||||||
if ecode == ldb.ERR_NO_SUCH_OBJECT:
|
if ecode == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
return None
|
return None
|
||||||
raise
|
raise
|
||||||
@ -1274,7 +1275,8 @@ def setup_samdb(path, session_info, provision_backend, lp, names,
|
|||||||
# DB
|
# DB
|
||||||
try:
|
try:
|
||||||
samdb.connect(path)
|
samdb.connect(path)
|
||||||
except ldb.LdbError, (num, string_error):
|
except ldb.LdbError as e2:
|
||||||
|
(num, string_error) = e2.args
|
||||||
if (num == ldb.ERR_INSUFFICIENT_ACCESS_RIGHTS):
|
if (num == ldb.ERR_INSUFFICIENT_ACCESS_RIGHTS):
|
||||||
raise ProvisioningError("Permission denied connecting to %s, are you running as root?" % path)
|
raise ProvisioningError("Permission denied connecting to %s, are you running as root?" % path)
|
||||||
else:
|
else:
|
||||||
@ -1902,7 +1904,8 @@ def provision_fill(samdb, secrets_ldb, logger, names, paths,
|
|||||||
elements=kerberos_enctypes, flags=ldb.FLAG_MOD_REPLACE,
|
elements=kerberos_enctypes, flags=ldb.FLAG_MOD_REPLACE,
|
||||||
name="msDS-SupportedEncryptionTypes")
|
name="msDS-SupportedEncryptionTypes")
|
||||||
samdb.modify(msg)
|
samdb.modify(msg)
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
if enum != ldb.ERR_NO_SUCH_ATTRIBUTE:
|
if enum != ldb.ERR_NO_SUCH_ATTRIBUTE:
|
||||||
# It might be that this attribute does not exist in this schema
|
# It might be that this attribute does not exist in this schema
|
||||||
raise
|
raise
|
||||||
|
@ -54,7 +54,8 @@ def remove_sysvol_references(samdb, logger, dc_name):
|
|||||||
try:
|
try:
|
||||||
logger.info("Removing Sysvol reference: %s" % dn)
|
logger.info("Removing Sysvol reference: %s" % dn)
|
||||||
samdb.delete(dn)
|
samdb.delete(dn)
|
||||||
except ldb.LdbError as (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -77,7 +78,8 @@ def remove_sysvol_references(samdb, logger, dc_name):
|
|||||||
try:
|
try:
|
||||||
logger.info("Removing Sysvol reference: %s" % dn)
|
logger.info("Removing Sysvol reference: %s" % dn)
|
||||||
samdb.delete(dn)
|
samdb.delete(dn)
|
||||||
except ldb.LdbError as (enum, estr):
|
except ldb.LdbError as e1:
|
||||||
|
(enum, estr) = e1.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -98,7 +100,8 @@ def remove_dns_references(samdb, logger, dnsHostName, ignore_no_name=False):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
(dn, primary_recs) = samdb.dns_lookup(dnsHostName)
|
(dn, primary_recs) = samdb.dns_lookup(dnsHostName)
|
||||||
except RuntimeError as (enum, estr):
|
except RuntimeError as e4:
|
||||||
|
(enum, estr) = e4.args
|
||||||
if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
|
if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
|
||||||
if ignore_no_name:
|
if ignore_no_name:
|
||||||
remove_hanging_dns_references(samdb, logger,
|
remove_hanging_dns_references(samdb, logger,
|
||||||
@ -145,7 +148,8 @@ def remove_dns_references(samdb, logger, dnsHostName, ignore_no_name=False):
|
|||||||
try:
|
try:
|
||||||
logger.debug("checking for DNS records to remove on %s" % a_name)
|
logger.debug("checking for DNS records to remove on %s" % a_name)
|
||||||
(a_rec_dn, a_recs) = samdb.dns_lookup(a_name)
|
(a_rec_dn, a_recs) = samdb.dns_lookup(a_name)
|
||||||
except RuntimeError as (enum, estr):
|
except RuntimeError as e2:
|
||||||
|
(enum, estr) = e2.args
|
||||||
if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
|
if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
|
||||||
return
|
return
|
||||||
raise DemoteException("lookup of %s failed: %s" % (a_name, estr))
|
raise DemoteException("lookup of %s failed: %s" % (a_name, estr))
|
||||||
@ -300,7 +304,8 @@ def offline_remove_ntds_dc(samdb,
|
|||||||
try:
|
try:
|
||||||
msgs = samdb.search(base=ntds_dn, expression="objectClass=ntdsDSA",
|
msgs = samdb.search(base=ntds_dn, expression="objectClass=ntdsDSA",
|
||||||
attrs=["objectGUID"], scope=ldb.SCOPE_BASE)
|
attrs=["objectGUID"], scope=ldb.SCOPE_BASE)
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e5:
|
||||||
|
(enum, estr) = e5.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise DemoteException("Given DN %s doesn't exist" % ntds_dn)
|
raise DemoteException("Given DN %s doesn't exist" % ntds_dn)
|
||||||
else:
|
else:
|
||||||
@ -349,7 +354,8 @@ def offline_remove_ntds_dc(samdb,
|
|||||||
try:
|
try:
|
||||||
logger.info("Removing nTDSDSA: %s (and any children)" % ntds_dn)
|
logger.info("Removing nTDSDSA: %s (and any children)" % ntds_dn)
|
||||||
samdb.delete(ntds_dn, ["tree_delete:0"])
|
samdb.delete(ntds_dn, ["tree_delete:0"])
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e6:
|
||||||
|
(enum, estr) = e6.args
|
||||||
raise DemoteException("Failed to remove the DCs NTDS DSA object: %s"
|
raise DemoteException("Failed to remove the DCs NTDS DSA object: %s"
|
||||||
% estr)
|
% estr)
|
||||||
|
|
||||||
@ -381,7 +387,8 @@ def remove_dc(samdb, logger, dc_name):
|
|||||||
expression="(&(objectClass=server)"
|
expression="(&(objectClass=server)"
|
||||||
"(cn=%s))"
|
"(cn=%s))"
|
||||||
% ldb.binary_encode(dc_name))
|
% ldb.binary_encode(dc_name))
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e3:
|
||||||
|
(enum, estr) = e3.args
|
||||||
raise DemoteException("Failure checking if %s is an server "
|
raise DemoteException("Failure checking if %s is an server "
|
||||||
"object in %s: "
|
"object in %s: "
|
||||||
% (dc_name, samdb.domain_dns_name()), estr)
|
% (dc_name, samdb.domain_dns_name()), estr)
|
||||||
@ -399,7 +406,8 @@ def remove_dc(samdb, logger, dc_name):
|
|||||||
try:
|
try:
|
||||||
ntds_msgs = samdb.search(base=ntds_dn, attrs=[], scope=ldb.SCOPE_BASE,
|
ntds_msgs = samdb.search(base=ntds_dn, attrs=[], scope=ldb.SCOPE_BASE,
|
||||||
expression="(objectClass=ntdsdsa)")
|
expression="(objectClass=ntdsdsa)")
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e7:
|
||||||
|
(enum, estr) = e7.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
ntds_msgs = []
|
ntds_msgs = []
|
||||||
pass
|
pass
|
||||||
|
@ -107,7 +107,8 @@ def delete_site(samdb, configDn, siteName):
|
|||||||
expression="objectClass=site")
|
expression="objectClass=site")
|
||||||
if len(ret) != 1:
|
if len(ret) != 1:
|
||||||
raise SiteNotFoundException('Site %s does not exist' % siteName)
|
raise SiteNotFoundException('Site %s does not exist' % siteName)
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise SiteNotFoundException('Site %s does not exist' % siteName)
|
raise SiteNotFoundException('Site %s does not exist' % siteName)
|
||||||
|
|
||||||
|
@ -85,7 +85,8 @@ def create_subnet(samdb, configDn, subnet_name, site_name):
|
|||||||
m["siteObject"] = ldb.MessageElement(str(dn_site), FLAG_MOD_ADD,
|
m["siteObject"] = ldb.MessageElement(str(dn_site), FLAG_MOD_ADD,
|
||||||
"siteObject")
|
"siteObject")
|
||||||
samdb.add(m)
|
samdb.add(m)
|
||||||
except ldb.LdbError as (enum, estr):
|
except ldb.LdbError as e:
|
||||||
|
(enum, estr) = e.args
|
||||||
if enum == ldb.ERR_INVALID_DN_SYNTAX:
|
if enum == ldb.ERR_INVALID_DN_SYNTAX:
|
||||||
raise SubnetInvalid("%s is not a valid subnet: %s" % (subnet_name, estr))
|
raise SubnetInvalid("%s is not a valid subnet: %s" % (subnet_name, estr))
|
||||||
elif enum == ldb.ERR_ENTRY_ALREADY_EXISTS:
|
elif enum == ldb.ERR_ENTRY_ALREADY_EXISTS:
|
||||||
@ -121,7 +122,8 @@ def delete_subnet(samdb, configDn, subnet_name):
|
|||||||
expression="objectClass=subnet")
|
expression="objectClass=subnet")
|
||||||
if len(ret) != 1:
|
if len(ret) != 1:
|
||||||
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e1:
|
||||||
|
(enum, estr) = e1.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
||||||
|
|
||||||
@ -149,7 +151,8 @@ def rename_subnet(samdb, configDn, subnet_name, new_name):
|
|||||||
newdnsubnet.set_component(0, "CN", new_name)
|
newdnsubnet.set_component(0, "CN", new_name)
|
||||||
try:
|
try:
|
||||||
samdb.rename(dnsubnet, newdnsubnet)
|
samdb.rename(dnsubnet, newdnsubnet)
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e2:
|
||||||
|
(enum, estr) = e2.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise SubnetNotFound('Subnet %s does not exist' % subnet)
|
raise SubnetNotFound('Subnet %s does not exist' % subnet)
|
||||||
elif enum == ldb.ERR_ENTRY_ALREADY_EXISTS:
|
elif enum == ldb.ERR_ENTRY_ALREADY_EXISTS:
|
||||||
@ -187,7 +190,8 @@ def set_subnet_site(samdb, configDn, subnet_name, site_name):
|
|||||||
expression="objectClass=subnet")
|
expression="objectClass=subnet")
|
||||||
if len(ret) != 1:
|
if len(ret) != 1:
|
||||||
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e3:
|
||||||
|
(enum, estr) = e3.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
raise SubnetNotFound('Subnet %s does not exist' % subnet_name)
|
||||||
|
|
||||||
@ -206,7 +210,8 @@ def set_subnet_site(samdb, configDn, subnet_name, site_name):
|
|||||||
expression="objectClass=site")
|
expression="objectClass=site")
|
||||||
if len(ret) != 1:
|
if len(ret) != 1:
|
||||||
raise SiteNotFoundException('Site %s does not exist' % site_name)
|
raise SiteNotFoundException('Site %s does not exist' % site_name)
|
||||||
except LdbError as (enum, estr):
|
except LdbError as e4:
|
||||||
|
(enum, estr) = e4.args
|
||||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
raise SiteNotFoundException('Site %s does not exist' % site_name)
|
raise SiteNotFoundException('Site %s does not exist' % site_name)
|
||||||
|
|
||||||
|
@ -255,7 +255,8 @@ def add_group_from_mapping_entry(samdb, groupmap, logger):
|
|||||||
msg = samdb.search(
|
msg = samdb.search(
|
||||||
base='<SID=%s>' % str(groupmap.sid), scope=ldb.SCOPE_BASE)
|
base='<SID=%s>' % str(groupmap.sid), scope=ldb.SCOPE_BASE)
|
||||||
found = True
|
found = True
|
||||||
except ldb.LdbError, (ecode, emsg):
|
except ldb.LdbError as e1:
|
||||||
|
(ecode, emsg) = e1.args
|
||||||
if ecode == ldb.ERR_NO_SUCH_OBJECT:
|
if ecode == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
found = False
|
found = False
|
||||||
else:
|
else:
|
||||||
@ -312,7 +313,8 @@ def add_users_to_group(samdb, group, members, logger):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
samdb.modify(m)
|
samdb.modify(m)
|
||||||
except ldb.LdbError, (ecode, emsg):
|
except ldb.LdbError as e:
|
||||||
|
(ecode, emsg) = e.args
|
||||||
if ecode == ldb.ERR_ENTRY_ALREADY_EXISTS:
|
if ecode == ldb.ERR_ENTRY_ALREADY_EXISTS:
|
||||||
logger.debug("skipped re-adding member '%s' to group '%s': %s", member_sid, group.sid, emsg)
|
logger.debug("skipped re-adding member '%s' to group '%s': %s", member_sid, group.sid, emsg)
|
||||||
elif ecode == ldb.ERR_NO_SUCH_OBJECT:
|
elif ecode == ldb.ERR_NO_SUCH_OBJECT:
|
||||||
|
Reference in New Issue
Block a user