diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-12-24 14:16:59 -0600 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-26 11:57:06 -0600 |
commit | 3c22677a8ce1635d7e055f954153dec4c1796b17 (patch) | |
tree | be568cf2aa91f41c6a1c9e2d173f893006cd3ad8 /source4/scripting/python/samba | |
parent | 8ada900ee67fc8e1a1ff94c9e5f7a50752d11017 (diff) | |
download | samba-3c22677a8ce1635d7e055f954153dec4c1796b17.tar.gz |
r26591: Get the first bits of samba3dump to work again.
(This used to be commit 3511027515f8ea860fbe46639d9169999646a297)
Diffstat (limited to 'source4/scripting/python/samba')
-rw-r--r-- | source4/scripting/python/samba/samba3.py | 42 | ||||
-rw-r--r-- | source4/scripting/python/samba/upgrade.py | 4 |
2 files changed, 32 insertions, 14 deletions
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py index b75b24ba34a..40443bd8bab 100644 --- a/source4/scripting/python/samba/samba3.py +++ b/source4/scripting/python/samba/samba3.py @@ -170,6 +170,16 @@ class SecretsDatabase: def get_dom_guid(self, host): return self.tdb.get("SECRETS/DOMGUID/%s" % host) + def ldap_dns(self): + for k in self.tdb.keys(): + if k.startswith("SECRETS/LDAP_BIND_PW/"): + yield k[len("SECRETS/LDAP_BIND_PW/"):].rstrip("\0") + + def domains(self): + for k in self.tdb.keys(): + if k.startswith("SECRETS/SID/"): + yield k[len("SECRETS/SID/"):].rstrip("\0") + def get_ldap_bind_pw(self, host): return self.tdb.get("SECRETS/LDAP_BIND_PW/%s" % host) @@ -177,10 +187,10 @@ class SecretsDatabase: return self.tdb.get("SECRETS/AFS_KEYFILE/%s" % host) def get_machine_sec_channel_type(self, host): - return self.tdb.get("SECRETS/MACHINE_SEC_CHANNEL_TYPE/%s" % host) + return self.tdb.fetch_uint32("SECRETS/MACHINE_SEC_CHANNEL_TYPE/%s" % host) def get_machine_last_change_time(self, host): - return self.tdb.get("SECRETS/MACHINE_LAST_CHANGE_TIME/%s" % host) + return self.tdb.fetch_uint32("SECRETS/MACHINE_LAST_CHANGE_TIME/%s" % host) def get_machine_password(self, host): return self.tdb.get("SECRETS/MACHINE_PASSWORD/%s" % host) @@ -191,6 +201,11 @@ class SecretsDatabase: def get_domtrust_acc(self, host): return self.tdb.get("SECRETS/$DOMTRUST.ACC/%s" % host) + def trusted_domains(self): + for k in self.tdb.keys(): + if k.startswith("SECRETS/$DOMTRUST.ACC/"): + yield k[len("SECRETS/$DOMTRUST.ACC/"):].rstrip("\0") + def get_random_seed(self): return self.tdb.get("INFO/random_seed") @@ -307,6 +322,9 @@ class SmbpasswdFile: def __getitem__(self, name): return self.users[name] + def __iter__(self): + return iter(self.entries) + def close(self): # For consistency pass @@ -363,7 +381,6 @@ class WinsDatabase: if l[0] == "#": # skip comments continue entries = shellsplit(l.rstrip("\n")) - print entries name = entries[0] ttl = int(entries[1]) i = 2 @@ -382,31 +399,34 @@ class WinsDatabase: def __len__(self): return len(self.entries) + def __iter__(self): + return iter(self.entries) + def close(self): # for consistency pass class Samba3: - def __init__(self, smbconfpath, libdir): + def __init__(self, libdir, smbconfpath): self.smbconfpath = smbconfpath self.libdir = libdir def get_policy_db(self): - return PolicyDatabase(os.path.join(libdir, "account_policy.tdb")) + return PolicyDatabase(os.path.join(self.libdir, "account_policy.tdb")) def get_registry(self): - return Registry(os.path.join(libdir, "registry.tdb")) + return Registry(os.path.join(self.libdir, "registry.tdb")) def get_secrets_db(self): - return SecretsDatabase(os.path.join(libdir, "secrets.tdb")) + return SecretsDatabase(os.path.join(self.libdir, "secrets.tdb")) def get_shares_db(self): - return ShareInfoDatabase(os.path.join(libdir, "share_info.tdb")) + return ShareInfoDatabase(os.path.join(self.libdir, "share_info.tdb")) def get_idmap_db(self): - return IdmapDatabase(os.path.join(libdir, "winbindd_idmap.tdb")) + return IdmapDatabase(os.path.join(self.libdir, "winbindd_idmap.tdb")) def get_wins_db(self): - return WinsDatabase(os.path.join(libdir, "wins.dat")) + return WinsDatabase(os.path.join(self.libdir, "wins.dat")) def get_groupmapping_db(self): - return GroupMappingDatabase(os.path.join(libdir, "group_mapping.tdb")) + return GroupMappingDatabase(os.path.join(self.libdir, "group_mapping.tdb")) diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py index 4f2ab46ef00..375c39eb5aa 100644 --- a/source4/scripting/python/samba/upgrade.py +++ b/source4/scripting/python/samba/upgrade.py @@ -447,7 +447,6 @@ def upgrade_smbconf(oldconf,mark): def upgrade(subobj, samba3, message, paths, session_info, credentials): ret = 0 - lp = loadparm_init() samdb = Ldb(paths.samdb, session_info=session_info, credentials=credentials) message("Writing configuration") @@ -455,8 +454,7 @@ def upgrade(subobj, samba3, message, paths, session_info, credentials): newconf.save(paths.smbconf) message("Importing account policies") - ldif = upgrade_sam_policy(samba3,subobj.BASEDN) - samdb.modify(ldif) + samdb.modify_ldif(upgrade_sam_policy(samba3,subobj.BASEDN)) regdb = Ldb(paths.hklm) regdb.modify(""" |