]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-rodc: Fix provision warnings by creating ntds objectGUID in provision
authorAnatoliy Atanasov <anatoliy.atanasov@postpath.com>
Mon, 10 May 2010 10:52:27 +0000 (13:52 +0300)
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>
Mon, 10 May 2010 14:24:02 +0000 (17:24 +0300)
source4/dsdb/pydsdb.c
source4/scripting/python/samba/provision.py
source4/scripting/python/samba/samdb.py

index 45f8b6e1cafa609dac016d2d12364d8bc3b430e4..c92eec2aaf4d2467034ac2310b2c60880753d1e2 100644 (file)
@@ -309,6 +309,26 @@ static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args)
        return result;
 }
 
+static PyObject *py_dsdb_set_ntds_objectGUID(PyObject *self, PyObject *args)
+{
+       PyObject *py_ldb, *py_guid;
+       bool ret;
+       struct GUID guid;
+       struct ldb_context *ldb;
+       if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_guid))
+               return NULL;
+
+       PyErr_LDB_OR_RAISE(py_ldb, ldb);
+       GUID_from_string(PyString_AsString(py_guid), &guid);
+
+       ret = samdb_set_ntds_objectGUID(ldb, &guid);
+       if (!ret) {
+               PyErr_SetString(PyExc_RuntimeError, "set_ntds_objectGUID failed");
+               return NULL;
+       }
+       Py_RETURN_NONE;
+}
+
 static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args)
 {
        PyObject *py_ldb;
@@ -399,6 +419,9 @@ static PyMethodDef py_dsdb_methods[] = {
                NULL },
        { "samdb_ntds_objectGUID", (PyCFunction)py_samdb_ntds_objectGUID,
                METH_VARARGS, "get the NTDS objectGUID as a string"},
+       { "dsdb_set_ntds_objectGUID",
+               (PyCFunction)py_dsdb_set_ntds_objectGUID, METH_VARARGS,
+               NULL },
        { "dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema,
                METH_VARARGS, NULL },
        { "dsdb_load_partition_usn", (PyCFunction)py_dsdb_load_partition_usn,
index fa2dabe5d476aac6593f78ebd7ef9a88b67aba2d..b9b59b4218adb37b5918056947ca6d487013525f 100644 (file)
@@ -840,7 +840,7 @@ def setup_samdb(path, setup_path, session_info, provision_backend, lp,
                 names, message, 
                 domainsid, domainguid, policyguid, policyguid_dc,
                 fill, adminpass, krbtgtpass, 
-                machinepass, invocationid, dnspass, ntdsguid,
+                machinepass, invocationid, ntds_guid, dnspass, ntdsguid,
                 serverrole, dom_for_fun_level=None,
                 schema=None):
     """Setup a complete SAM Database.
@@ -901,6 +901,7 @@ def setup_samdb(path, setup_path, session_info, provision_backend, lp,
 
         samdb.set_domain_sid(str(domainsid))
         samdb.set_invocation_id(invocationid)
+        samdb.set_ntds_GUID(ntds_guid)
         samdb.set_ntds_settings_dn("CN=NTDS Settings,%s" % names.serverdn)
 
         message("Adding DomainDN: %s" % names.domaindn)
@@ -1228,6 +1229,8 @@ def provision(setup_dir, message, session_info,
     if invocationid is None:
         invocationid = str(uuid.uuid4())
 
+    ntds_guid = str(uuid.uuid4())
+
     if not os.path.exists(paths.private_dir):
         os.mkdir(paths.private_dir)
     if not os.path.exists(os.path.join(paths.private_dir,"tls")):
@@ -1321,6 +1324,7 @@ def provision(setup_dir, message, session_info,
                         fill=samdb_fill, 
                         adminpass=adminpass, krbtgtpass=krbtgtpass,
                         invocationid=invocationid, 
+                        ntds_guid=ntds_guid,
                         machinepass=machinepass, dnspass=dnspass, 
                         ntdsguid=ntdsguid, serverrole=serverrole,
                         dom_for_fun_level=dom_for_fun_level)
index 991c678c7cf3fcc40338a383132720787dd0102a..d7b7d82604893e93b0f20a7fbd81f17f1fd9bbee 100644 (file)
@@ -262,6 +262,10 @@ accountExpires: %u
         "Get the NTDS objectGUID"
         return dsdb.samdb_ntds_objectGUID(self)
 
+    def set_ntds_GUID(self, object_guid):
+        "Set the NTDS objectGUID"
+        return dsdb.dsdb_set_ntds_objectGUID(self, object_guid)
+
     def server_site_name(self):
         "Get the server site name"
         return dsdb.samdb_server_site_name(self)