def test_setup_secretsdb(self): path = os.path.join(self.tempdir, "secrets.ldb") paths = ProvisionPaths() paths.secrets = path paths.private_dir = os.path.dirname(path) paths.keytab = "no.keytab" paths.dns_keytab = "no.dns.keytab" ldb = setup_secretsdb(paths, None, None, lp=env_loadparm()) try: self.assertEquals("LSA Secrets", ldb.searchone(basedn="CN=LSA Secrets", attribute="CN")) finally: del ldb os.unlink(path)
def create_dummy_secretsdb(path, lp=None): """Create a dummy secrets database for use in tests. :param path: Path to store the secrets db :param lp: Optional loadparm context. A simple one will be generated if not specified. """ if lp is None: lp = env_loadparm() paths = ProvisionPaths() paths.secrets = path paths.private_dir = os.path.dirname(path) paths.keytab = "no.keytab" paths.dns_keytab = "no.dns.keytab" secrets_ldb = setup_secretsdb(paths, None, None, lp=lp) secrets_ldb.transaction_commit() return secrets_ldb
def base_result(self): result = ProvisionResult() result.server_role = "domain controller" result.names = ProvisionNames() result.names.hostname = "hostnaam" result.names.domain = "DOMEIN" result.names.dnsdomain = "dnsdomein" result.domainsid = "S1-1-1" result.paths = ProvisionPaths() return result
def create_dummy_secretsdb(path, lp=None): """Create a dummy secrets database for use in tests. :param path: Path to store the secrets db :param lp: Optional loadparm context. A simple one will be generated if not specified. """ if lp is None: lp = env_loadparm() paths = ProvisionPaths() paths.secrets = path paths.private_dir = os.path.dirname(path) paths.binddns_dir = os.path.dirname(path) paths.keytab = "no.keytab" paths.dns_keytab = "no.dns.keytab" secrets_ldb = setup_secretsdb(paths, None, None, lp=lp) secrets_ldb.transaction_commit() return secrets_ldb
def test_setup_secretsdb(self): path = os.path.join(self.tempdir, "secrets.ldb") paths = ProvisionPaths() paths.secrets = path paths.private_dir = os.path.dirname(path) paths.keytab = "no.keytab" paths.dns_keytab = "no.dns.keytab" ldb = setup_secretsdb(paths, None, None, lp=env_loadparm()) try: self.assertEquals( "LSA Secrets", ldb.searchone(basedn="CN=LSA Secrets", attribute="CN")) finally: del ldb os.unlink(path)
setup_path, setup_add_ldif, setup_ldb ) from samba.provision.sambadns import secretsdb_setup_dns if __name__ == '__main__': ## most of this is extracted from source4/scripting/python/samba/provision/* lp = LoadParm() lp.load('/etc/samba/smb.conf') samdb = SamDB('/var/lib/samba/private/sam.ldb', session_info=system_session(lp), lp=lp) secretsdb = samba.Ldb('/var/lib/samba/private/secrets.ldb', session_info=system_session(lp), lp=lp) paths = ProvisionPaths() paths.private_dir = lp.get("private dir") names = ProvisionNames() # NT domain, kerberos realm, root dn, domain dn, domain dns name names.realm = lp.get("realm").upper() names.domain = lp.get("workgroup").upper() names.domaindn = samdb.domain_dn() names.dnsdomain = samba.ldb.Dn(samdb, names.domaindn).canonical_str().replace("/", "") basedn = samba.dn_from_dns_name(names.dnsdomain) # Get the netbiosname first (could be obtained from smb.conf in theory) res = secretsdb.search(expression="(flatname=%s)" % names.domain,base="CN=Primary Domains", scope=samba.ldb.SCOPE_SUBTREE, attrs=["sAMAccountName"]) names.netbiosname = str(res[0]["sAMAccountName"]).replace("$","")
from samba.provision.sambadns import secretsdb_setup_dns if __name__ == '__main__': ## most of this is extracted from source4/scripting/python/samba/provision/* lp = LoadParm() lp.load('/etc/samba/smb.conf') samdb = SamDB('/var/lib/samba/private/sam.ldb', session_info=system_session(lp), lp=lp) secretsdb = samba.Ldb('/var/lib/samba/private/secrets.ldb', session_info=system_session(lp), lp=lp) paths = ProvisionPaths() paths.private_dir = lp.get("private dir") names = ProvisionNames() # NT domain, kerberos realm, root dn, domain dn, domain dns name names.realm = lp.get("realm").upper() names.domain = lp.get("workgroup").upper() names.domaindn = samdb.domain_dn() names.dnsdomain = samba.ldb.Dn(samdb, names.domaindn).canonical_str().replace( "/", "") basedn = samba.dn_from_dns_name(names.dnsdomain) # Get the netbiosname first (could be obtained from smb.conf in theory) res = secretsdb.search(expression="(flatname=%s)" % names.domain, base="CN=Primary Domains",