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/>.
22 #include "libcli/util/pyerrors.h"
23 #include "dsdb/samdb/samdb.h"
24 #include "lib/ldb/pyldb.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 /* FIXME: These should be in a header file somewhere, once we finish moving
30 * away from SWIG .. */
31 #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
32 /* if (!PyLdb_Check(py_ldb)) { \
33 PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \
36 ldb = PyLdb_AsLdbContext(py_ldb);
38 static PyObject *py_ldb_get_exception(void)
40 PyObject *mod = PyImport_ImportModule("ldb");
44 return PyObject_GetAttrString(mod, "LdbError");
47 static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx)
49 if (ret == LDB_ERR_PYTHON_EXCEPTION)
50 return; /* Python exception should already be set, just keep that */
52 PyErr_SetObject(error,
53 Py_BuildValue(discard_const_p(char, "(i,s)"), ret,
54 ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
57 static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args)
59 PyObject *py_ldb, *result;
60 struct ldb_context *ldb;
64 if (!PyArg_ParseTuple(args, "O", &py_ldb))
67 PyErr_LDB_OR_RAISE(py_ldb, ldb);
69 mem_ctx = talloc_new(NULL);
71 site = samdb_server_site_name(ldb, mem_ctx);
73 PyErr_SetString(PyExc_RuntimeError, "Failed to find server site");
78 result = PyString_FromString(site);
83 static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self,
86 char *target_str, *mapping;
88 struct ldb_context *ldb;
92 if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &target_str, &mapping))
95 PyErr_LDB_OR_RAISE(py_ldb, ldb);
97 retstr = dsdb_convert_schema_to_openldap(ldb, target_str, mapping);
99 PyErr_SetString(PyExc_RuntimeError,
100 "dsdb_convert_schema_to_openldap failed");
104 ret = PyString_FromString(retstr);
109 static PyObject *py_samdb_set_domain_sid(PyLdbObject *self, PyObject *args)
111 PyObject *py_ldb, *py_sid;
112 struct ldb_context *ldb;
116 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_sid))
119 PyErr_LDB_OR_RAISE(py_ldb, ldb);
121 sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid));
123 ret = samdb_set_domain_sid(ldb, sid);
125 PyErr_SetString(PyExc_RuntimeError, "set_domain_sid failed");
131 static PyObject *py_samdb_set_ntds_settings_dn(PyLdbObject *self, PyObject *args)
133 PyObject *py_ldb, *py_ntds_settings_dn;
134 struct ldb_context *ldb;
135 struct ldb_dn *ntds_settings_dn;
139 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_ntds_settings_dn))
142 PyErr_LDB_OR_RAISE(py_ldb, ldb);
144 tmp_ctx = talloc_new(NULL);
145 if (tmp_ctx == NULL) {
150 if (!PyObject_AsDn(tmp_ctx, py_ntds_settings_dn, ldb, &ntds_settings_dn)) {
154 ret = samdb_set_ntds_settings_dn(ldb, ntds_settings_dn);
155 talloc_free(tmp_ctx);
157 PyErr_SetString(PyExc_RuntimeError, "set_ntds_settings_dn failed");
163 static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args)
166 struct ldb_context *ldb;
167 const struct dom_sid *sid;
171 if (!PyArg_ParseTuple(args, "O", &py_ldb))
174 PyErr_LDB_OR_RAISE(py_ldb, ldb);
176 sid = samdb_domain_sid(ldb);
178 PyErr_SetString(PyExc_RuntimeError, "samdb_domain_sid failed");
181 retstr = dom_sid_string(NULL, sid);
182 ret = PyString_FromString(retstr);
187 static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args)
189 PyObject *py_ldb, *result;
190 struct ldb_context *ldb;
192 const struct GUID *guid;
194 mem_ctx = talloc_new(NULL);
195 if (mem_ctx == NULL) {
200 if (!PyArg_ParseTuple(args, "O", &py_ldb)) {
201 talloc_free(mem_ctx);
205 PyErr_LDB_OR_RAISE(py_ldb, ldb);
207 guid = samdb_ntds_invocation_id(ldb);
209 PyErr_SetString(PyExc_RuntimeError,
210 "Failed to find NTDS invocation ID");
211 talloc_free(mem_ctx);
215 result = PyString_FromString(GUID_string(mem_ctx, guid));
216 talloc_free(mem_ctx);
220 static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args)
223 struct ldb_context *ldb;
225 struct dsdb_schema *schema;
231 if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
234 mem_ctx = talloc_new(NULL);
235 if (mem_ctx == NULL) {
240 PyErr_LDB_OR_RAISE(py_ldb, ldb);
242 schema = dsdb_get_schema(ldb, NULL);
245 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n");
246 talloc_free(mem_ctx);
250 status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid,
252 PyErr_WERROR_IS_ERR_RAISE(status);
254 ret = PyString_FromString(oid);
256 talloc_free(mem_ctx);
262 static PyObject *py_dsdb_get_attid_from_lDAPDisplayName(PyObject *self, PyObject *args)
264 PyObject *py_ldb, *is_schema_nc;
265 struct ldb_context *ldb;
266 struct dsdb_schema *schema;
267 const char *ldap_display_name;
268 bool schema_nc = false;
269 const struct dsdb_attribute *a;
272 if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &is_schema_nc))
275 PyErr_LDB_OR_RAISE(py_ldb, ldb);
278 if (!PyBool_Check(is_schema_nc)) {
279 PyErr_SetString(PyExc_TypeError, "Expected boolean is_schema_nc");
282 if (is_schema_nc == Py_True) {
287 schema = dsdb_get_schema(ldb, NULL);
290 PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
294 a = dsdb_attribute_by_lDAPDisplayName(schema, ldap_display_name);
296 PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name);
300 attid = dsdb_attribute_get_attid(a, schema_nc);
302 return PyLong_FromUnsignedLong(attid);
305 static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args)
307 PyObject *py_ldb, *py_guid;
310 struct ldb_context *ldb;
311 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_guid))
314 PyErr_LDB_OR_RAISE(py_ldb, ldb);
315 GUID_from_string(PyString_AsString(py_guid), &guid);
317 ret = samdb_set_ntds_invocation_id(ldb, &guid);
319 PyErr_SetString(PyExc_RuntimeError, "set_ntds_invocation_id failed");
325 static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args)
327 PyObject *py_ldb, *result;
328 struct ldb_context *ldb;
330 const struct GUID *guid;
332 mem_ctx = talloc_new(NULL);
333 if (mem_ctx == NULL) {
338 if (!PyArg_ParseTuple(args, "O", &py_ldb)) {
339 talloc_free(mem_ctx);
343 PyErr_LDB_OR_RAISE(py_ldb, ldb);
345 guid = samdb_ntds_objectGUID(ldb);
347 PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS GUID");
348 talloc_free(mem_ctx);
352 result = PyString_FromString(GUID_string(mem_ctx, guid));
353 talloc_free(mem_ctx);
357 static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args)
360 struct ldb_context *ldb;
362 if (!PyArg_ParseTuple(args, "O", &py_ldb))
365 PyErr_LDB_OR_RAISE(py_ldb, ldb);
367 ret = dsdb_set_global_schema(ldb);
368 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
373 static PyObject *py_dsdb_load_partition_usn(PyObject *self, PyObject *args)
375 PyObject *py_dn, *py_ldb, *result;
377 uint64_t highest_uSN, urgent_uSN;
378 struct ldb_context *ldb;
382 mem_ctx = talloc_new(NULL);
383 if (mem_ctx == NULL) {
388 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_dn)) {
389 talloc_free(mem_ctx);
393 PyErr_LDB_OR_RAISE(py_ldb, ldb);
395 if (!PyObject_AsDn(mem_ctx, py_dn, ldb, &dn)) {
396 talloc_free(mem_ctx);
400 ret = dsdb_load_partition_usn(ldb, dn, &highest_uSN, &urgent_uSN);
401 if (ret != LDB_SUCCESS) {
402 char *errstr = talloc_asprintf(mem_ctx, "Failed to load partition uSN - %s", ldb_errstring(ldb));
403 PyErr_SetString(PyExc_RuntimeError, errstr);
404 talloc_free(mem_ctx);
408 talloc_free(mem_ctx);
410 result = PyDict_New();
412 PyDict_SetItemString(result, "uSNHighest", PyInt_FromLong((uint64_t)highest_uSN));
413 PyDict_SetItemString(result, "uSNUrgent", PyInt_FromLong((uint64_t)urgent_uSN));
419 static PyObject *py_dsdb_set_am_rodc(PyObject *self, PyObject *args)
423 struct ldb_context *ldb;
426 if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &py_val))
429 PyErr_LDB_OR_RAISE(py_ldb, ldb);
430 ret = samdb_set_am_rodc(ldb, (bool)py_val);
432 PyErr_SetString(PyExc_RuntimeError, "set_am_rodc failed");
438 static PyObject *py_dsdb_set_schema_from_ldif(PyObject *self, PyObject *args)
443 struct ldb_context *ldb;
445 if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &pf, &df))
448 PyErr_LDB_OR_RAISE(py_ldb, ldb);
450 result = dsdb_set_schema_from_ldif(ldb, pf, df);
451 PyErr_WERROR_IS_ERR_RAISE(result);
456 static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
459 struct ldb_context *ldb;
460 PyObject *py_from_ldb;
461 struct ldb_context *from_ldb;
462 struct dsdb_schema *schema;
464 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_from_ldb))
467 PyErr_LDB_OR_RAISE(py_ldb, ldb);
469 PyErr_LDB_OR_RAISE(py_from_ldb, from_ldb);
471 schema = dsdb_get_schema(from_ldb, NULL);
473 PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on 'from' ldb!\n");
477 ret = dsdb_reference_schema(ldb, schema, true);
478 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
483 static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObject *args)
486 struct ldb_context *ldb;
488 struct dsdb_schema *schema;
490 if (!PyArg_ParseTuple(args, "O", &py_ldb))
493 PyErr_LDB_OR_RAISE(py_ldb, ldb);
495 schema = dsdb_get_schema(ldb, NULL);
497 PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on ldb!\n");
501 result = dsdb_write_prefixes_from_schema_to_ldb(NULL, ldb, schema);
502 PyErr_WERROR_IS_ERR_RAISE(result);
508 static PyObject *py_dsdb_get_partitions_dn(PyObject *self, PyObject *args)
510 struct ldb_context *ldb;
512 PyObject *py_ldb, *ret;
516 mod = PyImport_ImportModule("ldb");
518 if (!PyArg_ParseTuple(args, "O", &py_ldb))
521 PyErr_LDB_OR_RAISE(py_ldb, ldb);
523 tmp_ctx = talloc_new(NULL);
525 dn = samdb_partitions_dn(ldb, tmp_ctx);
528 talloc_free(tmp_ctx);
531 ret = PyLdbDn_FromDn(dn);
532 talloc_free(tmp_ctx);
538 call into samdb_rodc()
540 static PyObject *py_dsdb_am_rodc(PyObject *self, PyObject *args)
543 struct ldb_context *ldb;
547 if (!PyArg_ParseTuple(args, "O", &py_ldb))
550 PyErr_LDB_OR_RAISE(py_ldb, ldb);
552 ret = samdb_rodc(ldb, &am_rodc);
553 if (samdb_rodc(ldb, &am_rodc) != LDB_SUCCESS) {
554 PyErr_SetString(PyExc_RuntimeError, ldb_errstring(ldb));
558 return PyBool_FromLong(am_rodc);
562 static PyMethodDef py_dsdb_methods[] = {
563 { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
564 METH_VARARGS, "Get the server site name as a string"},
565 { "_dsdb_convert_schema_to_openldap",
566 (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS,
567 "dsdb_convert_schema_to_openldap(ldb, target_str, mapping) -> str\n"
568 "Create an OpenLDAP schema from a schema." },
569 { "_samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid,
571 "samdb_set_domain_sid(samdb, sid)\n"
572 "Set SID of domain to use." },
573 { "_samdb_get_domain_sid", (PyCFunction)py_samdb_get_domain_sid,
575 "samdb_get_domain_sid(samdb)\n"
576 "Get SID of domain in use." },
577 { "_samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id,
578 METH_VARARGS, "get the NTDS invocation ID GUID as a string"},
579 { "_samdb_set_ntds_settings_dn", (PyCFunction)py_samdb_set_ntds_settings_dn,
581 "samdb_set_ntds_settings_dn(samdb, ntds_settings_dn)\n"
582 "Set NTDS Settings DN for this LDB (allows it to be set before the DB fully exists)." },
583 { "_dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid,
584 METH_VARARGS, NULL },
585 { "_dsdb_get_attid_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_attid_from_lDAPDisplayName,
586 METH_VARARGS, NULL },
587 { "_dsdb_set_ntds_invocation_id",
588 (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS,
590 { "_samdb_ntds_objectGUID", (PyCFunction)py_samdb_ntds_objectGUID,
591 METH_VARARGS, "get the NTDS objectGUID as a string"},
592 { "_dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema,
593 METH_VARARGS, NULL },
594 { "_dsdb_load_partition_usn", (PyCFunction)py_dsdb_load_partition_usn,
596 "get uSNHighest and uSNUrgent from the partition @REPLCHANGED"},
597 { "_dsdb_set_am_rodc",
598 (PyCFunction)py_dsdb_set_am_rodc, METH_VARARGS,
601 (PyCFunction)py_dsdb_am_rodc, METH_VARARGS,
603 { "_dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS,
605 { "_dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS,
607 { "_dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS,
609 { "_dsdb_get_partitions_dn", (PyCFunction)py_dsdb_get_partitions_dn, METH_VARARGS, NULL },
617 m = Py_InitModule3("dsdb", py_dsdb_methods,
618 "Python bindings for the directory service databases.");
622 /* "userAccountControl" flags */
623 PyModule_AddObject(m, "UF_NORMAL_ACCOUNT",
624 PyInt_FromLong(UF_NORMAL_ACCOUNT));
625 PyModule_AddObject(m, "UF_TEMP_DUPLICATE_ACCOUNT",
626 PyInt_FromLong(UF_TEMP_DUPLICATE_ACCOUNT));
627 PyModule_AddObject(m, "UF_SERVER_TRUST_ACCOUNT",
628 PyInt_FromLong(UF_SERVER_TRUST_ACCOUNT));
629 PyModule_AddObject(m, "UF_WORKSTATION_TRUST_ACCOUNT",
630 PyInt_FromLong(UF_WORKSTATION_TRUST_ACCOUNT));
631 PyModule_AddObject(m, "UF_INTERDOMAIN_TRUST_ACCOUNT",
632 PyInt_FromLong(UF_INTERDOMAIN_TRUST_ACCOUNT));
633 PyModule_AddObject(m, "UF_PASSWD_NOTREQD",
634 PyInt_FromLong(UF_PASSWD_NOTREQD));
635 PyModule_AddObject(m, "UF_ACCOUNTDISABLE",
636 PyInt_FromLong(UF_ACCOUNTDISABLE));
638 PyModule_AddObject(m, "UF_SCRIPT", PyInt_FromLong(UF_SCRIPT));
639 PyModule_AddObject(m, "UF_ACCOUNTDISABLE", PyInt_FromLong(UF_ACCOUNTDISABLE));
640 PyModule_AddObject(m, "UF_00000004", PyInt_FromLong(UF_00000004));
641 PyModule_AddObject(m, "UF_HOMEDIR_REQUIRED", PyInt_FromLong(UF_HOMEDIR_REQUIRED));
642 PyModule_AddObject(m, "UF_LOCKOUT", PyInt_FromLong(UF_LOCKOUT));
643 PyModule_AddObject(m, "UF_PASSWD_NOTREQD", PyInt_FromLong(UF_PASSWD_NOTREQD));
644 PyModule_AddObject(m, "UF_PASSWD_CANT_CHANGE", PyInt_FromLong(UF_PASSWD_CANT_CHANGE));
645 PyModule_AddObject(m, "UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED", PyInt_FromLong(UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED));
646 PyModule_AddObject(m, "UF_TEMP_DUPLICATE_ACCOUNT", PyInt_FromLong(UF_TEMP_DUPLICATE_ACCOUNT));
647 PyModule_AddObject(m, "UF_NORMAL_ACCOUNT", PyInt_FromLong(UF_NORMAL_ACCOUNT));
648 PyModule_AddObject(m, "UF_00000400", PyInt_FromLong(UF_00000400));
649 PyModule_AddObject(m, "UF_INTERDOMAIN_TRUST_ACCOUNT", PyInt_FromLong(UF_INTERDOMAIN_TRUST_ACCOUNT));
650 PyModule_AddObject(m, "UF_WORKSTATION_TRUST_ACCOUNT", PyInt_FromLong(UF_WORKSTATION_TRUST_ACCOUNT));
651 PyModule_AddObject(m, "UF_SERVER_TRUST_ACCOUNT", PyInt_FromLong(UF_SERVER_TRUST_ACCOUNT));
652 PyModule_AddObject(m, "UF_00004000", PyInt_FromLong(UF_00004000));
653 PyModule_AddObject(m, "UF_00008000", PyInt_FromLong(UF_00008000));
654 PyModule_AddObject(m, "UF_DONT_EXPIRE_PASSWD", PyInt_FromLong(UF_DONT_EXPIRE_PASSWD));
655 PyModule_AddObject(m, "UF_MNS_LOGON_ACCOUNT", PyInt_FromLong(UF_MNS_LOGON_ACCOUNT));
656 PyModule_AddObject(m, "UF_SMARTCARD_REQUIRED", PyInt_FromLong(UF_SMARTCARD_REQUIRED));
657 PyModule_AddObject(m, "UF_TRUSTED_FOR_DELEGATION", PyInt_FromLong(UF_TRUSTED_FOR_DELEGATION));
658 PyModule_AddObject(m, "UF_NOT_DELEGATED", PyInt_FromLong(UF_NOT_DELEGATED));
659 PyModule_AddObject(m, "UF_USE_DES_KEY_ONLY", PyInt_FromLong(UF_USE_DES_KEY_ONLY));
660 PyModule_AddObject(m, "UF_DONT_REQUIRE_PREAUTH", PyInt_FromLong(UF_DONT_REQUIRE_PREAUTH));
661 PyModule_AddObject(m, "UF_PASSWORD_EXPIRED", PyInt_FromLong(UF_PASSWORD_EXPIRED));
662 PyModule_AddObject(m, "UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION", PyInt_FromLong(UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION));
663 PyModule_AddObject(m, "UF_NO_AUTH_DATA_REQUIRED", PyInt_FromLong(UF_NO_AUTH_DATA_REQUIRED));
664 PyModule_AddObject(m, "UF_PARTIAL_SECRETS_ACCOUNT", PyInt_FromLong(UF_PARTIAL_SECRETS_ACCOUNT));
666 /* "groupType" flags */
667 PyModule_AddObject(m, "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP",
668 PyInt_FromLong(GTYPE_SECURITY_BUILTIN_LOCAL_GROUP));
669 PyModule_AddObject(m, "GTYPE_SECURITY_GLOBAL_GROUP",
670 PyInt_FromLong(GTYPE_SECURITY_GLOBAL_GROUP));
671 PyModule_AddObject(m, "GTYPE_SECURITY_DOMAIN_LOCAL_GROUP",
672 PyInt_FromLong(GTYPE_SECURITY_DOMAIN_LOCAL_GROUP));
673 PyModule_AddObject(m, "GTYPE_SECURITY_UNIVERSAL_GROUP",
674 PyInt_FromLong(GTYPE_SECURITY_UNIVERSAL_GROUP));
675 PyModule_AddObject(m, "GTYPE_DISTRIBUTION_GLOBAL_GROUP",
676 PyInt_FromLong(GTYPE_DISTRIBUTION_GLOBAL_GROUP));
677 PyModule_AddObject(m, "GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP",
678 PyInt_FromLong(GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP));
679 PyModule_AddObject(m, "GTYPE_DISTRIBUTION_UNIVERSAL_GROUP",
680 PyInt_FromLong(GTYPE_DISTRIBUTION_UNIVERSAL_GROUP));
682 /* "sAMAccountType" flags */
683 PyModule_AddObject(m, "ATYPE_NORMAL_ACCOUNT",
684 PyInt_FromLong(ATYPE_NORMAL_ACCOUNT));
685 PyModule_AddObject(m, "ATYPE_WORKSTATION_TRUST",
686 PyInt_FromLong(ATYPE_WORKSTATION_TRUST));
687 PyModule_AddObject(m, "ATYPE_INTERDOMAIN_TRUST",
688 PyInt_FromLong(ATYPE_INTERDOMAIN_TRUST));
689 PyModule_AddObject(m, "ATYPE_SECURITY_GLOBAL_GROUP",
690 PyInt_FromLong(ATYPE_SECURITY_GLOBAL_GROUP));
691 PyModule_AddObject(m, "ATYPE_SECURITY_LOCAL_GROUP",
692 PyInt_FromLong(ATYPE_SECURITY_LOCAL_GROUP));
693 PyModule_AddObject(m, "ATYPE_SECURITY_UNIVERSAL_GROUP",
694 PyInt_FromLong(ATYPE_SECURITY_UNIVERSAL_GROUP));
695 PyModule_AddObject(m, "ATYPE_DISTRIBUTION_GLOBAL_GROUP",
696 PyInt_FromLong(ATYPE_DISTRIBUTION_GLOBAL_GROUP));
697 PyModule_AddObject(m, "ATYPE_DISTRIBUTION_LOCAL_GROUP",
698 PyInt_FromLong(ATYPE_DISTRIBUTION_LOCAL_GROUP));
699 PyModule_AddObject(m, "ATYPE_DISTRIBUTION_UNIVERSAL_GROUP",
700 PyInt_FromLong(ATYPE_DISTRIBUTION_UNIVERSAL_GROUP));
702 /* "domainFunctionality", "forestFunctionality" flags in the rootDSE */
703 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2000",
704 PyInt_FromLong(DS_DOMAIN_FUNCTION_2000));
705 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003_MIXED",
706 PyInt_FromLong(DS_DOMAIN_FUNCTION_2003_MIXED));
707 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003",
708 PyInt_FromLong(DS_DOMAIN_FUNCTION_2003));
709 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008",
710 PyInt_FromLong(DS_DOMAIN_FUNCTION_2008));
711 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008_R2",
712 PyInt_FromLong(DS_DOMAIN_FUNCTION_2008_R2));
715 PyModule_AddObject(m, "SYSTEM_FLAG_CR_NTDS_NC",
716 PyInt_FromLong(SYSTEM_FLAG_CR_NTDS_NC));
717 PyModule_AddObject(m, "SYSTEM_FLAG_CR_NTDS_DOMAIN",
718 PyInt_FromLong(SYSTEM_FLAG_CR_NTDS_DOMAIN));
719 PyModule_AddObject(m, "SYSTEM_FLAG_CR_NTDS_NOT_GC_REPLICATED",
720 PyInt_FromLong(SYSTEM_FLAG_CR_NTDS_NOT_GC_REPLICATED));
721 PyModule_AddObject(m, "SYSTEM_FLAG_SCHEMA_BASE_OBJECT",
722 PyInt_FromLong(SYSTEM_FLAG_SCHEMA_BASE_OBJECT));
723 PyModule_AddObject(m, "SYSTEM_FLAG_ATTR_IS_RDN",
724 PyInt_FromLong(SYSTEM_FLAG_ATTR_IS_RDN));
725 PyModule_AddObject(m, "SYSTEM_FLAG_DISALLOW_MOVE_ON_DELETE",
726 PyInt_FromLong(SYSTEM_FLAG_DISALLOW_MOVE_ON_DELETE));
727 PyModule_AddObject(m, "SYSTEM_FLAG_DOMAIN_DISALLOW_MOVE",
728 PyInt_FromLong(SYSTEM_FLAG_DOMAIN_DISALLOW_MOVE));
729 PyModule_AddObject(m, "SYSTEM_FLAG_DOMAIN_DISALLOW_RENAME",
730 PyInt_FromLong(SYSTEM_FLAG_DOMAIN_DISALLOW_RENAME));
731 PyModule_AddObject(m, "SYSTEM_FLAG_CONFIG_ALLOW_LIMITED_MOVE",
732 PyInt_FromLong(SYSTEM_FLAG_CONFIG_ALLOW_LIMITED_MOVE));
733 PyModule_AddObject(m, "SYSTEM_FLAG_CONFIG_ALLOW_MOVE",
734 PyInt_FromLong(SYSTEM_FLAG_CONFIG_ALLOW_MOVE));
735 PyModule_AddObject(m, "SYSTEM_FLAG_CONFIG_ALLOW_RENAME",
736 PyInt_FromLong(SYSTEM_FLAG_CONFIG_ALLOW_RENAME));
737 PyModule_AddObject(m, "SYSTEM_FLAG_DISALLOW_DELETE",
738 PyInt_FromLong(SYSTEM_FLAG_DISALLOW_DELETE));
740 /* Kerberos encryption type constants */
741 PyModule_AddObject(m, "ENC_ALL_TYPES",
742 PyInt_FromLong(ENC_ALL_TYPES));
743 PyModule_AddObject(m, "ENC_CRC32",
744 PyInt_FromLong(ENC_CRC32));
745 PyModule_AddObject(m, "ENC_RSA_MD5",
746 PyInt_FromLong(ENC_RSA_MD5));
747 PyModule_AddObject(m, "ENC_RC4_HMAC_MD5",
748 PyInt_FromLong(ENC_RC4_HMAC_MD5));
749 PyModule_AddObject(m, "ENC_HMAC_SHA1_96_AES128",
750 PyInt_FromLong(ENC_HMAC_SHA1_96_AES128));
751 PyModule_AddObject(m, "ENC_HMAC_SHA1_96_AES256",
752 PyInt_FromLong(ENC_HMAC_SHA1_96_AES256));
754 PyModule_AddObject(m, "SEARCH_FLAG_ATTINDEX", PyInt_FromLong(SEARCH_FLAG_ATTINDEX));
755 PyModule_AddObject(m, "SEARCH_FLAG_PDNTATTINDEX", PyInt_FromLong(SEARCH_FLAG_PDNTATTINDEX));
756 PyModule_AddObject(m, "SEARCH_FLAG_ANR", PyInt_FromLong(SEARCH_FLAG_ANR));
757 PyModule_AddObject(m, "SEARCH_FLAG_PRESERVEONDELETE", PyInt_FromLong(SEARCH_FLAG_PRESERVEONDELETE));
758 PyModule_AddObject(m, "SEARCH_FLAG_COPY", PyInt_FromLong(SEARCH_FLAG_COPY));
759 PyModule_AddObject(m, "SEARCH_FLAG_TUPLEINDEX", PyInt_FromLong(SEARCH_FLAG_TUPLEINDEX));
760 PyModule_AddObject(m, "SEARCH_FLAG_SUBTREEATTRINDEX", PyInt_FromLong(SEARCH_FLAG_SUBTREEATTRINDEX));
761 PyModule_AddObject(m, "SEARCH_FLAG_CONFIDENTIAL", PyInt_FromLong(SEARCH_FLAG_CONFIDENTIAL));
762 PyModule_AddObject(m, "SEARCH_FLAG_NEVERVALUEAUDIT", PyInt_FromLong(SEARCH_FLAG_NEVERVALUEAUDIT));
763 PyModule_AddObject(m, "SEARCH_FLAG_RODC_ATTRIBUTE", PyInt_FromLong(SEARCH_FLAG_RODC_ATTRIBUTE));
765 PyModule_AddObject(m, "DS_FLAG_ATTR_NOT_REPLICATED", PyInt_FromLong(DS_FLAG_ATTR_NOT_REPLICATED));
766 PyModule_AddObject(m, "DS_FLAG_ATTR_REQ_PARTIAL_SET_MEMBER", PyInt_FromLong(DS_FLAG_ATTR_REQ_PARTIAL_SET_MEMBER));
767 PyModule_AddObject(m, "DS_FLAG_ATTR_IS_CONSTRUCTED", PyInt_FromLong(DS_FLAG_ATTR_IS_CONSTRUCTED));