diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/schema/schema_syntax.c | 102 | ||||
-rw-r--r-- | source4/librpc/idl/drsuapi.idl | 11 |
2 files changed, 110 insertions, 3 deletions
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index 69b99261ee..6b82968d2e 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -856,6 +856,104 @@ static WERROR dsdb_syntax_DN_ldb_to_drsuapi(const struct dsdb_schema *schema, return WERR_OK; } +static WERROR dsdb_syntax_DN_BINARY_drsuapi_to_ldb(const struct dsdb_schema *schema, + const struct dsdb_attribute *attr, + const struct drsuapi_DsReplicaAttribute *in, + TALLOC_CTX *mem_ctx, + struct ldb_message_element *out) +{ + uint32_t i; + + out->flags = 0; + out->name = talloc_strdup(mem_ctx, attr->lDAPDisplayName); + W_ERROR_HAVE_NO_MEMORY(out->name); + + out->num_values = in->value_ctr.data_blob.num_values; + out->values = talloc_array(mem_ctx, struct ldb_val, out->num_values); + W_ERROR_HAVE_NO_MEMORY(out->values); + + for (i=0; i < out->num_values; i++) { + struct drsuapi_DsReplicaObjectIdentifier3Binary id3b; + char *binary; + char *str; + NTSTATUS status; + + if (in->value_ctr.data_blob.values[i].data == NULL) { + return WERR_FOOBAR; + } + + if (in->value_ctr.data_blob.values[i].data->length == 0) { + return WERR_FOOBAR; + } + + status = ndr_pull_struct_blob(in->value_ctr.data_blob.values[i].data, + out->values, &id3b, + (ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3Binary); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + /* TODO: handle id3.guid and id3.sid */ + binary = data_blob_hex_string(out->values, &id3b.binary); + W_ERROR_HAVE_NO_MEMORY(binary); + + str = talloc_asprintf(out->values, "B:%u:%s:%s", + id3b.binary.length * 2, /* because of 2 hex chars per byte */ + binary, + id3b.dn); + W_ERROR_HAVE_NO_MEMORY(str); + + /* TODO: handle id3.guid and id3.sid */ + out->values[i] = data_blob_string_const(str); + } + + return WERR_OK; +} + +static WERROR dsdb_syntax_DN_BINARY_ldb_to_drsuapi(const struct dsdb_schema *schema, + const struct dsdb_attribute *attr, + const struct ldb_message_element *in, + TALLOC_CTX *mem_ctx, + struct drsuapi_DsReplicaAttribute *out) +{ + uint32_t i; + DATA_BLOB *blobs; + + if (attr->attributeID_id == 0xFFFFFFFF) { + return WERR_FOOBAR; + } + + out->attid = attr->attributeID_id; + out->value_ctr.data_blob.num_values = in->num_values; + out->value_ctr.data_blob.values = talloc_array(mem_ctx, + struct drsuapi_DsAttributeValueDataBlob, + in->num_values); + W_ERROR_HAVE_NO_MEMORY(out->value_ctr.data_blob.values); + + blobs = talloc_array(mem_ctx, DATA_BLOB, in->num_values); + W_ERROR_HAVE_NO_MEMORY(blobs); + + for (i=0; i < in->num_values; i++) { + NTSTATUS status; + struct drsuapi_DsReplicaObjectIdentifier3Binary id3b; + + out->value_ctr.data_blob.values[i].data = &blobs[i]; + + /* TODO: handle id3b.guid and id3b.sid, id3.binary */ + ZERO_STRUCT(id3b); + id3b.dn = (const char *)in->values[i].data; + id3b.binary = data_blob(NULL, 0); + + status = ndr_push_struct_blob(&blobs[i], blobs, &id3b, + (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3Binary); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + } + + return WERR_OK; +} + #define OMOBJECTCLASS(val) { .length = sizeof(val) - 1, .data = discard_const_p(uint8_t, val) } static const struct dsdb_syntax dsdb_syntaxes[] = { @@ -991,8 +1089,8 @@ static const struct dsdb_syntax dsdb_syntaxes[] = { .oMSyntax = 127, .oMObjectClass = OMOBJECTCLASS("\x2a\x86\x48\x86\xf7\x14\x01\x01\x01\x0b"), .attributeSyntax_oid = "2.5.5.7", - .drsuapi_to_ldb = dsdb_syntax_FOOBAR_drsuapi_to_ldb, - .ldb_to_drsuapi = dsdb_syntax_FOOBAR_ldb_to_drsuapi, + .drsuapi_to_ldb = dsdb_syntax_DN_BINARY_drsuapi_to_ldb, + .ldb_to_drsuapi = dsdb_syntax_DN_BINARY_ldb_to_drsuapi, },{ /* not used in w2k3 forest */ .name = "Object(OR-Name)", diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl index d7b4e1705b..0176fdd709 100644 --- a/source4/librpc/idl/drsuapi.idl +++ b/source4/librpc/idl/drsuapi.idl @@ -487,6 +487,16 @@ interface drsuapi [flag(STR_SIZE4|STR_CHARLEN)] string dn; } drsuapi_DsReplicaObjectIdentifier3; + typedef [public,gensize] struct { + [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary(r, ndr->flags))] uint32 __ndr_size; + [value(ndr_size_dom_sid28(&r->sid,ndr->flags))] uint32 __ndr_size_sid; + GUID guid; + dom_sid28 sid; + [flag(STR_SIZE4|STR_CHARLEN)] string dn; + [value(r->binary.length + 4)] uint32 __ndr_size_binary; + [flag(NDR_REMAINING)] DATA_BLOB binary; + } drsuapi_DsReplicaObjectIdentifier3Binary; + typedef struct { [range(0,10485760),value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(object, ndr->flags))] uint32 __ndr_size; [subcontext(4),subcontext_size(__ndr_size)] drsuapi_DsReplicaObjectIdentifier3 *object; @@ -548,7 +558,6 @@ interface drsuapi [case(DRSUAPI_ATTRIBUTE_hasMasterNCs)] drsuapi_DsAttributeValueCtrDNString dn_string; [case(DRSUAPI_ATTRIBUTE_dMDLocation)] drsuapi_DsAttributeValueCtrDNString dn_string; [case(DRSUAPI_ATTRIBUTE_fSMORoleOwner)] drsuapi_DsAttributeValueCtrDNString dn_string; - [case(DRSUAPI_ATTRIBUTE_wellKnownObjects)] drsuapi_DsAttributeValueCtrDNString dn_string; [case(DRSUAPI_ATTRIBUTE_serverReference)] drsuapi_DsAttributeValueCtrDNString dn_string; [case(DRSUAPI_ATTRIBUTE_serverReferenceBL)] drsuapi_DsAttributeValueCtrDNString dn_string; [case(DRSUAPI_ATTRIBUTE_msDS_HasDomainNCs)] drsuapi_DsAttributeValueCtrDNString dn_string; |