s4:dsdb/pydsdb.c - call the "objectClass" normalisation code from Python
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 11 Apr 2012 14:06:03 +0000 (16:06 +0200)
committerAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2012 05:48:05 +0000 (07:48 +0200)
This allows the dbchecker to fix ordering/inconsistency problems with
the mentioned attribute.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/dsdb/pydsdb.c

index 762a03de3f74c21b435b5ef9f4677300c5a14a4a..d3486a41ec66a760d09d215440acfb8855d50b4f 100644 (file)
@@ -569,6 +569,7 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
                PyObject *item = PyList_GetItem(el_list, i);
                if (!PyString_Check(item)) {
                        PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
+                       talloc_free(tmp_ctx);
                        return NULL;
                }
                el->values[i].data = (uint8_t *)PyString_AsString(item);
@@ -663,12 +664,25 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
                PyObject *item = PyList_GetItem(el_list, i);
                if (!PyString_Check(item)) {
                        PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
+                       talloc_free(tmp_ctx);
                        return NULL;
                }
                el->values[i].data = (uint8_t *)PyString_AsString(item);
                el->values[i].length = PyString_Size(item);
        }
 
+       /* Normalise "objectClass" attribute if needed */
+       if (ldb_attr_cmp(a->lDAPDisplayName, "objectClass") == 0) {
+               int iret;
+               iret = dsdb_sort_objectClass_attr(ldb, schema, tmp_ctx, el,
+                                                tmp_ctx, el);
+               if (iret != LDB_SUCCESS) {
+                       PyErr_SetString(PyExc_RuntimeError, ldb_errstring(ldb));
+                       talloc_free(tmp_ctx);
+                       return NULL;
+               }
+       }
+
        /* first run ldb_to_drsuapi, then convert back again. This has
         * the effect of normalising the attributes
         */