2 Unix SMB/CIFS mplementation.
5 Copyright (C) Stefan Metzmacher <metze@samba.org> 2006-2007
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2006-2008
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "dsdb/samdb/samdb.h"
25 #include "lib/ldb/include/ldb_errors.h"
26 #include "../lib/util/dlinklist.h"
27 #include "librpc/gen_ndr/ndr_misc.h"
28 #include "librpc/gen_ndr/ndr_drsuapi.h"
29 #include "librpc/gen_ndr/ndr_drsblobs.h"
30 #include "param/param.h"
31 #include "lib/ldb/include/ldb_module.h"
32 #include "../lib/util/asn1.h"
35 struct dsdb_schema *dsdb_new_schema(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience)
37 struct dsdb_schema *schema = talloc_zero(mem_ctx, struct dsdb_schema);
42 schema->iconv_convenience = iconv_convenience;
47 WERROR dsdb_load_prefixmap_from_drsuapi(struct dsdb_schema *schema,
48 const struct drsuapi_DsReplicaOIDMapping_Ctr *ctr)
51 const char *schema_info;
52 struct dsdb_schema_prefixmap *pfm;
54 werr = dsdb_schema_pfm_from_drsuapi_pfm(ctr, true, schema, &pfm, &schema_info);
55 W_ERROR_NOT_OK_RETURN(werr);
57 /* set loaded prefixMap */
58 talloc_free(schema->prefixmap);
59 schema->prefixmap = pfm;
61 talloc_free(discard_const(schema->schema_info));
62 schema->schema_info = schema_info;
67 static WERROR _dsdb_prefixmap_from_ldb_val(const struct ldb_val *pfm_ldb_val,
68 struct smb_iconv_convenience *iconv_convenience,
70 struct dsdb_schema_prefixmap **_pfm)
73 enum ndr_err_code ndr_err;
74 struct prefixMapBlob pfm_blob;
76 TALLOC_CTX *temp_ctx = talloc_new(mem_ctx);
77 W_ERROR_HAVE_NO_MEMORY(temp_ctx);
79 ndr_err = ndr_pull_struct_blob(pfm_ldb_val, temp_ctx,
80 iconv_convenience, &pfm_blob,
81 (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
82 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
83 NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
84 talloc_free(temp_ctx);
85 return ntstatus_to_werror(nt_status);
88 if (pfm_blob.version != PREFIX_MAP_VERSION_DSDB) {
89 DEBUG(0,("_dsdb_prefixmap_from_ldb_val: pfm_blob->version incorrect\n"));
90 talloc_free(temp_ctx);
91 return WERR_VERSION_PARSE_ERROR;
94 /* call the drsuapi version */
95 werr = dsdb_schema_pfm_from_drsuapi_pfm(&pfm_blob.ctr.dsdb, false, mem_ctx, _pfm, NULL);
97 talloc_free(temp_ctx);
102 WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema *schema,
103 const struct ldb_val *prefixMap,
104 const struct ldb_val *schemaInfo)
107 const char *schema_info;
108 struct dsdb_schema_prefixmap *pfm;
111 /* verify input params */
112 if (schemaInfo->length != 21) {
113 return WERR_INVALID_PARAMETER;
115 if (schemaInfo->data[0] != 0xFF) {
116 return WERR_INVALID_PARAMETER;
119 mem_ctx = talloc_new(schema);
120 W_ERROR_HAVE_NO_MEMORY(mem_ctx);
122 /* fetch prefixMap */
123 status = _dsdb_prefixmap_from_ldb_val(prefixMap,
124 schema->iconv_convenience,
126 W_ERROR_NOT_OK_RETURN(status);
128 /* decode schema_info */
129 schema_info = hex_encode_talloc(mem_ctx,
133 talloc_free(mem_ctx);
137 /* store prefixMap and schema_info into cached Schema */
138 talloc_free(schema->prefixmap);
139 schema->prefixmap = talloc_steal(schema, pfm);
141 talloc_free(discard_const(schema->schema_info));
142 schema->schema_info = talloc_steal(schema, schema_info);
144 /* clean up locally allocated mem */
145 talloc_free(mem_ctx);
150 WERROR dsdb_get_oid_mappings_drsuapi(const struct dsdb_schema *schema,
151 bool include_schema_info,
153 struct drsuapi_DsReplicaOIDMapping_Ctr **_ctr)
155 return dsdb_drsuapi_pfm_from_schema_pfm(schema->prefixmap,
156 include_schema_info ? schema->schema_info : NULL,
160 WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema,
162 struct ldb_val *prefixMap,
163 struct ldb_val *schemaInfo)
166 enum ndr_err_code ndr_err;
167 struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
168 struct prefixMapBlob pfm;
170 status = dsdb_get_oid_mappings_drsuapi(schema, false, mem_ctx, &ctr);
171 W_ERROR_NOT_OK_RETURN(status);
173 pfm.version = PREFIX_MAP_VERSION_DSDB;
177 ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, schema->iconv_convenience, &pfm, (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
179 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
180 NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
181 return ntstatus_to_werror(nt_status);
184 *schemaInfo = strhex_to_data_blob(mem_ctx, schema->schema_info);
185 W_ERROR_HAVE_NO_MEMORY(schemaInfo->data);
192 * this function is called from within a ldb transaction from the schema_fsmo module
194 WERROR dsdb_create_prefix_mapping(struct ldb_context *ldb, struct dsdb_schema *schema, const char *full_oid)
197 uint32_t num_prefixes;
198 struct dsdb_schema_oid_prefix *prefixes;
202 mem_ctx = talloc_new(ldb);
203 W_ERROR_HAVE_NO_MEMORY(mem_ctx);
205 /* Read prefixes from disk*/
206 status = dsdb_read_prefixes_from_ldb( mem_ctx, ldb, &num_prefixes, &prefixes );
207 if (!W_ERROR_IS_OK(status)) {
208 DEBUG(0,("dsdb_create_prefix_mapping: dsdb_read_prefixes_from_ldb: %s\n",
209 win_errstr(status)));
210 talloc_free(mem_ctx);
214 /* Check if there is a prefix for the oid in the prefixes array*/
215 status = dsdb_find_prefix_for_oid( num_prefixes, prefixes, full_oid, &out );
216 if (W_ERROR_IS_OK(status)) {
218 talloc_free(mem_ctx);
220 } else if (!W_ERROR_EQUAL(WERR_DS_NO_MSDS_INTID, status)) {
222 DEBUG(0,("dsdb_create_prefix_mapping: dsdb_find_prefix_for_oid: %s\n",
223 win_errstr(status)));
224 talloc_free(mem_ctx);
228 /* Create the new mapping for the prefix of full_oid */
229 status = dsdb_prefix_map_update(mem_ctx, &num_prefixes, &prefixes, full_oid);
230 if (!W_ERROR_IS_OK(status)) {
231 DEBUG(0,("dsdb_create_prefix_mapping: dsdb_prefix_map_update: %s\n",
232 win_errstr(status)));
233 talloc_free(mem_ctx);
237 talloc_free(schema->prefixes);
238 schema->prefixes = talloc_steal(schema, prefixes);
239 schema->num_prefixes = num_prefixes;
241 /* Update prefixMap in ldb*/
242 status = dsdb_write_prefixes_from_schema_to_ldb(mem_ctx, ldb, schema);
243 if (!W_ERROR_IS_OK(status)) {
244 DEBUG(0,("dsdb_create_prefix_mapping: dsdb_write_prefixes_to_ldb: %s\n",
245 win_errstr(status)));
246 talloc_free(mem_ctx);
250 DEBUG(2,(__location__ " Added prefixMap %s - now have %u prefixes\n",
251 full_oid, num_prefixes));
253 talloc_free(mem_ctx);
257 WERROR dsdb_prefix_map_update(TALLOC_CTX *mem_ctx, uint32_t *num_prefixes, struct dsdb_schema_oid_prefix **prefixes, const char *oid)
259 uint32_t new_num_prefixes, index_new_prefix, new_entry_id;
260 const char* lastDotOffset;
263 new_num_prefixes = *num_prefixes + 1;
264 index_new_prefix = *num_prefixes;
267 * this is the algorithm we use to create new mappings for now
269 * TODO: find what algorithm windows use
271 new_entry_id = (*num_prefixes)<<16;
273 /* Extract the prefix from the oid*/
274 lastDotOffset = strrchr(oid, '.');
275 if (lastDotOffset == NULL) {
276 DEBUG(0,("dsdb_prefix_map_update: failed to find the last dot\n"));
277 return WERR_NOT_FOUND;
280 /* Calculate the size of the remainig string that should be the prefix of it */
281 size = strlen(oid) - strlen(lastDotOffset);
283 DEBUG(0,("dsdb_prefix_map_update: size of the remaining string invalid\n"));
287 /* Create a spot in the prefixMap for one more prefix*/
288 (*prefixes) = talloc_realloc(mem_ctx, *prefixes, struct dsdb_schema_oid_prefix, new_num_prefixes);
289 W_ERROR_HAVE_NO_MEMORY(*prefixes);
291 /* Add the new prefix entry*/
292 (*prefixes)[index_new_prefix].id = new_entry_id;
293 (*prefixes)[index_new_prefix].oid = talloc_strndup(mem_ctx, oid, size);
294 (*prefixes)[index_new_prefix].oid_len = strlen((*prefixes)[index_new_prefix].oid);
296 /* Increase num_prefixes because new prefix has been added */
302 WERROR dsdb_find_prefix_for_oid(uint32_t num_prefixes, const struct dsdb_schema_oid_prefix *prefixes, const char *in, uint32_t *out)
310 /* make oid prefix, i.e. oid w/o last subidentifier */
311 pstr = strrchr(in, '.');
312 if (!pstr) return WERR_INVALID_PARAM;
313 if (pstr < in) return WERR_INVALID_PARAM;
314 if ((pstr - in) < 4) return WERR_INVALID_PARAM;
316 oid_prefix = talloc_strndup(0, in, pstr - in);
318 for (i=0; i < num_prefixes; i++) {
319 if (strcmp(prefixes[i].oid, oid_prefix) == 0) {
324 talloc_free(oid_prefix);
326 if (i < num_prefixes) {
327 /* move next to '.' char */
330 val = strtoul(pstr, &end_str, 10);
331 if (end_str[0] != '\0') {
332 return WERR_INVALID_PARAM;
333 } else if (val > 0xFFFF) {
334 return WERR_INVALID_PARAM;
337 *out = prefixes[i].id | val;
341 DEBUG(5,(__location__ " Failed to find oid %s - have %u prefixes\n", in, num_prefixes));
343 return WERR_DS_NO_MSDS_INTID;
346 WERROR dsdb_write_prefixes_from_schema_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
347 const struct dsdb_schema *schema)
349 struct ldb_message *msg = ldb_msg_new(mem_ctx);
350 struct ldb_dn *schema_dn;
351 struct prefixMapBlob pm;
352 struct ldb_val ndr_blob;
353 enum ndr_err_code ndr_err;
361 schema_dn = samdb_schema_dn(ldb);
363 DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: no schema dn present\n"));
367 pm.version = PREFIX_MAP_VERSION_DSDB;
368 pm.ctr.dsdb.num_mappings = schema->num_prefixes;
369 pm.ctr.dsdb.mappings = talloc_array(msg,
370 struct drsuapi_DsReplicaOIDMapping,
371 pm.ctr.dsdb.num_mappings);
372 if (!pm.ctr.dsdb.mappings) {
377 for (i=0; i < schema->num_prefixes; i++) {
380 if (!ber_write_partial_OID_String(pm.ctr.dsdb.mappings, &oid_blob, schema->prefixes[i].oid)) {
381 DEBUG(0, ("write_partial_OID failed for %s", schema->prefixes[i].oid));
382 return WERR_INTERNAL_ERROR;
385 pm.ctr.dsdb.mappings[i].id_prefix = schema->prefixes[i].id>>16;
386 pm.ctr.dsdb.mappings[i].oid.length = oid_blob.length;
387 pm.ctr.dsdb.mappings[i].oid.binary_oid = oid_blob.data;
390 ndr_err = ndr_push_struct_blob(&ndr_blob, msg,
391 lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
393 (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
394 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
400 ret = ldb_msg_add_value(msg, "prefixMap", &ndr_blob, NULL);
403 DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: ldb_msg_add_value failed\n"));
407 ret = samdb_replace( ldb, msg, msg );
411 DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: samdb_replace failed\n"));
418 WERROR dsdb_read_prefixes_from_ldb(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap **_pfm)
422 const struct ldb_val *prefix_val;
423 struct smb_iconv_convenience *iconv_convenience;
424 struct ldb_dn *schema_dn;
425 struct ldb_result *schema_res = NULL;
426 static const char *schema_attrs[] = {
431 schema_dn = samdb_schema_dn(ldb);
433 DEBUG(0,("dsdb_read_prefixes_from_ldb: no schema dn present\n"));
437 ldb_ret = ldb_search(ldb, mem_ctx, &schema_res, schema_dn, LDB_SCOPE_BASE, schema_attrs, NULL);
438 if (ldb_ret == LDB_ERR_NO_SUCH_OBJECT) {
439 DEBUG(0,("dsdb_read_prefixes_from_ldb: no prefix map present\n"));
440 talloc_free(schema_res);
442 } else if (ldb_ret != LDB_SUCCESS) {
443 DEBUG(0,("dsdb_read_prefixes_from_ldb: failed to search the schema head\n"));
444 talloc_free(schema_res);
448 prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap");
450 DEBUG(0,("dsdb_read_prefixes_from_ldb: no prefixMap attribute found\n"));
451 talloc_free(schema_res);
455 iconv_convenience = lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm"));
457 werr = _dsdb_prefixmap_from_ldb_val(prefix_val,
461 talloc_free(schema_res);
462 W_ERROR_NOT_OK_RETURN(werr);
468 this will be replaced with something that looks at the right part of
469 the schema once we know where unique indexing information is hidden
471 static bool dsdb_schema_unique_attribute(const char *attr)
473 const char *attrs[] = { "objectGUID", "objectSID" , NULL };
475 for (i=0;attrs[i];i++) {
476 if (strcasecmp(attr, attrs[i]) == 0) {
485 setup the ldb_schema_attribute field for a dsdb_attribute
487 static int dsdb_schema_setup_ldb_schema_attribute(struct ldb_context *ldb,
488 struct dsdb_attribute *attr)
490 const char *syntax = attr->syntax->ldb_syntax;
491 const struct ldb_schema_syntax *s;
492 struct ldb_schema_attribute *a;
495 syntax = attr->syntax->ldap_oid;
498 s = ldb_samba_syntax_by_lDAPDisplayName(ldb, attr->lDAPDisplayName);
500 s = ldb_samba_syntax_by_name(ldb, syntax);
503 s = ldb_standard_syntax_by_name(ldb, syntax);
507 return LDB_ERR_OPERATIONS_ERROR;
510 attr->ldb_schema_attribute = a = talloc(attr, struct ldb_schema_attribute);
511 if (attr->ldb_schema_attribute == NULL) {
513 return LDB_ERR_OPERATIONS_ERROR;
516 a->name = attr->lDAPDisplayName;
520 if (dsdb_schema_unique_attribute(a->name)) {
521 a->flags |= LDB_ATTR_FLAG_UNIQUE_INDEX;
523 if (attr->isSingleValued) {
524 a->flags |= LDB_ATTR_FLAG_SINGLE_VALUE;
532 #define GET_STRING_LDB(msg, attr, mem_ctx, p, elem, strict) do { \
533 const struct ldb_val *get_string_val = ldb_msg_find_ldb_val(msg, attr); \
534 if (get_string_val == NULL) { \
536 d_printf("%s: %s == NULL\n", __location__, attr); \
537 return WERR_INVALID_PARAM; \
542 (p)->elem = talloc_strndup(mem_ctx, \
543 (const char *)get_string_val->data, \
544 get_string_val->length); \
546 d_printf("%s: talloc_strndup failed for %s\n", __location__, attr); \
552 #define GET_STRING_LIST_LDB(msg, attr, mem_ctx, p, elem, strict) do { \
553 int get_string_list_counter; \
554 struct ldb_message_element *get_string_list_el = ldb_msg_find_element(msg, attr); \
555 if (get_string_list_el == NULL) { \
557 d_printf("%s: %s == NULL\n", __location__, attr); \
558 return WERR_INVALID_PARAM; \
564 (p)->elem = talloc_array(mem_ctx, const char *, get_string_list_el->num_values + 1); \
565 for (get_string_list_counter=0; \
566 get_string_list_counter < get_string_list_el->num_values; \
567 get_string_list_counter++) { \
568 (p)->elem[get_string_list_counter] = talloc_strndup((p)->elem, \
569 (const char *)get_string_list_el->values[get_string_list_counter].data, \
570 get_string_list_el->values[get_string_list_counter].length); \
571 if (!(p)->elem[get_string_list_counter]) { \
572 d_printf("%s: talloc_strndup failed for %s\n", __location__, attr); \
575 (p)->elem[get_string_list_counter+1] = NULL; \
577 talloc_steal(mem_ctx, (p)->elem); \
580 #define GET_BOOL_LDB(msg, attr, p, elem, strict) do { \
582 str = samdb_result_string(msg, attr, NULL);\
585 d_printf("%s: %s == NULL\n", __location__, attr); \
586 return WERR_INVALID_PARAM; \
590 } else if (strcasecmp("TRUE", str) == 0) { \
592 } else if (strcasecmp("FALSE", str) == 0) { \
595 d_printf("%s: %s == %s\n", __location__, attr, str); \
596 return WERR_INVALID_PARAM; \
600 #define GET_UINT32_LDB(msg, attr, p, elem) do { \
601 (p)->elem = samdb_result_uint(msg, attr, 0);\
604 #define GET_UINT32_PTR_LDB(msg, attr, p, elem) do { \
605 uint64_t _v = samdb_result_uint64(msg, attr, UINT64_MAX);\
606 if (_v == UINT64_MAX) { \
608 } else if (_v > UINT32_MAX) { \
609 d_printf("%s: %s == 0x%llX\n", __location__, \
610 attr, (unsigned long long)_v); \
611 return WERR_INVALID_PARAM; \
613 (p)->elem = talloc(mem_ctx, uint32_t); \
615 d_printf("%s: talloc failed for %s\n", __location__, attr); \
618 *(p)->elem = (uint32_t)_v; \
622 #define GET_GUID_LDB(msg, attr, p, elem) do { \
623 (p)->elem = samdb_result_guid(msg, attr);\
626 #define GET_BLOB_LDB(msg, attr, mem_ctx, p, elem) do { \
627 const struct ldb_val *_val;\
628 _val = ldb_msg_find_ldb_val(msg, attr);\
631 talloc_steal(mem_ctx, (p)->elem.data);\
633 ZERO_STRUCT((p)->elem);\
637 WERROR dsdb_attribute_from_ldb(struct ldb_context *ldb,
638 const struct dsdb_schema *schema,
639 struct ldb_message *msg,
641 struct dsdb_attribute *attr)
645 GET_STRING_LDB(msg, "cn", mem_ctx, attr, cn, false);
646 GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true);
647 GET_STRING_LDB(msg, "attributeID", mem_ctx, attr, attributeID_oid, true);
648 if (schema->num_prefixes == 0) {
649 /* set an invalid value */
650 attr->attributeID_id = 0xFFFFFFFF;
652 status = dsdb_schema_pfm_make_attid(schema->prefixmap,
653 attr->attributeID_oid,
654 &attr->attributeID_id);
655 if (!W_ERROR_IS_OK(status)) {
656 DEBUG(0,("%s: '%s': unable to map attributeID %s: %s\n",
657 __location__, attr->lDAPDisplayName, attr->attributeID_oid,
658 win_errstr(status)));
662 GET_GUID_LDB(msg, "schemaIDGUID", attr, schemaIDGUID);
663 GET_UINT32_LDB(msg, "mAPIID", attr, mAPIID);
665 GET_GUID_LDB(msg, "attributeSecurityGUID", attr, attributeSecurityGUID);
667 GET_UINT32_LDB(msg, "searchFlags", attr, searchFlags);
668 GET_UINT32_LDB(msg, "systemFlags", attr, systemFlags);
669 GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false);
670 GET_UINT32_LDB(msg, "linkID", attr, linkID);
672 GET_STRING_LDB(msg, "attributeSyntax", mem_ctx, attr, attributeSyntax_oid, true);
673 if (schema->num_prefixes == 0) {
674 /* set an invalid value */
675 attr->attributeSyntax_id = 0xFFFFFFFF;
677 status = dsdb_schema_pfm_make_attid(schema->prefixmap,
678 attr->attributeSyntax_oid,
679 &attr->attributeSyntax_id);
680 if (!W_ERROR_IS_OK(status)) {
681 DEBUG(0,("%s: '%s': unable to map attributeSyntax_ %s: %s\n",
682 __location__, attr->lDAPDisplayName, attr->attributeSyntax_oid,
683 win_errstr(status)));
687 GET_UINT32_LDB(msg, "oMSyntax", attr, oMSyntax);
688 GET_BLOB_LDB(msg, "oMObjectClass", mem_ctx, attr, oMObjectClass);
690 GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, true);
691 GET_UINT32_PTR_LDB(msg, "rangeLower", attr, rangeLower);
692 GET_UINT32_PTR_LDB(msg, "rangeUpper", attr, rangeUpper);
693 GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, false);
695 GET_UINT32_LDB(msg, "schemaFlagsEx", attr, schemaFlagsEx);
696 GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
698 GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false);
699 GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, attr, adminDisplayName, false);
700 GET_STRING_LDB(msg, "adminDescription", mem_ctx, attr, adminDescription, false);
701 GET_STRING_LDB(msg, "classDisplayName", mem_ctx, attr, classDisplayName, false);
702 GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, false);
703 GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, false);
704 GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, false);
706 attr->syntax = dsdb_syntax_for_attribute(attr);
708 return WERR_DS_ATT_SCHEMA_REQ_SYNTAX;
711 if (dsdb_schema_setup_ldb_schema_attribute(ldb, attr) != LDB_SUCCESS) {
712 return WERR_DS_ATT_SCHEMA_REQ_SYNTAX;
718 WERROR dsdb_class_from_ldb(const struct dsdb_schema *schema,
719 struct ldb_message *msg,
721 struct dsdb_class *obj)
725 GET_STRING_LDB(msg, "cn", mem_ctx, obj, cn, false);
726 GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true);
727 GET_STRING_LDB(msg, "governsID", mem_ctx, obj, governsID_oid, true);
728 if (schema->num_prefixes == 0) {
729 /* set an invalid value */
730 obj->governsID_id = 0xFFFFFFFF;
732 status = dsdb_schema_pfm_make_attid(schema->prefixmap,
735 if (!W_ERROR_IS_OK(status)) {
736 DEBUG(0,("%s: '%s': unable to map governsID %s: %s\n",
737 __location__, obj->lDAPDisplayName, obj->governsID_oid,
738 win_errstr(status)));
742 GET_GUID_LDB(msg, "schemaIDGUID", obj, schemaIDGUID);
744 GET_UINT32_LDB(msg, "objectClassCategory", obj, objectClassCategory);
745 GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, false);
746 GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
748 GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, true);
750 GET_STRING_LIST_LDB(msg, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, false);
751 GET_STRING_LIST_LDB(msg, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, false);
753 GET_STRING_LIST_LDB(msg, "systemMustContain", mem_ctx, obj, systemMustContain, false);
754 GET_STRING_LIST_LDB(msg, "systemMayContain", mem_ctx, obj, systemMayContain, false);
755 GET_STRING_LIST_LDB(msg, "mustContain", mem_ctx, obj, mustContain, false);
756 GET_STRING_LIST_LDB(msg, "mayContain", mem_ctx, obj, mayContain, false);
758 GET_STRING_LIST_LDB(msg, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, false);
759 GET_STRING_LIST_LDB(msg, "possSuperiors", mem_ctx, obj, possSuperiors, false);
761 GET_STRING_LDB(msg, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
763 GET_UINT32_LDB(msg, "schemaFlagsEx", obj, schemaFlagsEx);
764 GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
766 GET_BOOL_LDB(msg, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false);
767 GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, obj, adminDisplayName, false);
768 GET_STRING_LDB(msg, "adminDescription", mem_ctx, obj, adminDescription, false);
769 GET_STRING_LDB(msg, "classDisplayName", mem_ctx, obj, classDisplayName, false);
770 GET_BOOL_LDB(msg, "defaultHidingValue", obj, defaultHidingValue, false);
771 GET_BOOL_LDB(msg, "isDefunct", obj, isDefunct, false);
772 GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, false);
777 #define dsdb_oom(error_string, mem_ctx) *error_string = talloc_asprintf(mem_ctx, "dsdb out of memory at %s:%d\n", __FILE__, __LINE__)
780 Create a DSDB schema from the ldb results provided. This is called
781 directly when the schema is provisioned from an on-disk LDIF file, or
782 from dsdb_schema_from_schema_dn in schema_fsmo
785 int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
786 struct smb_iconv_convenience *iconv_convenience,
787 struct ldb_result *schema_res,
788 struct ldb_result *attrs_res, struct ldb_result *objectclass_res,
789 struct dsdb_schema **schema_out,
794 const struct ldb_val *prefix_val;
795 const struct ldb_val *info_val;
796 struct ldb_val info_val_default;
797 struct dsdb_schema *schema;
799 schema = dsdb_new_schema(mem_ctx, iconv_convenience);
801 dsdb_oom(error_string, mem_ctx);
802 return LDB_ERR_OPERATIONS_ERROR;
805 prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap");
807 *error_string = talloc_asprintf(mem_ctx,
808 "schema_fsmo_init: no prefixMap attribute found");
809 DEBUG(0,(__location__ ": %s\n", *error_string));
810 return LDB_ERR_CONSTRAINT_VIOLATION;
812 info_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "schemaInfo");
814 info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000");
815 if (!info_val_default.data) {
816 dsdb_oom(error_string, mem_ctx);
817 return LDB_ERR_OPERATIONS_ERROR;
819 info_val = &info_val_default;
822 status = dsdb_load_oid_mappings_ldb(schema, prefix_val, info_val);
823 if (!W_ERROR_IS_OK(status)) {
824 *error_string = talloc_asprintf(mem_ctx,
825 "schema_fsmo_init: failed to load oid mappings: %s",
827 DEBUG(0,(__location__ ": %s\n", *error_string));
828 return LDB_ERR_CONSTRAINT_VIOLATION;
831 for (i=0; i < attrs_res->count; i++) {
832 struct dsdb_attribute *sa;
834 sa = talloc_zero(schema, struct dsdb_attribute);
836 dsdb_oom(error_string, mem_ctx);
837 return LDB_ERR_OPERATIONS_ERROR;
840 status = dsdb_attribute_from_ldb(ldb, schema, attrs_res->msgs[i], sa, sa);
841 if (!W_ERROR_IS_OK(status)) {
842 *error_string = talloc_asprintf(mem_ctx,
843 "schema_fsmo_init: failed to load attribute definition: %s:%s",
844 ldb_dn_get_linearized(attrs_res->msgs[i]->dn),
846 DEBUG(0,(__location__ ": %s\n", *error_string));
847 return LDB_ERR_CONSTRAINT_VIOLATION;
850 DLIST_ADD(schema->attributes, sa);
853 for (i=0; i < objectclass_res->count; i++) {
854 struct dsdb_class *sc;
856 sc = talloc_zero(schema, struct dsdb_class);
858 dsdb_oom(error_string, mem_ctx);
859 return LDB_ERR_OPERATIONS_ERROR;
862 status = dsdb_class_from_ldb(schema, objectclass_res->msgs[i], sc, sc);
863 if (!W_ERROR_IS_OK(status)) {
864 *error_string = talloc_asprintf(mem_ctx,
865 "schema_fsmo_init: failed to load class definition: %s:%s",
866 ldb_dn_get_linearized(objectclass_res->msgs[i]->dn),
868 DEBUG(0,(__location__ ": %s\n", *error_string));
869 return LDB_ERR_CONSTRAINT_VIOLATION;
872 DLIST_ADD(schema->classes, sc);
875 schema->fsmo.master_dn = ldb_msg_find_attr_as_dn(ldb, schema, schema_res->msgs[0], "fSMORoleOwner");
876 if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), schema->fsmo.master_dn) == 0) {
877 schema->fsmo.we_are_master = true;
879 schema->fsmo.we_are_master = false;
882 DEBUG(5, ("schema_fsmo_init: we are master: %s\n",
883 (schema->fsmo.we_are_master?"yes":"no")));
885 *schema_out = schema;
890 static const struct {
893 } name_mappings[] = {
895 { "name", "1.2.840.113556.1.4.1" },
896 { "lDAPDisplayName", "1.2.840.113556.1.2.460" },
897 { "attributeID", "1.2.840.113556.1.2.30" },
898 { "schemaIDGUID", "1.2.840.113556.1.4.148" },
899 { "mAPIID", "1.2.840.113556.1.2.49" },
900 { "attributeSecurityGUID", "1.2.840.113556.1.4.149" },
901 { "searchFlags", "1.2.840.113556.1.2.334" },
902 { "systemFlags", "1.2.840.113556.1.4.375" },
903 { "isMemberOfPartialAttributeSet", "1.2.840.113556.1.4.639" },
904 { "linkID", "1.2.840.113556.1.2.50" },
905 { "attributeSyntax", "1.2.840.113556.1.2.32" },
906 { "oMSyntax", "1.2.840.113556.1.2.231" },
907 { "oMObjectClass", "1.2.840.113556.1.2.218" },
908 { "isSingleValued", "1.2.840.113556.1.2.33" },
909 { "rangeLower", "1.2.840.113556.1.2.34" },
910 { "rangeUpper", "1.2.840.113556.1.2.35" },
911 { "extendedCharsAllowed", "1.2.840.113556.1.2.380" },
912 { "schemaFlagsEx", "1.2.840.113556.1.4.120" },
913 { "msDs-Schema-Extensions", "1.2.840.113556.1.4.1440" },
914 { "showInAdvancedViewOnly", "1.2.840.113556.1.2.169" },
915 { "adminDisplayName", "1.2.840.113556.1.2.194" },
916 { "adminDescription", "1.2.840.113556.1.2.226" },
917 { "classDisplayName", "1.2.840.113556.1.4.610" },
918 { "isEphemeral", "1.2.840.113556.1.4.1212" },
919 { "isDefunct", "1.2.840.113556.1.4.661" },
920 { "systemOnly", "1.2.840.113556.1.4.170" },
921 { "governsID", "1.2.840.113556.1.2.22" },
922 { "objectClassCategory", "1.2.840.113556.1.2.370" },
923 { "rDNAttID", "1.2.840.113556.1.2.26" },
924 { "defaultObjectCategory", "1.2.840.113556.1.4.783" },
925 { "subClassOf", "1.2.840.113556.1.2.21" },
926 { "systemAuxiliaryClass", "1.2.840.113556.1.4.198" },
927 { "systemPossSuperiors", "1.2.840.113556.1.4.195" },
928 { "systemMustContain", "1.2.840.113556.1.4.197" },
929 { "systemMayContain", "1.2.840.113556.1.4.196" },
930 { "auxiliaryClass", "1.2.840.113556.1.2.351" },
931 { "possSuperiors", "1.2.840.113556.1.2.8" },
932 { "mustContain", "1.2.840.113556.1.2.24" },
933 { "mayContain", "1.2.840.113556.1.2.25" },
934 { "defaultSecurityDescriptor", "1.2.840.113556.1.4.224" },
935 { "defaultHidingValue", "1.2.840.113556.1.4.518" },
938 static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb_schema *schema,
939 struct drsuapi_DsReplicaObject *obj,
945 const char *oid = NULL;
947 for(i=0; i < ARRAY_SIZE(name_mappings); i++) {
948 if (strcmp(name_mappings[i].name, name) != 0) continue;
950 oid = name_mappings[i].oid;
958 status = dsdb_schema_pfm_make_attid(schema->prefixmap, oid, &attid);
959 if (!W_ERROR_IS_OK(status)) {
963 for (i=0; i < obj->attribute_ctr.num_attributes; i++) {
964 if (obj->attribute_ctr.attributes[i].attid != attid) continue;
967 return &obj->attribute_ctr.attributes[i];
973 #define GET_STRING_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
974 struct drsuapi_DsReplicaAttribute *_a; \
975 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
976 if (strict && !_a) { \
977 d_printf("%s: %s == NULL\n", __location__, attr); \
978 return WERR_INVALID_PARAM; \
980 if (strict && _a->value_ctr.num_values != 1) { \
981 d_printf("%s: %s num_values == %u\n", __location__, attr, \
982 _a->value_ctr.num_values); \
983 return WERR_INVALID_PARAM; \
985 if (_a && _a->value_ctr.num_values >= 1) { \
987 if (!convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
988 _a->value_ctr.values[0].blob->data, \
989 _a->value_ctr.values[0].blob->length, \
990 (void **)discard_const(&(p)->elem), &_ret, false)) { \
991 DEBUG(0,("%s: invalid data!\n", attr)); \
993 _a->value_ctr.values[0].blob->data, \
994 _a->value_ctr.values[0].blob->length); \
995 return WERR_FOOBAR; \
1002 #define GET_UINT32_LIST_DS(s, r, attr, mem_ctx, p, elem) do { \
1004 struct drsuapi_DsReplicaAttribute *_a; \
1005 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1006 (p)->elem = _a ? talloc_array(mem_ctx, uint32_t, _a->value_ctr.num_values + 1) : NULL; \
1007 for (list_counter=0; \
1008 _a && list_counter < _a->value_ctr.num_values; \
1010 if (_a->value_ctr.values[list_counter].blob->length != 4) { \
1011 return WERR_INVALID_PARAM; \
1013 (p)->elem[list_counter] = IVAL(_a->value_ctr.values[list_counter].blob->data, 0); \
1015 if (_a) (p)->elem[list_counter] = 0; \
1018 #define GET_DN_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
1019 struct drsuapi_DsReplicaAttribute *_a; \
1020 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1021 if (strict && !_a) { \
1022 d_printf("%s: %s == NULL\n", __location__, attr); \
1023 return WERR_INVALID_PARAM; \
1025 if (strict && _a->value_ctr.num_values != 1) { \
1026 d_printf("%s: %s num_values == %u\n", __location__, attr, \
1027 _a->value_ctr.num_values); \
1028 return WERR_INVALID_PARAM; \
1030 if (strict && !_a->value_ctr.values[0].blob) { \
1031 d_printf("%s: %s data == NULL\n", __location__, attr); \
1032 return WERR_INVALID_PARAM; \
1034 if (_a && _a->value_ctr.num_values >= 1 \
1035 && _a->value_ctr.values[0].blob) { \
1036 struct drsuapi_DsReplicaObjectIdentifier3 _id3; \
1037 enum ndr_err_code _ndr_err; \
1038 _ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
1039 mem_ctx, s->iconv_convenience, &_id3,\
1040 (ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3);\
1041 if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
1042 NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \
1043 return ntstatus_to_werror(_nt_status); \
1045 (p)->elem = _id3.dn; \
1051 #define GET_BOOL_DS(s, r, attr, p, elem, strict) do { \
1052 struct drsuapi_DsReplicaAttribute *_a; \
1053 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1054 if (strict && !_a) { \
1055 d_printf("%s: %s == NULL\n", __location__, attr); \
1056 return WERR_INVALID_PARAM; \
1058 if (strict && _a->value_ctr.num_values != 1) { \
1059 d_printf("%s: %s num_values == %u\n", __location__, attr, \
1060 (unsigned int)_a->value_ctr.num_values); \
1061 return WERR_INVALID_PARAM; \
1063 if (strict && !_a->value_ctr.values[0].blob) { \
1064 d_printf("%s: %s data == NULL\n", __location__, attr); \
1065 return WERR_INVALID_PARAM; \
1067 if (strict && _a->value_ctr.values[0].blob->length != 4) { \
1068 d_printf("%s: %s length == %u\n", __location__, attr, \
1069 (unsigned int)_a->value_ctr.values[0].blob->length); \
1070 return WERR_INVALID_PARAM; \
1072 if (_a && _a->value_ctr.num_values >= 1 \
1073 && _a->value_ctr.values[0].blob \
1074 && _a->value_ctr.values[0].blob->length == 4) { \
1075 (p)->elem = (IVAL(_a->value_ctr.values[0].blob->data,0)?true:false);\
1077 (p)->elem = false; \
1081 #define GET_UINT32_DS(s, r, attr, p, elem) do { \
1082 struct drsuapi_DsReplicaAttribute *_a; \
1083 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1084 if (_a && _a->value_ctr.num_values >= 1 \
1085 && _a->value_ctr.values[0].blob \
1086 && _a->value_ctr.values[0].blob->length == 4) { \
1087 (p)->elem = IVAL(_a->value_ctr.values[0].blob->data,0);\
1093 #define GET_UINT32_PTR_DS(s, r, attr, p, elem) do { \
1094 struct drsuapi_DsReplicaAttribute *_a; \
1095 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1096 if (_a && _a->value_ctr.num_values >= 1 \
1097 && _a->value_ctr.values[0].blob \
1098 && _a->value_ctr.values[0].blob->length == 4) { \
1099 (p)->elem = talloc(mem_ctx, uint32_t); \
1101 d_printf("%s: talloc failed for %s\n", __location__, attr); \
1102 return WERR_NOMEM; \
1104 *(p)->elem = IVAL(_a->value_ctr.values[0].blob->data,0);\
1110 #define GET_GUID_DS(s, r, attr, mem_ctx, p, elem) do { \
1111 struct drsuapi_DsReplicaAttribute *_a; \
1112 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1113 if (_a && _a->value_ctr.num_values >= 1 \
1114 && _a->value_ctr.values[0].blob \
1115 && _a->value_ctr.values[0].blob->length == 16) { \
1116 enum ndr_err_code _ndr_err; \
1117 _ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
1118 mem_ctx, s->iconv_convenience, &(p)->elem, \
1119 (ndr_pull_flags_fn_t)ndr_pull_GUID); \
1120 if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
1121 NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \
1122 return ntstatus_to_werror(_nt_status); \
1125 ZERO_STRUCT((p)->elem);\
1129 #define GET_BLOB_DS(s, r, attr, mem_ctx, p, elem) do { \
1130 struct drsuapi_DsReplicaAttribute *_a; \
1131 _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
1132 if (_a && _a->value_ctr.num_values >= 1 \
1133 && _a->value_ctr.values[0].blob) { \
1134 (p)->elem = *_a->value_ctr.values[0].blob;\
1135 talloc_steal(mem_ctx, (p)->elem.data); \
1137 ZERO_STRUCT((p)->elem);\
1141 WERROR dsdb_attribute_from_drsuapi(struct ldb_context *ldb,
1142 struct dsdb_schema *schema,
1143 struct drsuapi_DsReplicaObject *r,
1144 TALLOC_CTX *mem_ctx,
1145 struct dsdb_attribute *attr)
1149 GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, true);
1150 GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true);
1151 GET_UINT32_DS(schema, r, "attributeID", attr, attributeID_id);
1152 status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attr->attributeID_id,
1153 mem_ctx, &attr->attributeID_oid);
1154 if (!W_ERROR_IS_OK(status)) {
1155 DEBUG(0,("%s: '%s': unable to map attributeID 0x%08X: %s\n",
1156 __location__, attr->lDAPDisplayName, attr->attributeID_id,
1157 win_errstr(status)));
1160 GET_GUID_DS(schema, r, "schemaIDGUID", mem_ctx, attr, schemaIDGUID);
1161 GET_UINT32_DS(schema, r, "mAPIID", attr, mAPIID);
1163 GET_GUID_DS(schema, r, "attributeSecurityGUID", mem_ctx, attr, attributeSecurityGUID);
1165 GET_UINT32_DS(schema, r, "searchFlags", attr, searchFlags);
1166 GET_UINT32_DS(schema, r, "systemFlags", attr, systemFlags);
1167 GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false);
1168 GET_UINT32_DS(schema, r, "linkID", attr, linkID);
1170 GET_UINT32_DS(schema, r, "attributeSyntax", attr, attributeSyntax_id);
1171 status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attr->attributeSyntax_id,
1172 mem_ctx, &attr->attributeSyntax_oid);
1173 if (!W_ERROR_IS_OK(status)) {
1174 DEBUG(0,("%s: '%s': unable to map attributeSyntax 0x%08X: %s\n",
1175 __location__, attr->lDAPDisplayName, attr->attributeSyntax_id,
1176 win_errstr(status)));
1179 GET_UINT32_DS(schema, r, "oMSyntax", attr, oMSyntax);
1180 GET_BLOB_DS(schema, r, "oMObjectClass", mem_ctx, attr, oMObjectClass);
1182 GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, true);
1183 GET_UINT32_PTR_DS(schema, r, "rangeLower", attr, rangeLower);
1184 GET_UINT32_PTR_DS(schema, r, "rangeUpper", attr, rangeUpper);
1185 GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, false);
1187 GET_UINT32_DS(schema, r, "schemaFlagsEx", attr, schemaFlagsEx);
1188 GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
1190 GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false);
1191 GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, false);
1192 GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, false);
1193 GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, false);
1194 GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, false);
1195 GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, false);
1196 GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, false);
1198 attr->syntax = dsdb_syntax_for_attribute(attr);
1199 if (!attr->syntax) {
1200 return WERR_DS_ATT_SCHEMA_REQ_SYNTAX;
1203 if (dsdb_schema_setup_ldb_schema_attribute(ldb, attr) != LDB_SUCCESS) {
1204 return WERR_DS_ATT_SCHEMA_REQ_SYNTAX;
1210 WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
1211 struct drsuapi_DsReplicaObject *r,
1212 TALLOC_CTX *mem_ctx,
1213 struct dsdb_class *obj)
1217 GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, true);
1218 GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true);
1219 GET_UINT32_DS(schema, r, "governsID", obj, governsID_id);
1220 status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, obj->governsID_id,
1221 mem_ctx, &obj->governsID_oid);
1222 if (!W_ERROR_IS_OK(status)) {
1223 DEBUG(0,("%s: '%s': unable to map governsID 0x%08X: %s\n",
1224 __location__, obj->lDAPDisplayName, obj->governsID_id,
1225 win_errstr(status)));
1228 GET_GUID_DS(schema, r, "schemaIDGUID", mem_ctx, obj, schemaIDGUID);
1230 GET_UINT32_DS(schema, r, "objectClassCategory", obj, objectClassCategory);
1231 GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, false);
1232 GET_DN_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
1234 GET_UINT32_DS(schema, r, "subClassOf", obj, subClassOf_id);
1236 GET_UINT32_LIST_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass_ids);
1237 GET_UINT32_LIST_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass_ids);
1239 GET_UINT32_LIST_DS(schema, r, "systemMustContain", mem_ctx, obj, systemMustContain_ids);
1240 GET_UINT32_LIST_DS(schema, r, "systemMayContain", mem_ctx, obj, systemMayContain_ids);
1241 GET_UINT32_LIST_DS(schema, r, "mustContain", mem_ctx, obj, mustContain_ids);
1242 GET_UINT32_LIST_DS(schema, r, "mayContain", mem_ctx, obj, mayContain_ids);
1244 GET_UINT32_LIST_DS(schema, r, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors_ids);
1245 GET_UINT32_LIST_DS(schema, r, "possSuperiors", mem_ctx, obj, possSuperiors_ids);
1247 GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
1249 GET_UINT32_DS(schema, r, "schemaFlagsEx", obj, schemaFlagsEx);
1250 GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
1252 GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false);
1253 GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, false);
1254 GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, false);
1255 GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, false);
1256 GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, false);
1257 GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, false);
1258 GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, false);