summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-11-10 15:18:52 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-11-12 16:34:11 +1100
commit6b0b3fed3127dd2da15a79eabea62708e82cc941 (patch)
tree7bc041c52d39d0525d15ed8b966d3287f9a2dd43 /source4/scripting/python
parent6437c38aeb5880b18728e65e1c19edf08ac5e4e9 (diff)
downloadsamba-6b0b3fed3127dd2da15a79eabea62708e82cc941.tar.gz
samba-6b0b3fed3127dd2da15a79eabea62708e82cc941.tar.bz2
samba-6b0b3fed3127dd2da15a79eabea62708e82cc941.zip
s4:provision Add C binding to get at the generate schema
This will allow us to do local tests against that schema
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/schema.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/schema.py b/source4/scripting/python/samba/schema.py
index 958a77d40f..2f90ac7122 100644
--- a/source4/scripting/python/samba/schema.py
+++ b/source4/scripting/python/samba/schema.py
@@ -32,6 +32,7 @@ from samba import read_and_sub_file, substitute_var, check_all_substituted
from samba import Ldb
from samba.ndr import ndr_pack
from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE
+import os
def get_schema_descriptor(domain_sid):
sddl = "O:SAG:SAD:(A;CI;RPLCLORC;;;AU)(A;CI;RPWPCRCCLCLORCWOWDSW;;;SA)" \
@@ -138,3 +139,25 @@ def get_dnsyntax_attributes(schemadn,schemaldb):
return attributes
+def ldb_with_schema(setup_dir=None, schemadn="cn=schema,cn=configuration,dc=example,dc=com",
+ serverdn="cn=server,cn=servers,cn=default-first-site-name,cn=sites,cn=cn=configuration,dc=example,dc=com",
+ domainsid=None):
+ """Load schema for the SamDB from the AD schema files and samba4_schema.ldif
+
+ :param setup_dir: Setup path
+ :param schemadn: DN of the schema
+ :param serverdn: DN of the server
+
+ Returns the schema data loaded as an object, with .ldb being a
+ new ldb with the schema loaded. This allows certain tests to
+ operate without a remote or local schema.
+ """
+
+ def setup_path(file):
+ return os.path.join(setup_dir, file)
+
+ if domainsid is None:
+ domainsid = security.random_sid()
+ else:
+ domainsid = security.dom_sid(domainsid)
+ return Schema(setup_path, domainsid, schemadn=schemadn, serverdn=serverdn)