summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_init.c264
1 files changed, 263 insertions, 1 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 2b0d1e5ee0..c5304824a9 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "dsdb/samdb/samdb.h"
#include "lib/util/dlinklist.h"
+#include "librpc/gen_ndr/drsuapi.h"
#define _PREFIX(uint32, oid) {uint32,oid,sizeof(oid)}
static const struct {
@@ -238,7 +239,7 @@ WERROR dsdb_class_from_ldb(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct
GET_GUID_LDB(msg, "schemaIDGUID", obj, schemaIDGUID);
GET_UINT32_LDB(msg, "objectClassCategory", obj, objectClassCategory);
- GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, True);
+ GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, False);
GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, True);
@@ -268,3 +269,264 @@ WERROR dsdb_class_from_ldb(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct
return WERR_OK;
}
+
+static const struct {
+ const char *name;
+ const char *oid;
+} name_mappings[] = {
+ { "cn", "2.5.4.3" },
+ { "name", "1.2.840.113556.1.4.1" },
+ { "lDAPDisplayName", "1.2.840.113556.1.2.460" },
+ { "attributeID", "1.2.840.113556.1.2.30" },
+ { "schemaIDGUID", "1.2.840.113556.1.4.148" },
+ { "mAPIID", "1.2.840.113556.1.2.49" },
+ { "attributeSecurityGUID", "1.2.840.113556.1.4.149" },
+ { "searchFlags", "1.2.840.113556.1.2.334" },
+ { "systemFlags", "1.2.840.113556.1.4.375" },
+ { "isMemberOfPartialAttributeSet", "1.2.840.113556.1.4.639" },
+ { "linkID", "1.2.840.113556.1.2.50" },
+ { "attributeSyntax", "1.2.840.113556.1.2.30" },
+ { "oMSyntax", "1.2.840.113556.1.2.231" },
+ { "oMObjectClass", "1.2.840.113556.1.2.218" },
+ { "isSingleValued", "1.2.840.113556.1.2.33" },
+ { "rangeLower", "1.2.840.113556.1.2.34" },
+ { "rangeUpper", "1.2.840.113556.1.2.35" },
+ { "extendedCharsAllowed", "1.2.840.113556.1.2.380" },
+ { "schemaFlagsEx", "1.2.840.113556.1.4.120" },
+ { "msDs-Schema-Extensions", "1.2.840.113556.1.4.1440" },
+ { "showInAdvancedViewOnly", "1.2.840.113556.1.2.169" },
+ { "adminDisplayName", "1.2.840.113556.1.2.194" },
+ { "adminDescription", "1.2.840.113556.1.2.226" },
+ { "classDisplayName", "1.2.840.113556.1.4.610" },
+ { "isEphemeral", "1.2.840.113556.1.4.1212" },
+ { "isDefunct", "1.2.840.113556.1.4.661" },
+ { "systemOnly", "1.2.840.113556.1.4.170" },
+ { "governsID", "1.2.840.113556.1.2.22" },
+ { "objectClassCategory", "1.2.840.113556.1.2.370" },
+ { "rDNAttID", "1.2.840.113556.1.2.26" },
+ { "defaultObjectCategory", "1.2.840.113556.1.4.783" },
+ { "subClassOf", "1.2.840.113556.1.2.21" },
+ { "systemAuxiliaryClass", "1.2.840.113556.1.4.198" },
+ { "systemPossSuperiors", "1.2.840.113556.1.4.195" },
+ { "systemMustContain", "1.2.840.113556.1.4.197" },
+ { "systemMayContain", "1.2.840.113556.1.4.196" },
+ { "auxiliaryClass", "1.2.840.113556.1.2.351" },
+ { "possSuperiors", "1.2.840.113556.1.2.8" },
+ { "mustContain", "1.2.840.113556.1.2.24" },
+ { "mayContain", "1.2.840.113556.1.2.25" },
+ { "defaultSecurityDescriptor", "1.2.840.113556.1.4.224" },
+ { "defaultHidingValue", "1.2.840.113556.1.4.518" },
+};
+
+static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct drsuapi_DsReplicaObject *obj,
+ const char *name,
+ uint32_t *idx)
+{
+ WERROR status;
+ uint32_t i, id;
+ const char *oid = NULL;
+
+ for(i=0; i < ARRAY_SIZE(name_mappings); i++) {
+ if (strcmp(name_mappings[i].name, name) != 0) continue;
+
+ oid = name_mappings[i].oid;
+ break;
+ }
+
+ if (!oid) {
+ return NULL;
+ }
+
+ status = dsdb_map_oid2int(oid, &id);
+ if (!W_ERROR_IS_OK(status)) {
+ return NULL;
+ }
+
+ for (i=0; i < obj->attribute_ctr.num_attributes; i++) {
+ if (obj->attribute_ctr.attributes[i].attid != id) continue;
+
+ if (idx) *idx = i;
+ return &obj->attribute_ctr.attributes[i];
+ }
+
+ return NULL;
+}
+
+#define GET_STRING_DS(r, attr, mem_ctx, p, elem, strict) do { \
+ struct drsuapi_DsReplicaAttribute *_a; \
+ _a = dsdb_find_object_attr_name(r, attr, NULL); \
+ if (strict && !_a) { \
+ d_printf("%s: %s == NULL\n", __location__, attr); \
+ return WERR_INVALID_PARAM; \
+ } \
+ if (strict && _a->value_ctr.unicode_string.num_values != 1) { \
+ d_printf("%s: %s num_values == %u\n", __location__, attr, \
+ _a->value_ctr.unicode_string.num_values); \
+ return WERR_INVALID_PARAM; \
+ } \
+ if (_a && _a->value_ctr.unicode_string.num_values >= 1) { \
+ (p)->elem = talloc_steal(mem_ctx, _a->value_ctr.unicode_string.values[0].string);\
+ } else { \
+ (p)->elem = NULL; \
+ } \
+} while (0)
+
+#define GET_BOOL_DS(r, attr, p, elem, strict) do { \
+ struct drsuapi_DsReplicaAttribute *_a; \
+ _a = dsdb_find_object_attr_name(r, attr, NULL); \
+ if (strict && !_a) { \
+ d_printf("%s: %s == NULL\n", __location__, attr); \
+ return WERR_INVALID_PARAM; \
+ } \
+ if (strict && _a->value_ctr.uint32.num_values != 1) { \
+ d_printf("%s: %s num_values == %u\n", __location__, attr, \
+ _a->value_ctr.uint32.num_values); \
+ return WERR_INVALID_PARAM; \
+ } \
+ if (strict && !_a->value_ctr.uint32.values[0].value) { \
+ d_printf("%s: %s value == NULL\n", __location__, attr); \
+ return WERR_INVALID_PARAM; \
+ } \
+ if (_a && _a->value_ctr.uint32.num_values >= 1 \
+ && _a->value_ctr.uint32.values[0].value) { \
+ (p)->elem = (*_a->value_ctr.uint32.values[0].value?True:False);\
+ } else { \
+ (p)->elem = False; \
+ } \
+} while (0)
+
+#define GET_UINT32_DS(r, attr, p, elem) do { \
+ struct drsuapi_DsReplicaAttribute *_a; \
+ _a = dsdb_find_object_attr_name(r, attr, NULL); \
+ if (_a && _a->value_ctr.uint32.num_values >= 1 \
+ && _a->value_ctr.uint32.values[0].value) { \
+ (p)->elem = *_a->value_ctr.uint32.values[0].value;\
+ } else { \
+ (p)->elem = 0; \
+ } \
+} while (0)
+
+#define GET_GUID_DS(r, attr, p, elem) do { \
+ struct drsuapi_DsReplicaAttribute *_a; \
+ _a = dsdb_find_object_attr_name(r, attr, NULL); \
+ if (_a && _a->value_ctr.guid.num_values >= 1 \
+ && _a->value_ctr.guid.values[0].guid) { \
+ (p)->elem = *_a->value_ctr.guid.values[0].guid;\
+ } else { \
+ ZERO_STRUCT((p)->elem);\
+ } \
+} while (0)
+
+#define GET_BLOB_DS(r, attr, mem_ctx, p, elem) do { \
+ struct drsuapi_DsReplicaAttribute *_a; \
+ _a = dsdb_find_object_attr_name(r, attr, NULL); \
+ if (_a && _a->value_ctr.data_blob.num_values >= 1 \
+ && _a->value_ctr.data_blob.values[0].data) { \
+ (p)->elem = *_a->value_ctr.data_blob.values[0].data;\
+ talloc_steal(mem_ctx, (p)->elem.data); \
+ } else { \
+ ZERO_STRUCT((p)->elem);\
+ }\
+} while (0)
+
+WERROR dsdb_attribute_from_drsuapi(struct drsuapi_DsReplicaObject *r, TALLOC_CTX *mem_ctx, struct dsdb_attribute *attr)
+{
+ WERROR status;
+
+ GET_STRING_DS(r, "name", mem_ctx, attr, cn, True);
+ GET_STRING_DS(r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
+ GET_UINT32_DS(r, "attributeID", attr, attributeID_id);
+ status = dsdb_map_int2oid(attr->attributeID_id, mem_ctx, &attr->attributeID_oid);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("%s: '%s': unable to map attributeID 0x%08X: %s\n",
+ __location__, attr->lDAPDisplayName, attr->attributeID_id,
+ win_errstr(status)));
+ return status;
+ }
+ GET_GUID_DS(r, "schemaIDGUID", attr, schemaIDGUID);
+ GET_UINT32_DS(r, "mAPIID", attr, mAPIID);
+
+ GET_GUID_DS(r, "attributeSecurityGUID", attr, attributeSecurityGUID);
+
+ GET_UINT32_DS(r, "searchFlags", attr, searchFlags);
+ GET_UINT32_DS(r, "systemFlags", attr, systemFlags);
+ GET_BOOL_DS(r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
+ GET_UINT32_DS(r, "linkID", attr, linkID);
+
+ GET_UINT32_DS(r, "attributeSyntax", attr, attributeSyntax_id);
+ status = dsdb_map_int2oid(attr->attributeSyntax_id, mem_ctx, &attr->attributeSyntax_oid);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("%s: '%s': unable to map attributeSyntax 0x%08X: %s\n",
+ __location__, attr->lDAPDisplayName, attr->attributeSyntax_id,
+ win_errstr(status)));
+ return status;
+ }
+ GET_UINT32_DS(r, "oMSyntax", attr, oMSyntax);
+ GET_BLOB_DS(r, "oMObjectClass", mem_ctx, attr, oMObjectClass);
+
+ GET_BOOL_DS(r, "isSingleValued", attr, isSingleValued, True);
+ GET_UINT32_DS(r, "rangeLower", attr, rangeLower);
+ GET_UINT32_DS(r, "rangeUpper", attr, rangeUpper);
+ GET_BOOL_DS(r, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
+
+ GET_UINT32_DS(r, "schemaFlagsEx", attr, schemaFlagsEx);
+ GET_BLOB_DS(r, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
+
+ GET_BOOL_DS(r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
+ GET_STRING_DS(r, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
+ GET_STRING_DS(r, "adminDescription", mem_ctx, attr, adminDescription, False);
+ GET_STRING_DS(r, "classDisplayName", mem_ctx, attr, classDisplayName, False);
+ GET_BOOL_DS(r, "isEphemeral", attr, isEphemeral, False);
+ GET_BOOL_DS(r, "isDefunct", attr, isDefunct, False);
+ GET_BOOL_DS(r, "systemOnly", attr, systemOnly, False);
+
+ return WERR_OK;
+}
+
+WERROR dsdb_class_from_drsuapi(struct drsuapi_DsReplicaObject *r, TALLOC_CTX *mem_ctx, struct dsdb_class *obj)
+{
+ WERROR status;
+
+ GET_STRING_DS(r, "name", mem_ctx, obj, cn, True);
+ GET_STRING_DS(r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
+ GET_UINT32_DS(r, "governsID", obj, governsID_id);
+ status = dsdb_map_int2oid(obj->governsID_id, mem_ctx, &obj->governsID_oid);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("%s: '%s': unable to map governsID 0x%08X: %s\n",
+ __location__, obj->lDAPDisplayName, obj->governsID_id,
+ win_errstr(status)));
+ return status;
+ }
+ GET_GUID_DS(r, "schemaIDGUID", obj, schemaIDGUID);
+
+ GET_UINT32_DS(r, "objectClassCategory", obj, objectClassCategory);
+ GET_STRING_DS(r, "rDNAttID", mem_ctx, obj, rDNAttID, False);
+ GET_STRING_DS(r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
+
+ GET_STRING_DS(r, "subClassOf", mem_ctx, obj, subClassOf, True);
+
+ GET_STRING_DS(r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, False);
+ obj->systemPossSuperiors= NULL;
+ obj->systemMustContain = NULL;
+ obj->systemMayContain = NULL;
+
+ GET_STRING_DS(r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, False);
+ obj->possSuperiors = NULL;
+ obj->mustContain = NULL;
+ obj->mayContain = NULL;
+
+ GET_STRING_DS(r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
+
+ GET_UINT32_DS(r, "schemaFlagsEx", obj, schemaFlagsEx);
+ GET_BLOB_DS(r, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
+
+ GET_BOOL_DS(r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
+ GET_STRING_DS(r, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
+ GET_STRING_DS(r, "adminDescription", mem_ctx, obj, adminDescription, False);
+ GET_STRING_DS(r, "classDisplayName", mem_ctx, obj, classDisplayName, False);
+ GET_BOOL_DS(r, "defaultHidingValue", obj, defaultHidingValue, False);
+ GET_BOOL_DS(r, "isDefunct", obj, isDefunct, False);
+ GET_BOOL_DS(r, "systemOnly", obj, systemOnly, False);
+
+ return WERR_OK;
+}