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/>.
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"
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
;
41 /* FIXME: These should be in a header file somewhere */
42 #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
43 if (!py_check_dcerpc_type(py_ldb, "ldb", "Ldb")) { \
44 PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \
47 ldb = pyldb_Ldb_AsLdbContext(py_ldb);
49 #define PyErr_LDB_DN_OR_RAISE(py_ldb_dn, dn) \
50 if (!py_check_dcerpc_type(py_ldb_dn, "ldb", "Dn")) { \
51 PyErr_SetString(py_ldb_get_exception(), "ldb Dn object required"); \
54 dn = pyldb_Dn_AsDn(py_ldb_dn);
56 static PyObject
*py_ldb_get_exception(void)
58 PyObject
*mod
= PyImport_ImportModule("ldb");
62 return PyObject_GetAttrString(mod
, "LdbError");
65 static void PyErr_SetLdbError(PyObject
*error
, int ret
, struct ldb_context
*ldb_ctx
)
67 if (ret
== LDB_ERR_PYTHON_EXCEPTION
)
68 return; /* Python exception should already be set, just keep that */
70 PyErr_SetObject(error
,
71 Py_BuildValue(discard_const_p(char, "(i,s)"), ret
,
72 ldb_ctx
== NULL
?ldb_strerror(ret
):ldb_errstring(ldb_ctx
)));
75 static PyObject
*py_samdb_server_site_name(PyObject
*self
, PyObject
*args
)
77 PyObject
*py_ldb
, *result
;
78 struct ldb_context
*ldb
;
82 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
85 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
87 mem_ctx
= talloc_new(NULL
);
88 if (mem_ctx
== NULL
) {
93 site
= samdb_server_site_name(ldb
, mem_ctx
);
95 PyErr_SetString(PyExc_RuntimeError
, "Failed to find server site");
100 result
= PyString_FromString(site
);
101 talloc_free(mem_ctx
);
105 static PyObject
*py_dsdb_convert_schema_to_openldap(PyObject
*self
,
108 char *target_str
, *mapping
;
110 struct ldb_context
*ldb
;
114 if (!PyArg_ParseTuple(args
, "Oss", &py_ldb
, &target_str
, &mapping
))
117 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
119 retstr
= dsdb_convert_schema_to_openldap(ldb
, target_str
, mapping
);
120 if (retstr
== NULL
) {
121 PyErr_SetString(PyExc_RuntimeError
,
122 "dsdb_convert_schema_to_openldap failed");
126 ret
= PyString_FromString(retstr
);
131 static PyObject
*py_samdb_set_domain_sid(PyLdbObject
*self
, PyObject
*args
)
133 PyObject
*py_ldb
, *py_sid
;
134 struct ldb_context
*ldb
;
138 if (!PyArg_ParseTuple(args
, "OO", &py_ldb
, &py_sid
))
141 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
143 sid
= dom_sid_parse_talloc(NULL
, PyString_AsString(py_sid
));
149 ret
= samdb_set_domain_sid(ldb
, sid
);
152 PyErr_SetString(PyExc_RuntimeError
, "set_domain_sid failed");
158 static PyObject
*py_samdb_set_ntds_settings_dn(PyLdbObject
*self
, PyObject
*args
)
160 PyObject
*py_ldb
, *py_ntds_settings_dn
;
161 struct ldb_context
*ldb
;
162 struct ldb_dn
*ntds_settings_dn
;
166 if (!PyArg_ParseTuple(args
, "OO", &py_ldb
, &py_ntds_settings_dn
))
169 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
171 tmp_ctx
= talloc_new(NULL
);
172 if (tmp_ctx
== NULL
) {
177 if (!pyldb_Object_AsDn(tmp_ctx
, py_ntds_settings_dn
, ldb
, &ntds_settings_dn
)) {
178 /* exception thrown by "pyldb_Object_AsDn" */
179 talloc_free(tmp_ctx
);
183 ret
= samdb_set_ntds_settings_dn(ldb
, ntds_settings_dn
);
184 talloc_free(tmp_ctx
);
186 PyErr_SetString(PyExc_RuntimeError
, "set_ntds_settings_dn failed");
192 static PyObject
*py_samdb_get_domain_sid(PyLdbObject
*self
, PyObject
*args
)
195 struct ldb_context
*ldb
;
196 const struct dom_sid
*sid
;
200 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
203 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
205 sid
= samdb_domain_sid(ldb
);
207 PyErr_SetString(PyExc_RuntimeError
, "samdb_domain_sid failed");
211 retstr
= dom_sid_string(NULL
, sid
);
212 if (retstr
== NULL
) {
216 ret
= PyString_FromString(retstr
);
221 static PyObject
*py_samdb_ntds_invocation_id(PyObject
*self
, PyObject
*args
)
223 PyObject
*py_ldb
, *result
;
224 struct ldb_context
*ldb
;
225 const struct GUID
*guid
;
228 if (!PyArg_ParseTuple(args
, "O", &py_ldb
)) {
232 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
234 guid
= samdb_ntds_invocation_id(ldb
);
236 PyErr_SetString(PyExc_RuntimeError
,
237 "Failed to find NTDS invocation ID");
241 retstr
= GUID_string(NULL
, guid
);
242 if (retstr
== NULL
) {
246 result
= PyString_FromString(retstr
);
251 static PyObject
*py_dsdb_get_oid_from_attid(PyObject
*self
, PyObject
*args
)
254 struct ldb_context
*ldb
;
256 struct dsdb_schema
*schema
;
262 if (!PyArg_ParseTuple(args
, "Oi", &py_ldb
, &attid
))
265 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
267 mem_ctx
= talloc_new(NULL
);
273 schema
= dsdb_get_schema(ldb
, mem_ctx
);
275 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb \n");
276 talloc_free(mem_ctx
);
280 status
= dsdb_schema_pfm_oid_from_attid(schema
->prefixmap
, attid
,
282 if (!W_ERROR_IS_OK(status
)) {
283 PyErr_SetWERROR(status
);
284 talloc_free(mem_ctx
);
288 ret
= PyString_FromString(oid
);
290 talloc_free(mem_ctx
);
296 static PyObject
*py_dsdb_get_attid_from_lDAPDisplayName(PyObject
*self
, PyObject
*args
)
298 PyObject
*py_ldb
, *is_schema_nc
;
299 struct ldb_context
*ldb
;
300 struct dsdb_schema
*schema
;
301 const char *ldap_display_name
;
302 bool schema_nc
= false;
303 const struct dsdb_attribute
*a
;
306 if (!PyArg_ParseTuple(args
, "OsO", &py_ldb
, &ldap_display_name
, &is_schema_nc
))
309 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
312 if (!PyBool_Check(is_schema_nc
)) {
313 PyErr_SetString(PyExc_TypeError
, "Expected boolean is_schema_nc");
316 if (is_schema_nc
== Py_True
) {
321 schema
= dsdb_get_schema(ldb
, NULL
);
324 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
328 a
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
330 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
334 attid
= dsdb_attribute_get_attid(a
, schema_nc
);
336 return PyLong_FromUnsignedLong(attid
);
340 return the systemFlags as int from the attribute name
342 static PyObject
*py_dsdb_get_systemFlags_from_lDAPDisplayName(PyObject
*self
, PyObject
*args
)
345 struct ldb_context
*ldb
;
346 struct dsdb_schema
*schema
;
347 const char *ldap_display_name
;
348 const struct dsdb_attribute
*attribute
;
350 if (!PyArg_ParseTuple(args
, "Os", &py_ldb
, &ldap_display_name
))
353 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
355 schema
= dsdb_get_schema(ldb
, NULL
);
358 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
362 attribute
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
363 if (attribute
== NULL
) {
364 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
368 return PyInt_FromLong(attribute
->systemFlags
);
372 return the linkID from the attribute name
374 static PyObject
*py_dsdb_get_linkId_from_lDAPDisplayName(PyObject
*self
, PyObject
*args
)
377 struct ldb_context
*ldb
;
378 struct dsdb_schema
*schema
;
379 const char *ldap_display_name
;
380 const struct dsdb_attribute
*attribute
;
382 if (!PyArg_ParseTuple(args
, "Os", &py_ldb
, &ldap_display_name
))
385 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
387 schema
= dsdb_get_schema(ldb
, NULL
);
390 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
394 attribute
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
395 if (attribute
== NULL
) {
396 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
400 return PyInt_FromLong(attribute
->linkID
);
404 return the backlink attribute name (if any) for an attribute
406 static PyObject
*py_dsdb_get_backlink_from_lDAPDisplayName(PyObject
*self
, PyObject
*args
)
409 struct ldb_context
*ldb
;
410 struct dsdb_schema
*schema
;
411 const char *ldap_display_name
;
412 const struct dsdb_attribute
*attribute
, *target_attr
;
414 if (!PyArg_ParseTuple(args
, "Os", &py_ldb
, &ldap_display_name
))
417 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
419 schema
= dsdb_get_schema(ldb
, NULL
);
422 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
426 attribute
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
427 if (attribute
== NULL
) {
428 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
432 if (attribute
->linkID
== 0) {
436 target_attr
= dsdb_attribute_by_linkID(schema
, attribute
->linkID
^ 1);
437 if (target_attr
== NULL
) {
438 /* when we add pseudo-backlinks we'll need to handle
443 return PyString_FromString(target_attr
->lDAPDisplayName
);
447 static PyObject
*py_dsdb_get_lDAPDisplayName_by_attid(PyObject
*self
, PyObject
*args
)
450 struct ldb_context
*ldb
;
451 struct dsdb_schema
*schema
;
452 const struct dsdb_attribute
*a
;
455 if (!PyArg_ParseTuple(args
, "Oi", &py_ldb
, &attid
))
458 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
460 schema
= dsdb_get_schema(ldb
, NULL
);
463 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
467 a
= dsdb_attribute_by_attributeID_id(schema
, attid
);
469 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '0x%08x'", attid
);
473 return PyString_FromString(a
->lDAPDisplayName
);
478 return the attribute syntax oid as a string from the attribute name
480 static PyObject
*py_dsdb_get_syntax_oid_from_lDAPDisplayName(PyObject
*self
, PyObject
*args
)
483 struct ldb_context
*ldb
;
484 struct dsdb_schema
*schema
;
485 const char *ldap_display_name
;
486 const struct dsdb_attribute
*attribute
;
488 if (!PyArg_ParseTuple(args
, "Os", &py_ldb
, &ldap_display_name
))
491 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
493 schema
= dsdb_get_schema(ldb
, NULL
);
496 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
500 attribute
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
501 if (attribute
== NULL
) {
502 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
506 return PyString_FromString(attribute
->syntax
->ldap_oid
);
510 convert a python string to a DRSUAPI drsuapi_DsReplicaAttribute attribute
512 static PyObject
*py_dsdb_DsReplicaAttribute(PyObject
*self
, PyObject
*args
)
514 PyObject
*py_ldb
, *el_list
, *ret
;
515 struct ldb_context
*ldb
;
516 char *ldap_display_name
;
517 const struct dsdb_attribute
*a
;
518 struct dsdb_schema
*schema
;
519 struct dsdb_syntax_ctx syntax_ctx
;
520 struct ldb_message_element
*el
;
521 struct drsuapi_DsReplicaAttribute
*attr
;
526 if (!PyArg_ParseTuple(args
, "OsO", &py_ldb
, &ldap_display_name
, &el_list
)) {
530 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
532 if (!PyList_Check(el_list
)) {
533 PyErr_Format(PyExc_TypeError
, "ldif_elements must be a list");
537 schema
= dsdb_get_schema(ldb
, NULL
);
539 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
543 a
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
545 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
549 dsdb_syntax_ctx_init(&syntax_ctx
, ldb
, schema
);
550 syntax_ctx
.is_schema_nc
= false;
552 tmp_ctx
= talloc_new(ldb
);
553 if (tmp_ctx
== NULL
) {
558 el
= talloc_zero(tmp_ctx
, struct ldb_message_element
);
561 talloc_free(tmp_ctx
);
565 el
->name
= ldap_display_name
;
566 el
->num_values
= PyList_Size(el_list
);
568 el
->values
= talloc_array(el
, struct ldb_val
, el
->num_values
);
569 if (el
->values
== NULL
) {
571 talloc_free(tmp_ctx
);
575 for (i
= 0; i
< el
->num_values
; i
++) {
576 PyObject
*item
= PyList_GetItem(el_list
, i
);
577 if (!PyString_Check(item
)) {
578 PyErr_Format(PyExc_TypeError
, "ldif_elements should be strings");
579 talloc_free(tmp_ctx
);
582 el
->values
[i
].data
= (uint8_t *)PyString_AsString(item
);
583 el
->values
[i
].length
= PyString_Size(item
);
586 attr
= talloc_zero(tmp_ctx
, struct drsuapi_DsReplicaAttribute
);
589 talloc_free(tmp_ctx
);
593 werr
= a
->syntax
->ldb_to_drsuapi(&syntax_ctx
, a
, el
, attr
, attr
);
594 PyErr_WERROR_NOT_OK_RAISE(werr
);
596 ret
= py_return_ndr_struct("samba.dcerpc.drsuapi", "DsReplicaAttribute", attr
, attr
);
598 talloc_free(tmp_ctx
);
605 normalise a ldb attribute list
607 static PyObject
*py_dsdb_normalise_attributes(PyObject
*self
, PyObject
*args
)
609 PyObject
*py_ldb
, *el_list
, *ret
;
610 struct ldb_context
*ldb
;
611 char *ldap_display_name
;
612 const struct dsdb_attribute
*a
;
613 struct dsdb_schema
*schema
;
614 struct dsdb_syntax_ctx syntax_ctx
;
615 struct ldb_message_element
*el
;
616 struct drsuapi_DsReplicaAttribute
*attr
;
621 if (!PyArg_ParseTuple(args
, "OsO", &py_ldb
, &ldap_display_name
, &el_list
)) {
625 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
627 if (!PyList_Check(el_list
)) {
628 PyErr_Format(PyExc_TypeError
, "ldif_elements must be a list");
632 schema
= dsdb_get_schema(ldb
, NULL
);
634 PyErr_SetString(PyExc_RuntimeError
, "Failed to find a schema from ldb");
638 a
= dsdb_attribute_by_lDAPDisplayName(schema
, ldap_display_name
);
640 PyErr_Format(PyExc_KeyError
, "Failed to find attribute '%s'", ldap_display_name
);
644 dsdb_syntax_ctx_init(&syntax_ctx
, ldb
, schema
);
645 syntax_ctx
.is_schema_nc
= false;
647 tmp_ctx
= talloc_new(ldb
);
648 if (tmp_ctx
== NULL
) {
653 el
= talloc_zero(tmp_ctx
, struct ldb_message_element
);
656 talloc_free(tmp_ctx
);
660 el
->name
= ldap_display_name
;
661 el
->num_values
= PyList_Size(el_list
);
663 el
->values
= talloc_array(el
, struct ldb_val
, el
->num_values
);
664 if (el
->values
== NULL
) {
666 talloc_free(tmp_ctx
);
670 for (i
= 0; i
< el
->num_values
; i
++) {
671 PyObject
*item
= PyList_GetItem(el_list
, i
);
672 if (!PyString_Check(item
)) {
673 PyErr_Format(PyExc_TypeError
, "ldif_elements should be strings");
674 talloc_free(tmp_ctx
);
677 el
->values
[i
].data
= (uint8_t *)PyString_AsString(item
);
678 el
->values
[i
].length
= PyString_Size(item
);
681 /* Normalise "objectClass" attribute if needed */
682 if (ldb_attr_cmp(a
->lDAPDisplayName
, "objectClass") == 0) {
684 iret
= dsdb_sort_objectClass_attr(ldb
, schema
, el
, tmp_ctx
, el
);
685 if (iret
!= LDB_SUCCESS
) {
686 PyErr_SetString(PyExc_RuntimeError
, ldb_errstring(ldb
));
687 talloc_free(tmp_ctx
);
692 /* first run ldb_to_drsuapi, then convert back again. This has
693 * the effect of normalising the attributes
696 attr
= talloc_zero(tmp_ctx
, struct drsuapi_DsReplicaAttribute
);
699 talloc_free(tmp_ctx
);
703 werr
= a
->syntax
->ldb_to_drsuapi(&syntax_ctx
, a
, el
, attr
, attr
);
704 PyErr_WERROR_NOT_OK_RAISE(werr
);
706 /* now convert back again */
707 werr
= a
->syntax
->drsuapi_to_ldb(&syntax_ctx
, a
, attr
, el
, el
);
708 PyErr_WERROR_NOT_OK_RAISE(werr
);
710 ret
= py_return_ndr_struct("ldb", "MessageElement", el
, el
);
712 talloc_free(tmp_ctx
);
718 static PyObject
*py_dsdb_set_ntds_invocation_id(PyObject
*self
, PyObject
*args
)
720 PyObject
*py_ldb
, *py_guid
;
723 struct ldb_context
*ldb
;
724 if (!PyArg_ParseTuple(args
, "OO", &py_ldb
, &py_guid
))
727 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
728 GUID_from_string(PyString_AsString(py_guid
), &guid
);
730 if (GUID_all_zero(&guid
)) {
731 PyErr_SetString(PyExc_RuntimeError
, "set_ntds_invocation_id rejected due to all-zero invocation ID");
735 ret
= samdb_set_ntds_invocation_id(ldb
, &guid
);
737 PyErr_SetString(PyExc_RuntimeError
, "set_ntds_invocation_id failed");
743 static PyObject
*py_samdb_ntds_objectGUID(PyObject
*self
, PyObject
*args
)
745 PyObject
*py_ldb
, *result
;
746 struct ldb_context
*ldb
;
747 const struct GUID
*guid
;
750 if (!PyArg_ParseTuple(args
, "O", &py_ldb
)) {
754 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
756 guid
= samdb_ntds_objectGUID(ldb
);
758 PyErr_SetString(PyExc_RuntimeError
, "Failed to find NTDS GUID");
762 retstr
= GUID_string(NULL
, guid
);
763 if (retstr
== NULL
) {
767 result
= PyString_FromString(retstr
);
772 static PyObject
*py_dsdb_set_global_schema(PyObject
*self
, PyObject
*args
)
775 struct ldb_context
*ldb
;
777 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
780 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
782 ret
= dsdb_set_global_schema(ldb
);
783 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret
, ldb
);
788 static PyObject
*py_dsdb_load_partition_usn(PyObject
*self
, PyObject
*args
)
790 PyObject
*py_dn
, *py_ldb
, *result
;
792 uint64_t highest_uSN
, urgent_uSN
;
793 struct ldb_context
*ldb
;
797 if (!PyArg_ParseTuple(args
, "OO", &py_ldb
, &py_dn
)) {
801 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
803 mem_ctx
= talloc_new(NULL
);
804 if (mem_ctx
== NULL
) {
809 if (!pyldb_Object_AsDn(mem_ctx
, py_dn
, ldb
, &dn
)) {
810 talloc_free(mem_ctx
);
814 ret
= dsdb_load_partition_usn(ldb
, dn
, &highest_uSN
, &urgent_uSN
);
815 if (ret
!= LDB_SUCCESS
) {
816 PyErr_Format(PyExc_RuntimeError
,
817 "Failed to load partition [%s] uSN - %s",
818 ldb_dn_get_linearized(dn
),
820 talloc_free(mem_ctx
);
824 talloc_free(mem_ctx
);
826 result
= PyDict_New();
828 PyDict_SetItemString(result
, "uSNHighest", PyInt_FromLong((uint64_t)highest_uSN
));
829 PyDict_SetItemString(result
, "uSNUrgent", PyInt_FromLong((uint64_t)urgent_uSN
));
835 static PyObject
*py_dsdb_set_am_rodc(PyObject
*self
, PyObject
*args
)
839 struct ldb_context
*ldb
;
842 if (!PyArg_ParseTuple(args
, "Oi", &py_ldb
, &py_val
))
845 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
846 ret
= samdb_set_am_rodc(ldb
, (bool)py_val
);
848 PyErr_SetString(PyExc_RuntimeError
, "set_am_rodc failed");
854 static PyObject
*py_dsdb_set_schema_from_ldif(PyObject
*self
, PyObject
*args
)
859 struct ldb_context
*ldb
;
861 if (!PyArg_ParseTuple(args
, "Osss", &py_ldb
, &pf
, &df
, &dn
))
864 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
866 result
= dsdb_set_schema_from_ldif(ldb
, pf
, df
, dn
);
867 PyErr_WERROR_NOT_OK_RAISE(result
);
872 static PyObject
*py_dsdb_set_schema_from_ldb(PyObject
*self
, PyObject
*args
)
875 struct ldb_context
*ldb
;
876 PyObject
*py_from_ldb
;
877 struct ldb_context
*from_ldb
;
878 struct dsdb_schema
*schema
;
880 char write_indices_and_attributes
= true;
881 if (!PyArg_ParseTuple(args
, "OO|b",
882 &py_ldb
, &py_from_ldb
, &write_indices_and_attributes
))
885 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
887 PyErr_LDB_OR_RAISE(py_from_ldb
, from_ldb
);
889 schema
= dsdb_get_schema(from_ldb
, NULL
);
891 PyErr_SetString(PyExc_RuntimeError
, "Failed to set find a schema on 'from' ldb!\n");
895 ret
= dsdb_reference_schema(ldb
, schema
, write_indices_and_attributes
);
896 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret
, ldb
);
901 static PyObject
*py_dsdb_write_prefixes_from_schema_to_ldb(PyObject
*self
, PyObject
*args
)
904 struct ldb_context
*ldb
;
906 struct dsdb_schema
*schema
;
908 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
911 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
913 schema
= dsdb_get_schema(ldb
, NULL
);
915 PyErr_SetString(PyExc_RuntimeError
, "Failed to set find a schema on ldb!\n");
919 result
= dsdb_write_prefixes_from_schema_to_ldb(NULL
, ldb
, schema
);
920 PyErr_WERROR_NOT_OK_RAISE(result
);
926 static PyObject
*py_dsdb_get_partitions_dn(PyObject
*self
, PyObject
*args
)
928 struct ldb_context
*ldb
;
930 PyObject
*py_ldb
, *ret
;
932 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
935 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
937 dn
= samdb_partitions_dn(ldb
, NULL
);
942 ret
= pyldb_Dn_FromDn(dn
);
948 static PyObject
*py_dsdb_get_nc_root(PyObject
*self
, PyObject
*args
)
950 struct ldb_context
*ldb
;
951 struct ldb_dn
*dn
, *nc_root
;
952 PyObject
*py_ldb
, *py_ldb_dn
, *py_nc_root
;
955 if (!PyArg_ParseTuple(args
, "OO", &py_ldb
, &py_ldb_dn
))
958 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
959 PyErr_LDB_DN_OR_RAISE(py_ldb_dn
, dn
);
961 ret
= dsdb_find_nc_root(ldb
, ldb
, dn
, &nc_root
);
962 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret
, ldb
);
964 py_nc_root
= pyldb_Dn_FromDn(nc_root
);
965 talloc_unlink(ldb
, nc_root
);
969 static PyObject
*py_dsdb_get_wellknown_dn(PyObject
*self
, PyObject
*args
)
971 struct ldb_context
*ldb
;
972 struct ldb_dn
*nc_dn
, *wk_dn
;
974 PyObject
*py_ldb
, *py_nc_dn
, *py_wk_dn
;
977 if (!PyArg_ParseTuple(args
, "OOs", &py_ldb
, &py_nc_dn
, &wkguid
))
980 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
981 PyErr_LDB_DN_OR_RAISE(py_nc_dn
, nc_dn
);
983 ret
= dsdb_wellknown_dn(ldb
, ldb
, nc_dn
, wkguid
, &wk_dn
);
984 if (ret
== LDB_ERR_NO_SUCH_OBJECT
) {
985 PyErr_Format(PyExc_KeyError
, "Failed to find well known DN for GUID %s", wkguid
);
989 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret
, ldb
);
991 py_wk_dn
= pyldb_Dn_FromDn(wk_dn
);
992 talloc_unlink(ldb
, wk_dn
);
998 call into samdb_rodc()
1000 static PyObject
*py_dsdb_am_rodc(PyObject
*self
, PyObject
*args
)
1003 struct ldb_context
*ldb
;
1007 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
1010 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
1012 ret
= samdb_rodc(ldb
, &am_rodc
);
1013 if (ret
!= LDB_SUCCESS
) {
1014 PyErr_SetString(PyExc_RuntimeError
, ldb_errstring(ldb
));
1018 return PyBool_FromLong(am_rodc
);
1022 call into samdb_is_pdc()
1024 static PyObject
*py_dsdb_am_pdc(PyObject
*self
, PyObject
*args
)
1027 struct ldb_context
*ldb
;
1030 if (!PyArg_ParseTuple(args
, "O", &py_ldb
))
1033 PyErr_LDB_OR_RAISE(py_ldb
, ldb
);
1035 am_pdc
= samdb_is_pdc(ldb
);
1036 return PyBool_FromLong(am_pdc
);
1040 static PyMethodDef py_dsdb_methods
[] = {
1041 { "_samdb_server_site_name", (PyCFunction
)py_samdb_server_site_name
,
1042 METH_VARARGS
, "Get the server site name as a string"},
1043 { "_dsdb_convert_schema_to_openldap",
1044 (PyCFunction
)py_dsdb_convert_schema_to_openldap
, METH_VARARGS
,
1045 "dsdb_convert_schema_to_openldap(ldb, target_str, mapping) -> str\n"
1046 "Create an OpenLDAP schema from a schema." },
1047 { "_samdb_set_domain_sid", (PyCFunction
)py_samdb_set_domain_sid
,
1049 "samdb_set_domain_sid(samdb, sid)\n"
1050 "Set SID of domain to use." },
1051 { "_samdb_get_domain_sid", (PyCFunction
)py_samdb_get_domain_sid
,
1053 "samdb_get_domain_sid(samdb)\n"
1054 "Get SID of domain in use." },
1055 { "_samdb_ntds_invocation_id", (PyCFunction
)py_samdb_ntds_invocation_id
,
1056 METH_VARARGS
, "get the NTDS invocation ID GUID as a string"},
1057 { "_samdb_set_ntds_settings_dn", (PyCFunction
)py_samdb_set_ntds_settings_dn
,
1059 "samdb_set_ntds_settings_dn(samdb, ntds_settings_dn)\n"
1060 "Set NTDS Settings DN for this LDB (allows it to be set before the DB fully exists)." },
1061 { "_dsdb_get_oid_from_attid", (PyCFunction
)py_dsdb_get_oid_from_attid
,
1062 METH_VARARGS
, NULL
},
1063 { "_dsdb_get_attid_from_lDAPDisplayName", (PyCFunction
)py_dsdb_get_attid_from_lDAPDisplayName
,
1064 METH_VARARGS
, NULL
},
1065 { "_dsdb_get_syntax_oid_from_lDAPDisplayName", (PyCFunction
)py_dsdb_get_syntax_oid_from_lDAPDisplayName
,
1066 METH_VARARGS
, NULL
},
1067 { "_dsdb_get_systemFlags_from_lDAPDisplayName", (PyCFunction
)py_dsdb_get_systemFlags_from_lDAPDisplayName
,
1068 METH_VARARGS
, NULL
},
1069 { "_dsdb_get_linkId_from_lDAPDisplayName", (PyCFunction
)py_dsdb_get_linkId_from_lDAPDisplayName
,
1070 METH_VARARGS
, NULL
},
1071 { "_dsdb_get_lDAPDisplayName_by_attid", (PyCFunction
)py_dsdb_get_lDAPDisplayName_by_attid
,
1072 METH_VARARGS
, NULL
},
1073 { "_dsdb_get_backlink_from_lDAPDisplayName", (PyCFunction
)py_dsdb_get_backlink_from_lDAPDisplayName
,
1074 METH_VARARGS
, NULL
},
1075 { "_dsdb_set_ntds_invocation_id",
1076 (PyCFunction
)py_dsdb_set_ntds_invocation_id
, METH_VARARGS
,
1078 { "_samdb_ntds_objectGUID", (PyCFunction
)py_samdb_ntds_objectGUID
,
1079 METH_VARARGS
, "get the NTDS objectGUID as a string"},
1080 { "_dsdb_set_global_schema", (PyCFunction
)py_dsdb_set_global_schema
,
1081 METH_VARARGS
, NULL
},
1082 { "_dsdb_load_partition_usn", (PyCFunction
)py_dsdb_load_partition_usn
,
1084 "get uSNHighest and uSNUrgent from the partition @REPLCHANGED"},
1085 { "_dsdb_set_am_rodc",
1086 (PyCFunction
)py_dsdb_set_am_rodc
, METH_VARARGS
,
1089 (PyCFunction
)py_dsdb_am_rodc
, METH_VARARGS
,
1092 (PyCFunction
)py_dsdb_am_pdc
, METH_VARARGS
,
1094 { "_dsdb_set_schema_from_ldif", (PyCFunction
)py_dsdb_set_schema_from_ldif
, METH_VARARGS
,
1096 { "_dsdb_set_schema_from_ldb", (PyCFunction
)py_dsdb_set_schema_from_ldb
, METH_VARARGS
,
1098 { "_dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction
)py_dsdb_write_prefixes_from_schema_to_ldb
, METH_VARARGS
,
1100 { "_dsdb_get_partitions_dn", (PyCFunction
)py_dsdb_get_partitions_dn
, METH_VARARGS
, NULL
},
1101 { "_dsdb_get_nc_root", (PyCFunction
)py_dsdb_get_nc_root
, METH_VARARGS
, NULL
},
1102 { "_dsdb_get_wellknown_dn", (PyCFunction
)py_dsdb_get_wellknown_dn
, METH_VARARGS
, NULL
},
1103 { "_dsdb_DsReplicaAttribute", (PyCFunction
)py_dsdb_DsReplicaAttribute
, METH_VARARGS
, NULL
},
1104 { "_dsdb_normalise_attributes", (PyCFunction
)py_dsdb_normalise_attributes
, METH_VARARGS
, NULL
},
1112 m
= Py_InitModule3("dsdb", py_dsdb_methods
,
1113 "Python bindings for the directory service databases.");
1117 #define ADD_DSDB_FLAG(val) PyModule_AddObject(m, #val, PyInt_FromLong(val))
1119 /* "userAccountControl" flags */
1120 ADD_DSDB_FLAG(UF_NORMAL_ACCOUNT
);
1121 ADD_DSDB_FLAG(UF_TEMP_DUPLICATE_ACCOUNT
);
1122 ADD_DSDB_FLAG(UF_SERVER_TRUST_ACCOUNT
);
1123 ADD_DSDB_FLAG(UF_WORKSTATION_TRUST_ACCOUNT
);
1124 ADD_DSDB_FLAG(UF_INTERDOMAIN_TRUST_ACCOUNT
);
1125 ADD_DSDB_FLAG(UF_PASSWD_NOTREQD
);
1126 ADD_DSDB_FLAG(UF_ACCOUNTDISABLE
);
1128 ADD_DSDB_FLAG(UF_SCRIPT
);
1129 ADD_DSDB_FLAG(UF_ACCOUNTDISABLE
);
1130 ADD_DSDB_FLAG(UF_00000004
);
1131 ADD_DSDB_FLAG(UF_HOMEDIR_REQUIRED
);
1132 ADD_DSDB_FLAG(UF_LOCKOUT
);
1133 ADD_DSDB_FLAG(UF_PASSWD_NOTREQD
);
1134 ADD_DSDB_FLAG(UF_PASSWD_CANT_CHANGE
);
1135 ADD_DSDB_FLAG(UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED
);
1136 ADD_DSDB_FLAG(UF_TEMP_DUPLICATE_ACCOUNT
);
1137 ADD_DSDB_FLAG(UF_NORMAL_ACCOUNT
);
1138 ADD_DSDB_FLAG(UF_00000400
);
1139 ADD_DSDB_FLAG(UF_INTERDOMAIN_TRUST_ACCOUNT
);
1140 ADD_DSDB_FLAG(UF_WORKSTATION_TRUST_ACCOUNT
);
1141 ADD_DSDB_FLAG(UF_SERVER_TRUST_ACCOUNT
);
1142 ADD_DSDB_FLAG(UF_00004000
);
1143 ADD_DSDB_FLAG(UF_00008000
);
1144 ADD_DSDB_FLAG(UF_DONT_EXPIRE_PASSWD
);
1145 ADD_DSDB_FLAG(UF_MNS_LOGON_ACCOUNT
);
1146 ADD_DSDB_FLAG(UF_SMARTCARD_REQUIRED
);
1147 ADD_DSDB_FLAG(UF_TRUSTED_FOR_DELEGATION
);
1148 ADD_DSDB_FLAG(UF_NOT_DELEGATED
);
1149 ADD_DSDB_FLAG(UF_USE_DES_KEY_ONLY
);
1150 ADD_DSDB_FLAG(UF_DONT_REQUIRE_PREAUTH
);
1151 ADD_DSDB_FLAG(UF_PASSWORD_EXPIRED
);
1152 ADD_DSDB_FLAG(UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION
);
1153 ADD_DSDB_FLAG(UF_NO_AUTH_DATA_REQUIRED
);
1154 ADD_DSDB_FLAG(UF_PARTIAL_SECRETS_ACCOUNT
);
1156 /* groupType flags */
1157 ADD_DSDB_FLAG(GTYPE_SECURITY_BUILTIN_LOCAL_GROUP
);
1158 ADD_DSDB_FLAG(GTYPE_SECURITY_GLOBAL_GROUP
);
1159 ADD_DSDB_FLAG(GTYPE_SECURITY_DOMAIN_LOCAL_GROUP
);
1160 ADD_DSDB_FLAG(GTYPE_SECURITY_UNIVERSAL_GROUP
);
1161 ADD_DSDB_FLAG(GTYPE_DISTRIBUTION_GLOBAL_GROUP
);
1162 ADD_DSDB_FLAG(GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP
);
1163 ADD_DSDB_FLAG(GTYPE_DISTRIBUTION_UNIVERSAL_GROUP
);
1165 /* "sAMAccountType" flags */
1166 ADD_DSDB_FLAG(ATYPE_NORMAL_ACCOUNT
);
1167 ADD_DSDB_FLAG(ATYPE_WORKSTATION_TRUST
);
1168 ADD_DSDB_FLAG(ATYPE_INTERDOMAIN_TRUST
);
1169 ADD_DSDB_FLAG(ATYPE_SECURITY_GLOBAL_GROUP
);
1170 ADD_DSDB_FLAG(ATYPE_SECURITY_LOCAL_GROUP
);
1171 ADD_DSDB_FLAG(ATYPE_SECURITY_UNIVERSAL_GROUP
);
1172 ADD_DSDB_FLAG(ATYPE_DISTRIBUTION_GLOBAL_GROUP
);
1173 ADD_DSDB_FLAG(ATYPE_DISTRIBUTION_LOCAL_GROUP
);
1174 ADD_DSDB_FLAG(ATYPE_DISTRIBUTION_UNIVERSAL_GROUP
);
1176 /* "domainFunctionality", "forestFunctionality" flags in the rootDSE */
1177 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2000
);
1178 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2003_MIXED
);
1179 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2003
);
1180 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2008
);
1181 ADD_DSDB_FLAG(DS_DOMAIN_FUNCTION_2008_R2
);
1183 /* nc replica flags */
1184 ADD_DSDB_FLAG(INSTANCE_TYPE_IS_NC_HEAD
);
1185 ADD_DSDB_FLAG(INSTANCE_TYPE_UNINSTANT
);
1186 ADD_DSDB_FLAG(INSTANCE_TYPE_WRITE
);
1187 ADD_DSDB_FLAG(INSTANCE_TYPE_NC_ABOVE
);
1188 ADD_DSDB_FLAG(INSTANCE_TYPE_NC_COMING
);
1189 ADD_DSDB_FLAG(INSTANCE_TYPE_NC_GOING
);
1192 ADD_DSDB_FLAG(SYSTEM_FLAG_CR_NTDS_NC
);
1193 ADD_DSDB_FLAG(SYSTEM_FLAG_CR_NTDS_DOMAIN
);
1194 ADD_DSDB_FLAG(SYSTEM_FLAG_CR_NTDS_NOT_GC_REPLICATED
);
1195 ADD_DSDB_FLAG(SYSTEM_FLAG_SCHEMA_BASE_OBJECT
);
1196 ADD_DSDB_FLAG(SYSTEM_FLAG_ATTR_IS_RDN
);
1197 ADD_DSDB_FLAG(SYSTEM_FLAG_DISALLOW_MOVE_ON_DELETE
);
1198 ADD_DSDB_FLAG(SYSTEM_FLAG_DOMAIN_DISALLOW_MOVE
);
1199 ADD_DSDB_FLAG(SYSTEM_FLAG_DOMAIN_DISALLOW_RENAME
);
1200 ADD_DSDB_FLAG(SYSTEM_FLAG_CONFIG_ALLOW_LIMITED_MOVE
);
1201 ADD_DSDB_FLAG(SYSTEM_FLAG_CONFIG_ALLOW_MOVE
);
1202 ADD_DSDB_FLAG(SYSTEM_FLAG_CONFIG_ALLOW_RENAME
);
1203 ADD_DSDB_FLAG(SYSTEM_FLAG_DISALLOW_DELETE
);
1205 /* Kerberos encryption type constants */
1206 ADD_DSDB_FLAG(ENC_ALL_TYPES
);
1207 ADD_DSDB_FLAG(ENC_CRC32
);
1208 ADD_DSDB_FLAG(ENC_RSA_MD5
);
1209 ADD_DSDB_FLAG(ENC_RC4_HMAC_MD5
);
1210 ADD_DSDB_FLAG(ENC_HMAC_SHA1_96_AES128
);
1211 ADD_DSDB_FLAG(ENC_HMAC_SHA1_96_AES256
);
1213 ADD_DSDB_FLAG(SEARCH_FLAG_ATTINDEX
);
1214 ADD_DSDB_FLAG(SEARCH_FLAG_PDNTATTINDEX
);
1215 ADD_DSDB_FLAG(SEARCH_FLAG_ANR
);
1216 ADD_DSDB_FLAG(SEARCH_FLAG_PRESERVEONDELETE
);
1217 ADD_DSDB_FLAG(SEARCH_FLAG_COPY
);
1218 ADD_DSDB_FLAG(SEARCH_FLAG_TUPLEINDEX
);
1219 ADD_DSDB_FLAG(SEARCH_FLAG_SUBTREEATTRINDEX
);
1220 ADD_DSDB_FLAG(SEARCH_FLAG_CONFIDENTIAL
);
1221 ADD_DSDB_FLAG(SEARCH_FLAG_NEVERVALUEAUDIT
);
1222 ADD_DSDB_FLAG(SEARCH_FLAG_RODC_ATTRIBUTE
);
1224 ADD_DSDB_FLAG(DS_FLAG_ATTR_NOT_REPLICATED
);
1225 ADD_DSDB_FLAG(DS_FLAG_ATTR_REQ_PARTIAL_SET_MEMBER
);
1226 ADD_DSDB_FLAG(DS_FLAG_ATTR_IS_CONSTRUCTED
);
1228 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED
);
1229 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED
);
1230 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED
);
1231 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED
);
1232 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED
);
1233 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_GROUP_CACHING_ENABLED
);
1234 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_FORCE_KCC_WHISTLER_BEHAVIOR
);
1235 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED
);
1236 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_SCHEDULE_HASHING_ENABLED
);
1237 ADD_DSDB_FLAG(DS_NTDSSETTINGS_OPT_IS_REDUNDANT_SERVER_TOPOLOGY_ENABLED
);
1239 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_IS_GC
);
1240 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_INBOUND_REPL
);
1241 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL
);
1242 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE
);
1243 ADD_DSDB_FLAG(DS_NTDSDSA_OPT_DISABLE_SPN_REGISTRATION
);
1245 ADD_DSDB_FLAG(NTDSCONN_KCC_GC_TOPOLOGY
);
1246 ADD_DSDB_FLAG(NTDSCONN_KCC_RING_TOPOLOGY
);
1247 ADD_DSDB_FLAG(NTDSCONN_KCC_MINIMIZE_HOPS_TOPOLOGY
);
1248 ADD_DSDB_FLAG(NTDSCONN_KCC_STALE_SERVERS_TOPOLOGY
);
1249 ADD_DSDB_FLAG(NTDSCONN_KCC_OSCILLATING_CONNECTION_TOPOLOGY
);
1250 ADD_DSDB_FLAG(NTDSCONN_KCC_INTERSITE_GC_TOPOLOGY
);
1251 ADD_DSDB_FLAG(NTDSCONN_KCC_INTERSITE_TOPOLOGY
);
1252 ADD_DSDB_FLAG(NTDSCONN_KCC_SERVER_FAILOVER_TOPOLOGY
);
1253 ADD_DSDB_FLAG(NTDSCONN_KCC_SITE_FAILOVER_TOPOLOGY
);
1254 ADD_DSDB_FLAG(NTDSCONN_KCC_REDUNDANT_SERVER_TOPOLOGY
);
1256 ADD_DSDB_FLAG(NTDSCONN_OPT_IS_GENERATED
);
1257 ADD_DSDB_FLAG(NTDSCONN_OPT_TWOWAY_SYNC
);
1258 ADD_DSDB_FLAG(NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT
);
1259 ADD_DSDB_FLAG(NTDSCONN_OPT_USE_NOTIFY
);
1260 ADD_DSDB_FLAG(NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION
);
1261 ADD_DSDB_FLAG(NTDSCONN_OPT_USER_OWNED_SCHEDULE
);
1262 ADD_DSDB_FLAG(NTDSCONN_OPT_RODC_TOPOLOGY
);
1264 /* Site Link Object options */
1265 ADD_DSDB_FLAG(NTDSSITELINK_OPT_USE_NOTIFY
);
1266 ADD_DSDB_FLAG(NTDSSITELINK_OPT_TWOWAY_SYNC
);
1267 ADD_DSDB_FLAG(NTDSSITELINK_OPT_DISABLE_COMPRESSION
);
1269 /* GPO policy flags */
1270 ADD_DSDB_FLAG(GPLINK_OPT_DISABLE
);
1271 ADD_DSDB_FLAG(GPLINK_OPT_ENFORCE
);
1272 ADD_DSDB_FLAG(GPO_FLAG_USER_DISABLE
);
1273 ADD_DSDB_FLAG(GPO_FLAG_MACHINE_DISABLE
);
1274 ADD_DSDB_FLAG(GPO_INHERIT
);
1275 ADD_DSDB_FLAG(GPO_BLOCK_INHERITANCE
);
1277 #define ADD_DSDB_STRING(val) PyModule_AddObject(m, #val, PyString_FromString(val))
1279 ADD_DSDB_STRING(DSDB_SYNTAX_BINARY_DN
);
1280 ADD_DSDB_STRING(DSDB_SYNTAX_STRING_DN
);
1281 ADD_DSDB_STRING(DSDB_SYNTAX_OR_NAME
);
1282 ADD_DSDB_STRING(DSDB_CONTROL_DBCHECK
);
1283 ADD_DSDB_STRING(DSDB_CONTROL_DBCHECK_MODIFY_RO_REPLICA
);
1285 ADD_DSDB_STRING(DS_GUID_COMPUTERS_CONTAINER
);
1286 ADD_DSDB_STRING(DS_GUID_DELETED_OBJECTS_CONTAINER
);
1287 ADD_DSDB_STRING(DS_GUID_DOMAIN_CONTROLLERS_CONTAINER
);
1288 ADD_DSDB_STRING(DS_GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER
);
1289 ADD_DSDB_STRING(DS_GUID_INFRASTRUCTURE_CONTAINER
);
1290 ADD_DSDB_STRING(DS_GUID_LOSTANDFOUND_CONTAINER
);
1291 ADD_DSDB_STRING(DS_GUID_MICROSOFT_PROGRAM_DATA_CONTAINER
);
1292 ADD_DSDB_STRING(DS_GUID_NTDS_QUOTAS_CONTAINER
);
1293 ADD_DSDB_STRING(DS_GUID_PROGRAM_DATA_CONTAINER
);
1294 ADD_DSDB_STRING(DS_GUID_SYSTEMS_CONTAINER
);
1295 ADD_DSDB_STRING(DS_GUID_USERS_CONTAINER
);