summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-01-01 19:35:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:35:49 -0500
commit7ffdd1246d10cf969fe733e05595664921cdfb81 (patch)
tree39b7f72c4957546579e8fdb14792d1cd1c8779f6 /source4/dsdb/schema
parentef5b0ef44911b7c2a6093068025c56ae8c970083 (diff)
downloadsamba-7ffdd1246d10cf969fe733e05595664921cdfb81.tar.gz
samba-7ffdd1246d10cf969fe733e05595664921cdfb81.tar.bz2
samba-7ffdd1246d10cf969fe733e05595664921cdfb81.zip
r20453: add conversation for the DN_BINARY attribute syntax
the ldb_to_drsuapi version need to be completed, but it's currently not used... metze (This used to be commit 9b31e8c1f73aaf71522e33174c8c5415a95ac626)
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_syntax.c102
1 files changed, 100 insertions, 2 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)",