s3: Check for the packet size before accessing it
[Samba/gebeck_regimport.git] / source4 / dsdb / pydsdb.c
blobf9896c005295a9ee28fa55aab8764ddaf5ddda51
1 /*
2 Unix SMB/CIFS implementation.
3 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2010
4 Copyright (C) Matthias Dieter Wallnöfer 2009
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <Python.h>
21 #include "includes.h"
22 #include <ldb.h>
23 #include <pyldb.h>
24 #include "dsdb/samdb/samdb.h"
25 #include "libcli/security/security.h"
26 #include "librpc/ndr/libndr.h"
27 #include "system/kerberos.h"
28 #include "auth/kerberos/kerberos.h"
29 #include "librpc/rpc/pyrpc_util.h"
30 #include "lib/policy/policy.h"
32 void initdsdb(void);
34 /* There's no Py_ssize_t in 2.4, apparently */
35 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
36 typedef int Py_ssize_t;
37 typedef inquiry lenfunc;
38 typedef intargfunc ssizeargfunc;
39 #endif
41 /* FIXME: These should be in a header file somewhere */
42 #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
43 /* if (!PyLdb_Check(py_ldb)) { \
44 PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \
45 return NULL; \
46 } */\
47 ldb = pyldb_Ldb_AsLdbContext(py_ldb);
49 static PyObject *py_ldb_get_exception(void)
51 PyObject *mod = PyImport_ImportModule("ldb");
52 if (mod == NULL)
53 return NULL;
55 return PyObject_GetAttrString(mod, "LdbError");
58 static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx)
60 if (ret == LDB_ERR_PYTHON_EXCEPTION)
61 return; /* Python exception should already be set, just keep that */
63 PyErr_SetObject(error,
64 Py_BuildValue(discard_const_p(char, "(i,s)"), ret,
65 ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
68 static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args)
70 PyObject *py_ldb, *result;
71 struct ldb_context *ldb;
72 const char *site;
73 TALLOC_CTX *mem_ctx;
75 if (!PyArg_ParseTuple(args, "O", &py_ldb))
76 return NULL;
78 PyErr_LDB_OR_RAISE(py_ldb, ldb);
80 mem_ctx = talloc_new(NULL);
81 if (mem_ctx == NULL) {
82 PyErr_NoMemory();
83 return NULL;
86 site = samdb_server_site_name(ldb, mem_ctx);
87 if (site == NULL) {
88 PyErr_SetString(PyExc_RuntimeError, "Failed to find server site");
89 talloc_free(mem_ctx);
90 return NULL;
93 result = PyString_FromString(site);
94 talloc_free(mem_ctx);
95 return result;
98 static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self,
99 PyObject *args)
101 char *target_str, *mapping;
102 PyObject *py_ldb;
103 struct ldb_context *ldb;
104 PyObject *ret;
105 char *retstr;
107 if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &target_str, &mapping))
108 return NULL;
110 PyErr_LDB_OR_RAISE(py_ldb, ldb);
112 retstr = dsdb_convert_schema_to_openldap(ldb, target_str, mapping);
113 if (retstr == NULL) {
114 PyErr_SetString(PyExc_RuntimeError,
115 "dsdb_convert_schema_to_openldap failed");
116 return NULL;
119 ret = PyString_FromString(retstr);
120 talloc_free(retstr);
121 return ret;
124 static PyObject *py_samdb_set_domain_sid(PyLdbObject *self, PyObject *args)
126 PyObject *py_ldb, *py_sid;
127 struct ldb_context *ldb;
128 struct dom_sid *sid;
129 bool ret;
131 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_sid))
132 return NULL;
134 PyErr_LDB_OR_RAISE(py_ldb, ldb);
136 sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid));
137 if (sid == NULL) {
138 PyErr_NoMemory();
139 return NULL;
142 ret = samdb_set_domain_sid(ldb, sid);
143 talloc_free(sid);
144 if (!ret) {
145 PyErr_SetString(PyExc_RuntimeError, "set_domain_sid failed");
146 return NULL;
148 Py_RETURN_NONE;
151 static PyObject *py_samdb_set_ntds_settings_dn(PyLdbObject *self, PyObject *args)
153 PyObject *py_ldb, *py_ntds_settings_dn;
154 struct ldb_context *ldb;
155 struct ldb_dn *ntds_settings_dn;
156 TALLOC_CTX *tmp_ctx;
157 bool ret;
159 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_ntds_settings_dn))
160 return NULL;
162 PyErr_LDB_OR_RAISE(py_ldb, ldb);
164 tmp_ctx = talloc_new(NULL);
165 if (tmp_ctx == NULL) {
166 PyErr_NoMemory();
167 return NULL;
170 if (!pyldb_Object_AsDn(tmp_ctx, py_ntds_settings_dn, ldb, &ntds_settings_dn)) {
171 /* exception thrown by "pyldb_Object_AsDn" */
172 talloc_free(tmp_ctx);
173 return NULL;
176 ret = samdb_set_ntds_settings_dn(ldb, ntds_settings_dn);
177 talloc_free(tmp_ctx);
178 if (!ret) {
179 PyErr_SetString(PyExc_RuntimeError, "set_ntds_settings_dn failed");
180 return NULL;
182 Py_RETURN_NONE;
185 static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args)
187 PyObject *py_ldb;
188 struct ldb_context *ldb;
189 const struct dom_sid *sid;
190 PyObject *ret;
191 char *retstr;
193 if (!PyArg_ParseTuple(args, "O", &py_ldb))
194 return NULL;
196 PyErr_LDB_OR_RAISE(py_ldb, ldb);
198 sid = samdb_domain_sid(ldb);
199 if (!sid) {
200 PyErr_SetString(PyExc_RuntimeError, "samdb_domain_sid failed");
201 return NULL;
204 retstr = dom_sid_string(NULL, sid);
205 if (retstr == NULL) {
206 PyErr_NoMemory();
207 return NULL;
209 ret = PyString_FromString(retstr);
210 talloc_free(retstr);
211 return ret;
214 static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args)
216 PyObject *py_ldb, *result;
217 struct ldb_context *ldb;
218 const struct GUID *guid;
219 char *retstr;
221 if (!PyArg_ParseTuple(args, "O", &py_ldb)) {
222 return NULL;
225 PyErr_LDB_OR_RAISE(py_ldb, ldb);
227 guid = samdb_ntds_invocation_id(ldb);
228 if (guid == NULL) {
229 PyErr_SetString(PyExc_RuntimeError,
230 "Failed to find NTDS invocation ID");
231 return NULL;
234 retstr = GUID_string(NULL, guid);
235 if (retstr == NULL) {
236 PyErr_NoMemory();
237 return NULL;
239 result = PyString_FromString(retstr);
240 talloc_free(retstr);
241 return result;
244 static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args)
246 PyObject *py_ldb;
247 struct ldb_context *ldb;
248 uint32_t attid;
249 struct dsdb_schema *schema;
250 const char *oid;
251 PyObject *ret;
252 WERROR status;
253 TALLOC_CTX *mem_ctx;
255 if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
256 return NULL;
258 PyErr_LDB_OR_RAISE(py_ldb, ldb);
260 mem_ctx = talloc_new(NULL);
261 if (!mem_ctx) {
262 PyErr_NoMemory();
263 return NULL;
266 schema = dsdb_get_schema(ldb, mem_ctx);
267 if (!schema) {
268 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n");
269 talloc_free(mem_ctx);
270 return NULL;
273 status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid,
274 mem_ctx, &oid);
275 if (!W_ERROR_IS_OK(status)) {
276 PyErr_SetWERROR(status);
277 talloc_free(mem_ctx);
278 return NULL;
281 ret = PyString_FromString(oid);
283 talloc_free(mem_ctx);
285 return ret;
289 static PyObject *py_dsdb_get_attid_from_lDAPDisplayName(PyObject *self, PyObject *args)
291 PyObject *py_ldb, *is_schema_nc;
292 struct ldb_context *ldb;
293 struct dsdb_schema *schema;
294 const char *ldap_display_name;
295 bool schema_nc = false;
296 const struct dsdb_attribute *a;
297 uint32_t attid;
299 if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &is_schema_nc))
300 return NULL;
302 PyErr_LDB_OR_RAISE(py_ldb, ldb);
304 if (is_schema_nc) {
305 if (!PyBool_Check(is_schema_nc)) {
306 PyErr_SetString(PyExc_TypeError, "Expected boolean is_schema_nc");
307 return NULL;
309 if (is_schema_nc == Py_True) {
310 schema_nc = true;
314 schema = dsdb_get_schema(ldb, NULL);
316 if (!schema) {
317 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
318 return NULL;
321 a = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
322 if (a == NULL) {
323 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
324 return NULL;
327 attid = dsdb_attribute_get_attid(a, schema_nc);
329 return PyLong_FromUnsignedLong(attid);
333 return the systemFlags as int from the attribute name
335 static PyObject *py_dsdb_get_systemFlags_from_lDAPDisplayName(PyObject *self, PyObject *args)
337 PyObject *py_ldb;
338 struct ldb_context *ldb;
339 struct dsdb_schema *schema;
340 const char *ldap_display_name;
341 const struct dsdb_attribute *attribute;
343 if (!PyArg_ParseTuple(args, "Os", &py_ldb, &ldap_display_name))
344 return NULL;
346 PyErr_LDB_OR_RAISE(py_ldb, ldb);
348 schema = dsdb_get_schema(ldb, NULL);
350 if (!schema) {
351 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
352 return NULL;
355 attribute = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
356 if (attribute == NULL) {
357 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
358 return NULL;
361 return PyInt_FromLong(attribute->systemFlags);
365 return the linkID from the attribute name
367 static PyObject *py_dsdb_get_linkId_from_lDAPDisplayName(PyObject *self, PyObject *args)
369 PyObject *py_ldb;
370 struct ldb_context *ldb;
371 struct dsdb_schema *schema;
372 const char *ldap_display_name;
373 const struct dsdb_attribute *attribute;
375 if (!PyArg_ParseTuple(args, "Os", &py_ldb, &ldap_display_name))
376 return NULL;
378 PyErr_LDB_OR_RAISE(py_ldb, ldb);
380 schema = dsdb_get_schema(ldb, NULL);
382 if (!schema) {
383 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
384 return NULL;
387 attribute = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
388 if (attribute == NULL) {
389 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
390 return NULL;
393 return PyInt_FromLong(attribute->linkID);
397 return the backlink attribute name (if any) for an attribute
399 static PyObject *py_dsdb_get_backlink_from_lDAPDisplayName(PyObject *self, PyObject *args)
401 PyObject *py_ldb;
402 struct ldb_context *ldb;
403 struct dsdb_schema *schema;
404 const char *ldap_display_name;
405 const struct dsdb_attribute *attribute, *target_attr;
407 if (!PyArg_ParseTuple(args, "Os", &py_ldb, &ldap_display_name))
408 return NULL;
410 PyErr_LDB_OR_RAISE(py_ldb, ldb);
412 schema = dsdb_get_schema(ldb, NULL);
414 if (!schema) {
415 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
416 return NULL;
419 attribute = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
420 if (attribute == NULL) {
421 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
422 return NULL;
425 if (attribute->linkID == 0) {
426 Py_RETURN_NONE;
429 target_attr = dsdb_attribute_by_linkID(schema, attribute->linkID ^ 1);
430 if (target_attr == NULL) {
431 /* when we add pseudo-backlinks we'll need to handle
432 them here */
433 Py_RETURN_NONE;
436 return PyString_FromString(target_attr->lDAPDisplayName);
440 static PyObject *py_dsdb_get_lDAPDisplayName_by_attid(PyObject *self, PyObject *args)
442 PyObject *py_ldb;
443 struct ldb_context *ldb;
444 struct dsdb_schema *schema;
445 const struct dsdb_attribute *a;
446 uint32_t attid;
448 if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
449 return NULL;
451 PyErr_LDB_OR_RAISE(py_ldb, ldb);
453 schema = dsdb_get_schema(ldb, NULL);
455 if (!schema) {
456 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
457 return NULL;
460 a = dsdb_attribute_by_attributeID_id(schema, attid);
461 if (a == NULL) {
462 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '0x%08x'", attid);
463 return NULL;
466 return PyString_FromString(a->lDAPDisplayName);
471 return the attribute syntax oid as a string from the attribute name
473 static PyObject *py_dsdb_get_syntax_oid_from_lDAPDisplayName(PyObject *self, PyObject *args)
475 PyObject *py_ldb;
476 struct ldb_context *ldb;
477 struct dsdb_schema *schema;
478 const char *ldap_display_name;
479 const struct dsdb_attribute *attribute;
481 if (!PyArg_ParseTuple(args, "Os", &py_ldb, &ldap_display_name))
482 return NULL;
484 PyErr_LDB_OR_RAISE(py_ldb, ldb);
486 schema = dsdb_get_schema(ldb, NULL);
488 if (!schema) {
489 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
490 return NULL;
493 attribute = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
494 if (attribute == NULL) {
495 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
496 return NULL;
499 return PyString_FromString(attribute->syntax->ldap_oid);
503 convert a python string to a DRSUAPI drsuapi_DsReplicaAttribute attribute
505 static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
507 PyObject *py_ldb, *el_list, *ret;
508 struct ldb_context *ldb;
509 char *ldap_display_name;
510 const struct dsdb_attribute *a;
511 struct dsdb_schema *schema;
512 struct dsdb_syntax_ctx syntax_ctx;
513 struct ldb_message_element *el;
514 struct drsuapi_DsReplicaAttribute *attr;
515 TALLOC_CTX *tmp_ctx;
516 WERROR werr;
517 Py_ssize_t i;
519 if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &el_list)) {
520 return NULL;
523 PyErr_LDB_OR_RAISE(py_ldb, ldb);
525 if (!PyList_Check(el_list)) {
526 PyErr_Format(PyExc_TypeError, "ldif_elements must be a list");
527 return NULL;
530 schema = dsdb_get_schema(ldb, NULL);
531 if (!schema) {
532 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
533 return NULL;
536 a = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
537 if (a == NULL) {
538 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
539 return NULL;
542 dsdb_syntax_ctx_init(&syntax_ctx, ldb, schema);
543 syntax_ctx.is_schema_nc = false;
545 tmp_ctx = talloc_new(ldb);
546 if (tmp_ctx == NULL) {
547 PyErr_NoMemory();
548 return NULL;
551 el = talloc_zero(tmp_ctx, struct ldb_message_element);
552 if (el == NULL) {
553 PyErr_NoMemory();
554 talloc_free(tmp_ctx);
555 return NULL;
558 el->name = ldap_display_name;
559 el->num_values = PyList_Size(el_list);
561 el->values = talloc_array(el, struct ldb_val, el->num_values);
562 if (el->values == NULL) {
563 PyErr_NoMemory();
564 talloc_free(tmp_ctx);
565 return NULL;
568 for (i = 0; i < el->num_values; i++) {
569 PyObject *item = PyList_GetItem(el_list, i);
570 if (!PyString_Check(item)) {
571 PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
572 return NULL;
574 el->values[i].data = (uint8_t *)PyString_AsString(item);
575 el->values[i].length = PyString_Size(item);
578 attr = talloc_zero(tmp_ctx, struct drsuapi_DsReplicaAttribute);
579 if (attr == NULL) {
580 PyErr_NoMemory();
581 talloc_free(tmp_ctx);
582 return NULL;
585 werr = a->syntax->ldb_to_drsuapi(&syntax_ctx, a, el, attr, attr);
586 PyErr_WERROR_IS_ERR_RAISE(werr);
588 ret = py_return_ndr_struct("samba.dcerpc.drsuapi", "DsReplicaAttribute", attr, attr);
590 talloc_free(tmp_ctx);
592 return ret;
597 normalise a ldb attribute list
599 static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
601 PyObject *py_ldb, *el_list, *ret;
602 struct ldb_context *ldb;
603 char *ldap_display_name;
604 const struct dsdb_attribute *a;
605 struct dsdb_schema *schema;
606 struct dsdb_syntax_ctx syntax_ctx;
607 struct ldb_message_element *el;
608 struct drsuapi_DsReplicaAttribute *attr;
609 TALLOC_CTX *tmp_ctx;
610 WERROR werr;
611 Py_ssize_t i;
613 if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &el_list)) {
614 return NULL;
617 PyErr_LDB_OR_RAISE(py_ldb, ldb);
619 if (!PyList_Check(el_list)) {
620 PyErr_Format(PyExc_TypeError, "ldif_elements must be a list");
621 return NULL;
624 schema = dsdb_get_schema(ldb, NULL);
625 if (!schema) {
626 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
627 return NULL;
630 a = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
631 if (a == NULL) {
632 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
633 return NULL;
636 dsdb_syntax_ctx_init(&syntax_ctx, ldb, schema);
637 syntax_ctx.is_schema_nc = false;
639 tmp_ctx = talloc_new(ldb);
640 if (tmp_ctx == NULL) {
641 PyErr_NoMemory();
642 return NULL;
645 el = talloc_zero(tmp_ctx, struct ldb_message_element);
646 if (el == NULL) {
647 PyErr_NoMemory();
648 talloc_free(tmp_ctx);
649 return NULL;
652 el->name = ldap_display_name;
653 el->num_values = PyList_Size(el_list);
655 el->values = talloc_array(el, struct ldb_val, el->num_values);
656 if (el->values == NULL) {
657 PyErr_NoMemory();
658 talloc_free(tmp_ctx);
659 return NULL;
662 for (i = 0; i < el->num_values; i++) {
663 PyObject *item = PyList_GetItem(el_list, i);
664 if (!PyString_Check(item)) {
665 PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
666 return NULL;
668 el->values[i].data = (uint8_t *)PyString_AsString(item);
669 el->values[i].length = PyString_Size(item);
672 /* first run ldb_to_drsuapi, then convert back again. This has
673 * the effect of normalising the attributes
676 attr = talloc_zero(tmp_ctx, struct drsuapi_DsReplicaAttribute);
677 if (attr == NULL) {
678 PyErr_NoMemory();
679 talloc_free(tmp_ctx);
680 return NULL;
683 werr = a->syntax->ldb_to_drsuapi(&syntax_ctx, a, el, attr, attr);
684 PyErr_WERROR_IS_ERR_RAISE(werr);
686 /* now convert back again */
687 werr = a->syntax->drsuapi_to_ldb(&syntax_ctx, a, attr, el, el);
688 PyErr_WERROR_IS_ERR_RAISE(werr);
690 ret = py_return_ndr_struct("ldb", "MessageElement", el, el);
692 talloc_free(tmp_ctx);
694 return ret;
698 static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args)
700 PyObject *py_ldb, *py_guid;
701 bool ret;
702 struct GUID guid;
703 struct ldb_context *ldb;
704 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_guid))
705 return NULL;
707 PyErr_LDB_OR_RAISE(py_ldb, ldb);
708 GUID_from_string(PyString_AsString(py_guid), &guid);
710 ret = samdb_set_ntds_invocation_id(ldb, &guid);
711 if (!ret) {
712 PyErr_SetString(PyExc_RuntimeError, "set_ntds_invocation_id failed");
713 return NULL;
715 Py_RETURN_NONE;
718 static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args)
720 PyObject *py_ldb, *result;
721 struct ldb_context *ldb;
722 const struct GUID *guid;
723 char *retstr;
725 if (!PyArg_ParseTuple(args, "O", &py_ldb)) {
726 return NULL;
729 PyErr_LDB_OR_RAISE(py_ldb, ldb);
731 guid = samdb_ntds_objectGUID(ldb);
732 if (guid == NULL) {
733 PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS GUID");
734 return NULL;
737 retstr = GUID_string(NULL, guid);
738 if (retstr == NULL) {
739 PyErr_NoMemory();
740 return NULL;
742 result = PyString_FromString(retstr);
743 talloc_free(retstr);
744 return result;
747 static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args)
749 PyObject *py_ldb;
750 struct ldb_context *ldb;
751 int ret;
752 if (!PyArg_ParseTuple(args, "O", &py_ldb))
753 return NULL;
755 PyErr_LDB_OR_RAISE(py_ldb, ldb);
757 ret = dsdb_set_global_schema(ldb);
758 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
760 Py_RETURN_NONE;
763 static PyObject *py_dsdb_load_partition_usn(PyObject *self, PyObject *args)
765 PyObject *py_dn, *py_ldb, *result;
766 struct ldb_dn *dn;
767 uint64_t highest_uSN, urgent_uSN;
768 struct ldb_context *ldb;
769 TALLOC_CTX *mem_ctx;
770 int ret;
772 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_dn)) {
773 return NULL;
776 PyErr_LDB_OR_RAISE(py_ldb, ldb);
778 mem_ctx = talloc_new(NULL);
779 if (mem_ctx == NULL) {
780 PyErr_NoMemory();
781 return NULL;
784 if (!pyldb_Object_AsDn(mem_ctx, py_dn, ldb, &dn)) {
785 talloc_free(mem_ctx);
786 return NULL;
789 ret = dsdb_load_partition_usn(ldb, dn, &highest_uSN, &urgent_uSN);
790 if (ret != LDB_SUCCESS) {
791 PyErr_Format(PyExc_RuntimeError,
792 "Failed to load partition [%s] uSN - %s",
793 ldb_dn_get_linearized(dn),
794 ldb_errstring(ldb));
795 talloc_free(mem_ctx);
796 return NULL;
799 talloc_free(mem_ctx);
801 result = PyDict_New();
803 PyDict_SetItemString(result, "uSNHighest", PyInt_FromLong((uint64_t)highest_uSN));
804 PyDict_SetItemString(result, "uSNUrgent", PyInt_FromLong((uint64_t)urgent_uSN));
807 return result;
810 static PyObject *py_dsdb_set_am_rodc(PyObject *self, PyObject *args)
812 PyObject *py_ldb;
813 bool ret;
814 struct ldb_context *ldb;
815 int py_val;
817 if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &py_val))
818 return NULL;
820 PyErr_LDB_OR_RAISE(py_ldb, ldb);
821 ret = samdb_set_am_rodc(ldb, (bool)py_val);
822 if (!ret) {
823 PyErr_SetString(PyExc_RuntimeError, "set_am_rodc failed");
824 return NULL;
826 Py_RETURN_NONE;
829 static PyObject *py_dsdb_set_schema_from_ldif(PyObject *self, PyObject *args)
831 WERROR result;
832 char *pf, *df, *dn;
833 PyObject *py_ldb;
834 struct ldb_context *ldb;
836 if (!PyArg_ParseTuple(args, "Osss", &py_ldb, &pf, &df, &dn))
837 return NULL;
839 PyErr_LDB_OR_RAISE(py_ldb, ldb);
841 result = dsdb_set_schema_from_ldif(ldb, pf, df, dn);
842 PyErr_WERROR_IS_ERR_RAISE(result);
844 Py_RETURN_NONE;
847 static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
849 PyObject *py_ldb;
850 struct ldb_context *ldb;
851 PyObject *py_from_ldb;
852 struct ldb_context *from_ldb;
853 struct dsdb_schema *schema;
854 int ret;
855 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_from_ldb))
856 return NULL;
858 PyErr_LDB_OR_RAISE(py_ldb, ldb);
860 PyErr_LDB_OR_RAISE(py_from_ldb, from_ldb);
862 schema = dsdb_get_schema(from_ldb, NULL);
863 if (!schema) {
864 PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on 'from' ldb!\n");
865 return NULL;
868 ret = dsdb_reference_schema(ldb, schema, true);
869 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
871 Py_RETURN_NONE;
874 static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObject *args)
876 PyObject *py_ldb;
877 struct ldb_context *ldb;
878 WERROR result;
879 struct dsdb_schema *schema;
881 if (!PyArg_ParseTuple(args, "O", &py_ldb))
882 return NULL;
884 PyErr_LDB_OR_RAISE(py_ldb, ldb);
886 schema = dsdb_get_schema(ldb, NULL);
887 if (!schema) {
888 PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on ldb!\n");
889 return NULL;
892 result = dsdb_write_prefixes_from_schema_to_ldb(NULL, ldb, schema);
893 PyErr_WERROR_IS_ERR_RAISE(result);
895 Py_RETURN_NONE;
899 static PyObject *py_dsdb_get_partitions_dn(PyObject *self, PyObject *args)
901 struct ldb_context *ldb;
902 struct ldb_dn *dn;
903 PyObject *py_ldb, *ret;
904 PyObject *mod;
906 mod = PyImport_ImportModule("ldb");
908 if (!PyArg_ParseTuple(args, "O", &py_ldb))
909 return NULL;
911 PyErr_LDB_OR_RAISE(py_ldb, ldb);
913 dn = samdb_partitions_dn(ldb, NULL);
914 if (dn == NULL) {
915 PyErr_NoMemory();
916 return NULL;
918 ret = pyldb_Dn_FromDn(dn);
919 talloc_free(dn);
920 return ret;
925 call into samdb_rodc()
927 static PyObject *py_dsdb_am_rodc(PyObject *self, PyObject *args)
929 PyObject *py_ldb;
930 struct ldb_context *ldb;
931 int ret;
932 bool am_rodc;
934 if (!PyArg_ParseTuple(args, "O", &py_ldb))
935 return NULL;
937 PyErr_LDB_OR_RAISE(py_ldb, ldb);
939 ret = samdb_rodc(ldb, &am_rodc);
940 if (ret != LDB_SUCCESS) {
941 PyErr_SetString(PyExc_RuntimeError, ldb_errstring(ldb));
942 return NULL;
945 return PyBool_FromLong(am_rodc);
949 call into samdb_is_pdc()
951 static PyObject *py_dsdb_am_pdc(PyObject *self, PyObject *args)
953 PyObject *py_ldb;
954 struct ldb_context *ldb;
955 bool am_pdc;
957 if (!PyArg_ParseTuple(args, "O", &py_ldb))
958 return NULL;
960 PyErr_LDB_OR_RAISE(py_ldb, ldb);
962 am_pdc = samdb_is_pdc(ldb);
963 return PyBool_FromLong(am_pdc);
967 static PyMethodDef py_dsdb_methods[] = {
968 { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
969 METH_VARARGS, "Get the server site name as a string"},
970 { "_dsdb_convert_schema_to_openldap",
971 (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS,
972 "dsdb_convert_schema_to_openldap(ldb, target_str, mapping) -> str\n"
973 "Create an OpenLDAP schema from a schema." },
974 { "_samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid,
975 METH_VARARGS,
976 "samdb_set_domain_sid(samdb, sid)\n"
977 "Set SID of domain to use." },
978 { "_samdb_get_domain_sid", (PyCFunction)py_samdb_get_domain_sid,
979 METH_VARARGS,
980 "samdb_get_domain_sid(samdb)\n"
981 "Get SID of domain in use." },
982 { "_samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id,
983 METH_VARARGS, "get the NTDS invocation ID GUID as a string"},
984 { "_samdb_set_ntds_settings_dn", (PyCFunction)py_samdb_set_ntds_settings_dn,
985 METH_VARARGS,
986 "samdb_set_ntds_settings_dn(samdb, ntds_settings_dn)\n"
987 "Set NTDS Settings DN for this LDB (allows it to be set before the DB fully exists)." },
988 { "_dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid,
989 METH_VARARGS, NULL },
990 { "_dsdb_get_attid_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_attid_from_lDAPDisplayName,
991 METH_VARARGS, NULL },
992 { "_dsdb_get_syntax_oid_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_syntax_oid_from_lDAPDisplayName,
993 METH_VARARGS, NULL },
994 { "_dsdb_get_systemFlags_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_systemFlags_from_lDAPDisplayName,
995 METH_VARARGS, NULL },
996 { "_dsdb_get_linkId_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_linkId_from_lDAPDisplayName,
997 METH_VARARGS, NULL },
998 { "_dsdb_get_lDAPDisplayName_by_attid", (PyCFunction)py_dsdb_get_lDAPDisplayName_by_attid,
999 METH_VARARGS, NULL },
1000 { "_dsdb_get_backlink_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_backlink_from_lDAPDisplayName,
1001 METH_VARARGS, NULL },
1002 { "_dsdb_set_ntds_invocation_id",
1003 (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS,
1004 NULL },
1005 { "_samdb_ntds_objectGUID", (PyCFunction)py_samdb_ntds_objectGUID,
1006 METH_VARARGS, "get the NTDS objectGUID as a string"},
1007 { "_dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema,
1008 METH_VARARGS, NULL },
1009 { "_dsdb_load_partition_usn", (PyCFunction)py_dsdb_load_partition_usn,
1010 METH_VARARGS,
1011 "get uSNHighest and uSNUrgent from the partition @REPLCHANGED"},
1012 { "_dsdb_set_am_rodc",
1013 (PyCFunction)py_dsdb_set_am_rodc, METH_VARARGS,
1014 NULL },
1015 { "_am_rodc",
1016 (PyCFunction)py_dsdb_am_rodc, METH_VARARGS,
1017 NULL },
1018 { "_am_pdc",
1019 (PyCFunction)py_dsdb_am_pdc, METH_VARARGS,
1020 NULL },
1021 { "_dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS,
1022 NULL },
1023 { "_dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS,
1024 NULL },
1025 { "_dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS,
1026 NULL },
1027 { "_dsdb_get_partitions_dn", (PyCFunction)py_dsdb_get_partitions_dn, METH_VARARGS, NULL },
1028 { "_dsdb_DsReplicaAttribute", (PyCFunction)py_dsdb_DsReplicaAttribute, METH_VARARGS, NULL },
1029 { "_dsdb_normalise_attributes", (PyCFunction)py_dsdb_normalise_attributes, METH_VARARGS, NULL },
1030 { NULL }
1033 void initdsdb(void)
1035 PyObject *m;
1037 m = Py_InitModule3("dsdb", py_dsdb_methods,
1038 "Python bindings for the directory service databases.");
1039 if (m == NULL)
1040 return;
1042 #define ADD_DSDB_FLAG(val) PyModule_AddObject(m, #val, PyInt_FromLong(val))
1044 /* "userAccountControl" flags */
1045 ADD_DSDB_FLAG(UF_NORMAL_ACCOUNT);
1046 ADD_DSDB_FLAG(UF_TEMP_DUPLICATE_ACCOUNT);
1047 ADD_DSDB_FLAG(UF_SERVER_TRUST_ACCOUNT);
1048 ADD_DSDB_FLAG(UF_WORKSTATION_TRUST_ACCOUNT);
1049 ADD_DSDB_FLAG(UF_INTERDOMAIN_TRUST_ACCOUNT);
1050 ADD_DSDB_FLAG(UF_PASSWD_NOTREQD);
1051 ADD_DSDB_FLAG(UF_ACCOUNTDISABLE);
1053 ADD_DSDB_FLAG(UF_SCRIPT);
1054 ADD_DSDB_FLAG(UF_ACCOUNTDISABLE);
1055 ADD_DSDB_FLAG(UF_00000004);
1056 ADD_DSDB_FLAG(UF_HOMEDIR_REQUIRED);
1057 ADD_DSDB_FLAG(UF_LOCKOUT);
1058 ADD_DSDB_FLAG(UF_PASSWD_NOTREQD);
1059 ADD_DSDB_FLAG(UF_PASSWD_CANT_CHANGE);
1060 ADD_DSDB_FLAG(UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED);
1061 ADD_DSDB_FLAG(UF_TEMP_DUPLICATE_ACCOUNT);
1062 ADD_DSDB_FLAG(UF_NORMAL_ACCOUNT);
1063 ADD_DSDB_FLAG(UF_00000400);
1064 ADD_DSDB_FLAG(UF_INTERDOMAIN_TRUST_ACCOUNT);
1065 ADD_DSDB_FLAG(UF_WORKSTATION_TRUST_ACCOUNT);
1066 ADD_DSDB_FLAG(UF_SERVER_TRUST_ACCOUNT);
1067 ADD_DSDB_FLAG(UF_00004000);
1068 ADD_DSDB_FLAG(UF_00008000);
1069 ADD_DSDB_FLAG(UF_DONT_EXPIRE_PASSWD);
1070 ADD_DSDB_FLAG(UF_MNS_LOGON_ACCOUNT);
1071 ADD_DSDB_FLAG(UF_SMARTCARD_REQUIRED);
1072 ADD_DSDB_FLAG(UF_TRUSTED_FOR_DELEGATION);
1073 ADD_DSDB_FLAG(UF_NOT_DELEGATED);
1074 ADD_DSDB_FLAG(UF_USE_DES_KEY_ONLY);
1075 ADD_DSDB_FLAG(UF_DONT_REQUIRE_PREAUTH);
1076 ADD_DSDB_FLAG(UF_PASSWORD_EXPIRED);
1077 ADD_DSDB_FLAG(UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION);
1078 ADD_DSDB_FLAG(UF_NO_AUTH_DATA_REQUIRED);
1079 ADD_DSDB_FLAG(UF_PARTIAL_SECRETS_ACCOUNT);
1081 /* groupType flags */
1082 ADD_DSDB_FLAG(GTYPE_SECURITY_BUILTIN_LOCAL_GROUP);
1083 ADD_DSDB_FLAG(GTYPE_SECURITY_GLOBAL_GROUP);
1084 ADD_DSDB_FLAG(GTYPE_SECURITY_DOMAIN_LOCAL_GROUP);
1085 ADD_DSDB_FLAG(GTYPE_SECURITY_UNIVERSAL_GROUP);
1086 ADD_DSDB_FLAG(GTYPE_DISTRIBUTION_GLOBAL_GROUP);
1087 ADD_DSDB_FLAG(GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP);
1088 ADD_DSDB_FLAG(GTYPE_DISTRIBUTION_UNIVERSAL_GROUP);
1090 /* "sAMAccountType" flags */
1091 ADD_DSDB_FLAG(ATYPE_NORMAL_ACCOUNT);
1092 ADD_DSDB_FLAG(ATYPE_WORKSTATION_TRUST);
1093 ADD_DSDB_FLAG(ATYPE_INTERDOMAIN_TRUST);
1094 ADD_DSDB_FLAG(ATYPE_SECURITY_GLOBAL_GROUP);
1095 ADD_DSDB_FLAG(ATYPE_SECURITY_LOCAL_GROUP);
1096 ADD_DSDB_FLAG(ATYPE_SECURITY_UNIVERSAL_GROUP);
1097 ADD_DSDB_FLAG(ATYPE_DISTRIBUTION_GLOBAL_GROUP);
1098 ADD_DSDB_FLAG(ATYPE_DISTRIBUTION_LOCAL_GROUP);
1099 ADD_DSDB_FLAG(ATYPE_DISTRIBUTION_UNIVERSAL_GROUP);
1101 /* "domainFunctionality", "forestFunctionality" flags in the rootDSE */
1102 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2000);
1103 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2003_MIXED);
1104 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2003);
1105 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2008);
1106 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2008_R2);
1108 /* nc replica flags */
1109 ADD_DSDB_FLAG(INSTANCE_TYPE_IS_NC_HEAD);
1110 ADD_DSDB_FLAG(INSTANCE_TYPE_UNINSTANT);
1111 ADD_DSDB_FLAG(INSTANCE_TYPE_WRITE);
1112 ADD_DSDB_FLAG(INSTANCE_TYPE_NC_ABOVE);
1113 ADD_DSDB_FLAG(INSTANCE_TYPE_NC_COMING);
1114 ADD_DSDB_FLAG(INSTANCE_TYPE_NC_GOING);
1116 /* "systemFlags" */
1117 ADD_DSDB_FLAG(SYSTEM_FLAG_CR_NTDS_NC);
1118 ADD_DSDB_FLAG(SYSTEM_FLAG_CR_NTDS_DOMAIN);
1119 ADD_DSDB_FLAG(SYSTEM_FLAG_CR_NTDS_NOT_GC_REPLICATED);
1120 ADD_DSDB_FLAG(SYSTEM_FLAG_SCHEMA_BASE_OBJECT);
1121 ADD_DSDB_FLAG(SYSTEM_FLAG_ATTR_IS_RDN);
1122 ADD_DSDB_FLAG(SYSTEM_FLAG_DISALLOW_MOVE_ON_DELETE);
1123 ADD_DSDB_FLAG(SYSTEM_FLAG_DOMAIN_DISALLOW_MOVE);
1124 ADD_DSDB_FLAG(SYSTEM_FLAG_DOMAIN_DISALLOW_RENAME);
1125 ADD_DSDB_FLAG(SYSTEM_FLAG_CONFIG_ALLOW_LIMITED_MOVE);
1126 ADD_DSDB_FLAG(SYSTEM_FLAG_CONFIG_ALLOW_MOVE);
1127 ADD_DSDB_FLAG(SYSTEM_FLAG_CONFIG_ALLOW_RENAME);
1128 ADD_DSDB_FLAG(SYSTEM_FLAG_DISALLOW_DELETE);
1130 /* Kerberos encryption type constants */
1131 ADD_DSDB_FLAG(ENC_ALL_TYPES);
1132 ADD_DSDB_FLAG(ENC_CRC32);
1133 ADD_DSDB_FLAG(ENC_RSA_MD5);
1134 ADD_DSDB_FLAG(ENC_RC4_HMAC_MD5);
1135 ADD_DSDB_FLAG(ENC_HMAC_SHA1_96_AES128);
1136 ADD_DSDB_FLAG(ENC_HMAC_SHA1_96_AES256);
1138 ADD_DSDB_FLAG(SEARCH_FLAG_ATTINDEX);
1139 ADD_DSDB_FLAG(SEARCH_FLAG_PDNTATTINDEX);
1140 ADD_DSDB_FLAG(SEARCH_FLAG_ANR);
1141 ADD_DSDB_FLAG(SEARCH_FLAG_PRESERVEONDELETE);
1142 ADD_DSDB_FLAG(SEARCH_FLAG_COPY);
1143 ADD_DSDB_FLAG(SEARCH_FLAG_TUPLEINDEX);
1144 ADD_DSDB_FLAG(SEARCH_FLAG_SUBTREEATTRINDEX);
1145 ADD_DSDB_FLAG(SEARCH_FLAG_CONFIDENTIAL);
1146 ADD_DSDB_FLAG(SEARCH_FLAG_NEVERVALUEAUDIT);
1147 ADD_DSDB_FLAG(SEARCH_FLAG_RODC_ATTRIBUTE);
1149 ADD_DSDB_FLAG(DS_FLAG_ATTR_NOT_REPLICATED);
1150 ADD_DSDB_FLAG(DS_FLAG_ATTR_REQ_PARTIAL_SET_MEMBER);
1151 ADD_DSDB_FLAG(DS_FLAG_ATTR_IS_CONSTRUCTED);
1153 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED);
1154 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED);
1155 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED);
1156 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED);
1157 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED);
1158 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_GROUP_CACHING_ENABLED);
1159 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_FORCE_KCC_WHISTLER_BEHAVIOR);
1160 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED);
1161 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_SCHEDULE_HASHING_ENABLED);
1162 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_REDUNDANT_SERVER_TOPOLOGY_ENABLED);
1164 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_IS_GC);
1165 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_INBOUND_REPL);
1166 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL);
1167 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE);
1168 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_SPN_REGISTRATION);
1170 ADD_DSDB_FLAG(NTDSCONN_KCC_GC_TOPOLOGY);
1171 ADD_DSDB_FLAG(NTDSCONN_KCC_RING_TOPOLOGY);
1172 ADD_DSDB_FLAG(NTDSCONN_KCC_MINIMIZE_HOPS_TOPOLOGY);
1173 ADD_DSDB_FLAG(NTDSCONN_KCC_STALE_SERVERS_TOPOLOGY);
1174 ADD_DSDB_FLAG(NTDSCONN_KCC_OSCILLATING_CONNECTION_TOPOLOGY);
1175 ADD_DSDB_FLAG(NTDSCONN_KCC_INTERSITE_GC_TOPOLOGY);
1176 ADD_DSDB_FLAG(NTDSCONN_KCC_INTERSITE_TOPOLOGY);
1177 ADD_DSDB_FLAG(NTDSCONN_KCC_SERVER_FAILOVER_TOPOLOGY);
1178 ADD_DSDB_FLAG(NTDSCONN_KCC_SITE_FAILOVER_TOPOLOGY);
1179 ADD_DSDB_FLAG(NTDSCONN_KCC_REDUNDANT_SERVER_TOPOLOGY);
1181 ADD_DSDB_FLAG(NTDSCONN_OPT_IS_GENERATED);
1182 ADD_DSDB_FLAG(NTDSCONN_OPT_TWOWAY_SYNC);
1183 ADD_DSDB_FLAG(NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT);
1184 ADD_DSDB_FLAG(NTDSCONN_OPT_USE_NOTIFY);
1185 ADD_DSDB_FLAG(NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION);
1186 ADD_DSDB_FLAG(NTDSCONN_OPT_USER_OWNED_SCHEDULE);
1187 ADD_DSDB_FLAG(NTDSCONN_OPT_RODC_TOPOLOGY);
1189 /* GPO policy flags */
1190 ADD_DSDB_FLAG(GPLINK_OPT_DISABLE);
1191 ADD_DSDB_FLAG(GPLINK_OPT_ENFORCE);
1192 ADD_DSDB_FLAG(GPO_FLAG_USER_DISABLE);
1193 ADD_DSDB_FLAG(GPO_FLAG_MACHINE_DISABLE);
1194 ADD_DSDB_FLAG(GPO_INHERIT);
1195 ADD_DSDB_FLAG(GPO_BLOCK_INHERITANCE);
1197 #define ADD_DSDB_STRING(val) PyModule_AddObject(m, #val, PyString_FromString(val))
1199 ADD_DSDB_STRING(DSDB_SYNTAX_BINARY_DN);
1200 ADD_DSDB_STRING(DSDB_SYNTAX_STRING_DN);
1201 ADD_DSDB_STRING(DSDB_SYNTAX_OR_NAME);
1202 ADD_DSDB_STRING(DSDB_CONTROL_DBCHECK);