diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-06-09 18:57:52 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-06-15 10:51:34 +1000 |
commit | 6a2f7fe04c2c658e59fba01f7346303676b121b3 (patch) | |
tree | 14382729671b087e42a5e00156007cf302d00f40 /source4/dsdb/schema | |
parent | ecf782da87b67b8d977aa1bbfce21f1b6ed8288a (diff) | |
download | samba-6a2f7fe04c2c658e59fba01f7346303676b121b3.tar.gz samba-6a2f7fe04c2c658e59fba01f7346303676b121b3.tar.bz2 samba-6a2f7fe04c2c658e59fba01f7346303676b121b3.zip |
s4:dsdb Use the schema from our local provision to decode the schema
This works on the assumption that the schema partition can only
contain schema objects.
We may need to pass down some kind of 'relax' to the DRS -> LDB
conversion code, so that it allows incomplete conversions, so that we
don't fail if a new attribute is present, and we can't decode it.
This would then be resolved the second time we do the conversion.
Andrew Bartlett
Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r-- | source4/dsdb/schema/schema_init.c | 367 |
1 files changed, 0 insertions, 367 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 8e47f1228d..2cf5af685d 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -806,370 +806,3 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, *schema_out = schema; return LDB_SUCCESS; } - - -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.32" }, - { "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" }, - { "msDS-IntId", "1.2.840.113556.1.4.1716" }, -}; - -static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb_schema *schema, - struct drsuapi_DsReplicaObject *obj, - const char *name, - uint32_t *idx) -{ - WERROR status; - unsigned int i; - uint32_t attid; - 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_schema_pfm_make_attid(schema->prefixmap, oid, &attid); - 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 != attid) continue; - - if (idx) *idx = i; - return &obj->attribute_ctr.attributes[i]; - } - - return NULL; -} - -#define GET_STRING_DS(s, r, attr, mem_ctx, p, elem, strict) do { \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - if (strict && !_a) { \ - d_printf("%s: %s == NULL\n", __location__, attr); \ - return WERR_INVALID_PARAM; \ - } \ - if (strict && _a->value_ctr.num_values != 1) { \ - d_printf("%s: %s num_values == %u\n", __location__, attr, \ - _a->value_ctr.num_values); \ - return WERR_INVALID_PARAM; \ - } \ - if (_a && _a->value_ctr.num_values >= 1) { \ - size_t _ret; \ - if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, \ - _a->value_ctr.values[0].blob->data, \ - _a->value_ctr.values[0].blob->length, \ - (void **)discard_const(&(p)->elem), &_ret, false)) { \ - DEBUG(0,("%s: invalid data!\n", attr)); \ - dump_data(0, \ - _a->value_ctr.values[0].blob->data, \ - _a->value_ctr.values[0].blob->length); \ - return WERR_FOOBAR; \ - } \ - } else { \ - (p)->elem = NULL; \ - } \ -} while (0) - -#define GET_UINT32_LIST_DS(s, r, attr, mem_ctx, p, elem) do { \ - unsigned int list_counter; \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - (p)->elem = _a ? talloc_array(mem_ctx, uint32_t, _a->value_ctr.num_values + 1) : NULL; \ - for (list_counter=0; \ - _a && list_counter < _a->value_ctr.num_values; \ - list_counter++) { \ - if (_a->value_ctr.values[list_counter].blob->length != 4) { \ - return WERR_INVALID_PARAM; \ - } \ - (p)->elem[list_counter] = IVAL(_a->value_ctr.values[list_counter].blob->data, 0); \ - } \ - if (_a) (p)->elem[list_counter] = 0; \ -} while (0) - -#define GET_BOOL_DS(s, r, attr, p, elem, strict) do { \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - if (strict && !_a) { \ - d_printf("%s: %s == NULL\n", __location__, attr); \ - return WERR_INVALID_PARAM; \ - } \ - if (strict && _a->value_ctr.num_values != 1) { \ - d_printf("%s: %s num_values == %u\n", __location__, attr, \ - (unsigned int)_a->value_ctr.num_values); \ - return WERR_INVALID_PARAM; \ - } \ - if (strict && !_a->value_ctr.values[0].blob) { \ - d_printf("%s: %s data == NULL\n", __location__, attr); \ - return WERR_INVALID_PARAM; \ - } \ - if (strict && _a->value_ctr.values[0].blob->length != 4) { \ - d_printf("%s: %s length == %u\n", __location__, attr, \ - (unsigned int)_a->value_ctr.values[0].blob->length); \ - return WERR_INVALID_PARAM; \ - } \ - if (_a && _a->value_ctr.num_values >= 1 \ - && _a->value_ctr.values[0].blob \ - && _a->value_ctr.values[0].blob->length == 4) { \ - (p)->elem = (IVAL(_a->value_ctr.values[0].blob->data,0)?true:false);\ - } else { \ - (p)->elem = false; \ - } \ -} while (0) - -#define GET_UINT32_DS(s, r, attr, p, elem, def_val) do { \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - if (_a && _a->value_ctr.num_values >= 1 \ - && _a->value_ctr.values[0].blob \ - && _a->value_ctr.values[0].blob->length == 4) { \ - (p)->elem = IVAL(_a->value_ctr.values[0].blob->data,0);\ - } else { \ - (p)->elem = def_val; \ - } \ -} while (0) - -#define GET_UINT32_PTR_DS(s, r, attr, p, elem) do { \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - if (_a && _a->value_ctr.num_values >= 1 \ - && _a->value_ctr.values[0].blob \ - && _a->value_ctr.values[0].blob->length == 4) { \ - (p)->elem = talloc(mem_ctx, uint32_t); \ - if (!(p)->elem) { \ - d_printf("%s: talloc failed for %s\n", __location__, attr); \ - return WERR_NOMEM; \ - } \ - *(p)->elem = IVAL(_a->value_ctr.values[0].blob->data,0);\ - } else { \ - (p)->elem = NULL; \ - } \ -} while (0) - -#define GET_GUID_DS(s, r, attr, mem_ctx, p, elem) do { \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - if (_a && _a->value_ctr.num_values >= 1 \ - && _a->value_ctr.values[0].blob \ - && _a->value_ctr.values[0].blob->length == 16) { \ - NTSTATUS _nt_status = GUID_from_ndr_blob(_a->value_ctr.values[0].blob, &(p)->elem); \ - if (!NT_STATUS_IS_OK(_nt_status)) { \ - return ntstatus_to_werror(_nt_status); \ - } \ - } else { \ - ZERO_STRUCT((p)->elem);\ - } \ -} while (0) - -#define GET_BLOB_DS(s, r, attr, mem_ctx, p, elem) do { \ - struct drsuapi_DsReplicaAttribute *_a; \ - _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ - if (_a && _a->value_ctr.num_values >= 1 \ - && _a->value_ctr.values[0].blob) { \ - (p)->elem = *_a->value_ctr.values[0].blob;\ - talloc_steal(mem_ctx, (p)->elem.data); \ - } else { \ - ZERO_STRUCT((p)->elem);\ - }\ -} while (0) - -WERROR dsdb_attribute_from_drsuapi(struct ldb_context *ldb, - struct dsdb_schema *schema, - struct drsuapi_DsReplicaObject *r, - TALLOC_CTX *mem_ctx, - struct dsdb_attribute *attr) -{ - WERROR status; - - GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, true); - GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true); - GET_UINT32_DS(schema, r, "attributeID", attr, attributeID_id, 0xFFFFFFFF); - status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, 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; - } - /* fetch msDS-IntId to be used in resolving ATTRTYP values */ - GET_UINT32_DS(schema, r, "msDS-IntId", attr, msDS_IntId, 0); - - GET_GUID_DS(schema, r, "schemaIDGUID", mem_ctx, attr, schemaIDGUID); - GET_UINT32_DS(schema, r, "mAPIID", attr, mAPIID, 0); - - GET_GUID_DS(schema, r, "attributeSecurityGUID", mem_ctx, attr, attributeSecurityGUID); - - attr->objectGUID = r->identifier->guid; - - GET_UINT32_DS(schema, r, "searchFlags", attr, searchFlags, 0); - GET_UINT32_DS(schema, r, "systemFlags", attr, systemFlags, 0); - GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false); - GET_UINT32_DS(schema, r, "linkID", attr, linkID, 0); - - GET_UINT32_DS(schema, r, "attributeSyntax", attr, attributeSyntax_id, 0xFFFFFFFF); - status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, 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(schema, r, "oMSyntax", attr, oMSyntax, 0); - GET_BLOB_DS(schema, r, "oMObjectClass", mem_ctx, attr, oMObjectClass); - - GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, true); - GET_UINT32_PTR_DS(schema, r, "rangeLower", attr, rangeLower); - GET_UINT32_PTR_DS(schema, r, "rangeUpper", attr, rangeUpper); - GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, false); - - GET_UINT32_DS(schema, r, "schemaFlagsEx", attr, schemaFlagsEx, 0); - GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions); - - GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false); - GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, false); - GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, false); - GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, false); - GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, false); - GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, false); - GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, false); - - attr->syntax = dsdb_syntax_for_attribute(attr); - if (!attr->syntax) { - DEBUG(0,(__location__ ": Unknown schema syntax for %s\n", - attr->lDAPDisplayName)); - return WERR_DS_ATT_SCHEMA_REQ_SYNTAX; - } - - if (dsdb_schema_setup_ldb_schema_attribute(ldb, attr) != LDB_SUCCESS) { - DEBUG(0,(__location__ ": Unknown schema syntax for %s\n", - attr->lDAPDisplayName)); - return WERR_DS_ATT_SCHEMA_REQ_SYNTAX; - } - - return WERR_OK; -} - -WERROR dsdb_class_from_drsuapi(struct ldb_context *ldb, - struct dsdb_schema *schema, - struct drsuapi_DsReplicaObject *r, - TALLOC_CTX *mem_ctx, - struct dsdb_class *obj) -{ - WERROR status; - struct drsuapi_DsReplicaAttribute *attr; - DATA_BLOB blob; - - GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, true); - GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true); - GET_UINT32_DS(schema, r, "governsID", obj, governsID_id, 0xFFFFFFFF); - status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, 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(schema, r, "schemaIDGUID", mem_ctx, obj, schemaIDGUID); - - obj->objectGUID = r->identifier->guid; - - GET_UINT32_DS(schema, r, "objectClassCategory", obj, objectClassCategory, 0); - GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, false); - - attr = dsdb_find_object_attr_name(schema, r, "defaultObjectCategory", NULL); - - if (!attr || attr->value_ctr.num_values != 1 || !attr->value_ctr.values[0].blob) { - d_printf("%s: no defaultObjectCategory supplied\n", __location__); - return WERR_INVALID_PARAM; - } - - status = dsdb_syntax_one_DN_drsuapi_to_ldb(mem_ctx, ldb, find_syntax_map_by_standard_oid(LDB_SYNTAX_DN), - attr->value_ctr.values[0].blob, &blob); - if (!W_ERROR_IS_OK(status)) { - return status; - } - obj->defaultObjectCategory = (char *)blob.data; - - GET_UINT32_DS(schema, r, "subClassOf", obj, subClassOf_id, 0); - - GET_UINT32_LIST_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass_ids); - GET_UINT32_LIST_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass_ids); - - GET_UINT32_LIST_DS(schema, r, "systemMustContain", mem_ctx, obj, systemMustContain_ids); - GET_UINT32_LIST_DS(schema, r, "systemMayContain", mem_ctx, obj, systemMayContain_ids); - GET_UINT32_LIST_DS(schema, r, "mustContain", mem_ctx, obj, mustContain_ids); - GET_UINT32_LIST_DS(schema, r, "mayContain", mem_ctx, obj, mayContain_ids); - - GET_UINT32_LIST_DS(schema, r, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors_ids); - GET_UINT32_LIST_DS(schema, r, "possSuperiors", mem_ctx, obj, possSuperiors_ids); - - GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false); - - GET_UINT32_DS(schema, r, "schemaFlagsEx", obj, schemaFlagsEx, 0); - GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions); - - GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false); - GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, false); - GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, false); - GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, false); - GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, false); - GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, false); - GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, false); - - return WERR_OK; -} - |