mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
KCC: pep8 for ldif_utils.py
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
070c9f7094
commit
c33761d9be
@ -20,28 +20,24 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
|
||||
from samba import (
|
||||
Ldb,
|
||||
ldb,
|
||||
dsdb,
|
||||
read_and_sub_file,
|
||||
# drs_utils,
|
||||
# nttime2unix
|
||||
)
|
||||
from samba import Ldb, ldb, read_and_sub_file
|
||||
from samba.auth import system_session
|
||||
from samba.samdb import SamDB
|
||||
from samba.common import dsdb_Dn
|
||||
|
||||
|
||||
class LdifError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def write_search_result(samdb, f, res):
|
||||
for msg in res:
|
||||
lstr = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
|
||||
f.write("%s" % lstr)
|
||||
|
||||
|
||||
def ldif_to_samdb(dburl, lp, creds, ldif_file, forced_local_dsa=None):
|
||||
"""Routine to import all objects and attributes that are relevent
|
||||
to the KCC algorithms from a previously exported LDIF file.
|
||||
@ -89,7 +85,8 @@ dsServiceName: CN=NTDS Settings,%s
|
||||
# modules only during this re-open
|
||||
samdb = SamDB(url=dburl, session_info=system_session(),
|
||||
credentials=creds, lp=lp,
|
||||
options=["modules:rootdse,extended_dn_in,extended_dn_out_ldb"])
|
||||
options=["modules:rootdse,extended_dn_in,"
|
||||
"extended_dn_out_ldb"])
|
||||
return samdb
|
||||
|
||||
|
||||
@ -127,7 +124,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
|
||||
try:
|
||||
# Query Partitions
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
@ -137,7 +134,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
"dnsRoot",
|
||||
"nCName",
|
||||
"msDS-NC-Replica-Locations",
|
||||
"msDS-NC-RO-Replica-Locations" ]
|
||||
"msDS-NC-RO-Replica-Locations"]
|
||||
|
||||
sstr = "CN=Partitions,%s" % samdb.get_config_basedn()
|
||||
res = samdb.search(base=sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
@ -148,14 +145,14 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
# Query cross reference container
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"fSMORoleOwner",
|
||||
"systemFlags",
|
||||
"msDS-Behavior-Version",
|
||||
"msDS-EnabledFeature" ]
|
||||
"msDS-EnabledFeature"]
|
||||
|
||||
sstr = "CN=Partitions,%s" % samdb.get_config_basedn()
|
||||
res = samdb.search(base=sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
@ -166,11 +163,11 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
# Query Sites
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"systemFlags" ]
|
||||
"systemFlags"]
|
||||
|
||||
sstr = "CN=Sites,%s" % samdb.get_config_basedn()
|
||||
sites = samdb.search(base=sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
@ -184,14 +181,14 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
for msg in sites:
|
||||
sitestr = str(msg.dn)
|
||||
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"interSiteTopologyGenerator",
|
||||
"interSiteTopologyFailover",
|
||||
"schedule",
|
||||
"options" ]
|
||||
"options"]
|
||||
|
||||
sstr = "CN=NTDS Site Settings,%s" % sitestr
|
||||
res = samdb.search(base=sstr, scope=ldb.SCOPE_BASE,
|
||||
@ -207,20 +204,20 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
for msg in sites:
|
||||
sstr = str(msg.dn)
|
||||
|
||||
ncattrs = [ "hasMasterNCs",
|
||||
ncattrs = ["hasMasterNCs",
|
||||
"msDS-hasMasterNCs",
|
||||
"hasPartialReplicaNCs",
|
||||
"msDS-HasDomainNCs",
|
||||
"msDS-hasFullReplicaNCs",
|
||||
"msDS-HasInstantiatedNCs" ]
|
||||
attrs = [ "objectClass",
|
||||
"msDS-HasInstantiatedNCs"]
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"invocationID",
|
||||
"options",
|
||||
"msDS-isRODC",
|
||||
"msDS-Behavior-Version" ]
|
||||
"msDS-Behavior-Version"]
|
||||
|
||||
res = samdb.search(base=sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
attrs=attrs + ncattrs,
|
||||
@ -247,7 +244,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
for msg in sites:
|
||||
sstr = str(msg.dn)
|
||||
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
@ -257,7 +254,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
"schedule",
|
||||
"transportType",
|
||||
"fromServer",
|
||||
"systemFlags" ]
|
||||
"systemFlags"]
|
||||
|
||||
res = samdb.search(base=sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
attrs=attrs,
|
||||
@ -265,16 +262,15 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
# Write NTDS Connection output
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
|
||||
# Query Intersite transports
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"options",
|
||||
"name",
|
||||
"bridgeheadServerListBL",
|
||||
"transportAddressAttribute" ]
|
||||
"transportAddressAttribute"]
|
||||
|
||||
sstr = "CN=Inter-Site Transports,CN=Sites,%s" % \
|
||||
samdb.get_config_basedn()
|
||||
@ -286,7 +282,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
# Query siteLink
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
@ -295,7 +291,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
"schedule",
|
||||
"replInterval",
|
||||
"siteList",
|
||||
"cost" ]
|
||||
"cost"]
|
||||
|
||||
sstr = "CN=Sites,%s" % \
|
||||
samdb.get_config_basedn()
|
||||
@ -308,11 +304,11 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
# Query siteLinkBridge
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"siteLinkList" ]
|
||||
"siteLinkList"]
|
||||
|
||||
sstr = "CN=Sites,%s" % samdb.get_config_basedn()
|
||||
res = samdb.search(sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
@ -324,11 +320,11 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
|
||||
# Query servers containers
|
||||
# Needed for samdb.server_site_name()
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"systemFlags" ]
|
||||
"systemFlags"]
|
||||
|
||||
sstr = "CN=Sites,%s" % samdb.get_config_basedn()
|
||||
res = samdb.search(sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
@ -342,13 +338,13 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
# Needed because some transport interfaces refer back to
|
||||
# attributes found in the server object. Also needed
|
||||
# so extended-dn will be happy with dsServiceName in rootDSE
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
"systemFlags",
|
||||
"dNSHostName",
|
||||
"mailAddress" ]
|
||||
"mailAddress"]
|
||||
|
||||
sstr = "CN=Sites,%s" % samdb.get_config_basedn()
|
||||
res = samdb.search(sstr, scope=ldb.SCOPE_SUBTREE,
|
||||
@ -359,7 +355,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
# Query Naming Context replicas
|
||||
attrs = [ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
@ -367,7 +363,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
"fSMORoleOwner",
|
||||
"msDS-Behavior-Version",
|
||||
"repsFrom",
|
||||
"repsTo" ]
|
||||
"repsTo"]
|
||||
|
||||
for sstr in nclist:
|
||||
res = samdb.search(sstr, scope=ldb.SCOPE_BASE,
|
||||
@ -377,7 +373,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
write_search_result(samdb, f, res)
|
||||
|
||||
# Query rootDSE replicas
|
||||
attrs=[ "objectClass",
|
||||
attrs = ["objectClass",
|
||||
"objectGUID",
|
||||
"cn",
|
||||
"whenChanged",
|
||||
@ -385,7 +381,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
|
||||
"configurationNamingContext",
|
||||
"schemaNamingContext",
|
||||
"defaultNamingContext",
|
||||
"dsServiceName" ]
|
||||
"dsServiceName"]
|
||||
|
||||
sstr = ""
|
||||
res = samdb.search(sstr, scope=ldb.SCOPE_BASE,
|
||||
|
Loading…
Reference in New Issue
Block a user