summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-01-07 17:29:40 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-08 13:03:04 +1100
commitf6cf895951f24a28efb1a2859e066f5568e189b1 (patch)
tree8ff0ad00f26051df8c07927fd20556ea63b18693 /source4
parentf7517e62569b108a79dfba10a6f06ad92c996413 (diff)
downloadsamba-f6cf895951f24a28efb1a2859e066f5568e189b1.tar.gz
samba-f6cf895951f24a28efb1a2859e066f5568e189b1.tar.bz2
samba-f6cf895951f24a28efb1a2859e066f5568e189b1.zip
s4-schema: added generic attributeID conversion functions
When we get one we haven't seen before, we can work out the right type automatically in most cases. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/schema/schema_syntax.c180
1 files changed, 117 insertions, 63 deletions
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index de52b9c628..48c2031024 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -576,6 +576,57 @@ static WERROR dsdb_syntax_DATA_BLOB_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
+static WERROR _dsdb_syntax_auto_OID_drsuapi_to_ldb(struct ldb_context *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.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++) {
+ uint32_t v;
+ const struct dsdb_class *c;
+ const struct dsdb_attribute *a;
+ const char *str = NULL;
+
+ if (in->value_ctr.values[i].blob == NULL) {
+ return WERR_FOOBAR;
+ }
+
+ if (in->value_ctr.values[i].blob->length != 4) {
+ return WERR_FOOBAR;
+ }
+
+ v = IVAL(in->value_ctr.values[i].blob->data, 0);
+
+ if ((c = dsdb_class_by_governsID_id(schema, v))) {
+ str = talloc_strdup(out->values, c->lDAPDisplayName);
+ } else if ((a = dsdb_attribute_by_attributeID_id(schema, v))) {
+ str = talloc_strdup(out->values, a->lDAPDisplayName);
+ } else {
+ WERROR werr;
+ werr = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, v, out->values, &str);
+ W_ERROR_NOT_OK_RETURN(werr);
+ }
+ W_ERROR_HAVE_NO_MEMORY(str);
+
+ /* the values need to be reversed */
+ out->values[out->num_values - (i + 1)] = data_blob_string_const(str);
+ }
+
+ return WERR_OK;
+}
+
static WERROR _dsdb_syntax_OID_obj_drsuapi_to_ldb(struct ldb_context *ldb,
const struct dsdb_schema *schema,
const struct dsdb_attribute *attr,
@@ -711,6 +762,60 @@ static WERROR _dsdb_syntax_OID_oid_drsuapi_to_ldb(struct ldb_context *ldb,
return WERR_OK;
}
+static WERROR _dsdb_syntax_auto_OID_ldb_to_drsuapi(struct ldb_context *ldb,
+ 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;
+
+ out->attid= attr->attributeID_id;
+ out->value_ctr.num_values= in->num_values;
+ out->value_ctr.values= talloc_array(mem_ctx,
+ struct drsuapi_DsAttributeValue,
+ in->num_values);
+ W_ERROR_HAVE_NO_MEMORY(out->value_ctr.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++) {
+ const struct dsdb_class *obj_class;
+ const struct dsdb_attribute *obj_attr;
+ struct ldb_val *v;
+
+ out->value_ctr.values[i].blob= &blobs[i];
+
+ blobs[i] = data_blob_talloc(blobs, NULL, 4);
+ W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
+
+ /* in DRS windows puts the classes in the opposite
+ order to the order used in ldap */
+ v = &in->values[(in->num_values-1)-i];
+
+ if ((obj_class = dsdb_class_by_lDAPDisplayName_ldb_val(schema, v))) {
+ SIVAL(blobs[i].data, 0, obj_class->governsID_id);
+ } else if ((obj_attr = dsdb_attribute_by_lDAPDisplayName_ldb_val(schema, v))) {
+ SIVAL(blobs[i].data, 0, obj_attr->attributeID_id);
+ } else {
+ uint32_t attid;
+ WERROR werr;
+ werr = dsdb_schema_pfm_make_attid(schema->prefixmap,
+ (const char *)v->data,
+ &attid);
+ W_ERROR_NOT_OK_RETURN(werr);
+ SIVAL(blobs[i].data, 0, attid);
+ }
+
+ }
+
+
+ return WERR_OK;
+}
+
static WERROR _dsdb_syntax_OID_obj_ldb_to_drsuapi(struct ldb_context *ldb,
const struct dsdb_schema *schema,
const struct dsdb_attribute *attr,
@@ -839,18 +944,19 @@ static WERROR dsdb_syntax_OID_drsuapi_to_ldb(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
struct ldb_message_element *out)
{
- uint32_t i;
-
switch (attr->attributeID_id) {
case DRSUAPI_ATTRIBUTE_objectClass:
case DRSUAPI_ATTRIBUTE_subClassOf:
case DRSUAPI_ATTRIBUTE_auxiliaryClass:
+ case DRSUAPI_ATTRIBUTE_systemAuxiliaryClass:
case DRSUAPI_ATTRIBUTE_systemPossSuperiors:
case DRSUAPI_ATTRIBUTE_possSuperiors:
return _dsdb_syntax_OID_obj_drsuapi_to_ldb(ldb, schema, attr, in, mem_ctx, out);
case DRSUAPI_ATTRIBUTE_systemMustContain:
case DRSUAPI_ATTRIBUTE_systemMayContain:
case DRSUAPI_ATTRIBUTE_mustContain:
+ case DRSUAPI_ATTRIBUTE_rDNAttId:
+ case DRSUAPI_ATTRIBUTE_transportAddressAttribute:
case DRSUAPI_ATTRIBUTE_mayContain:
return _dsdb_syntax_OID_attr_drsuapi_to_ldb(ldb, schema, attr, in, mem_ctx, out);
case DRSUAPI_ATTRIBUTE_governsID:
@@ -859,41 +965,9 @@ static WERROR dsdb_syntax_OID_drsuapi_to_ldb(struct ldb_context *ldb,
return _dsdb_syntax_OID_oid_drsuapi_to_ldb(ldb, schema, attr, in, mem_ctx, out);
}
- out->flags = 0;
- out->name = talloc_strdup(mem_ctx, attr->lDAPDisplayName);
- W_ERROR_HAVE_NO_MEMORY(out->name);
-
- out->num_values = in->value_ctr.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++) {
- uint32_t v;
- const char *name;
- char *str;
-
- if (in->value_ctr.values[i].blob == NULL) {
- return WERR_FOOBAR;
- }
-
- if (in->value_ctr.values[i].blob->length != 4) {
- return WERR_FOOBAR;
- }
-
- v = IVAL(in->value_ctr.values[i].blob->data, 0);
-
- name = dsdb_lDAPDisplayName_by_id(schema, v);
- if (!name) {
- return WERR_FOOBAR;
- }
-
- str = talloc_strdup(out->values, name);
- W_ERROR_HAVE_NO_MEMORY(str);
-
- out->values[i] = data_blob_string_const(str);
- }
-
- return WERR_OK;
+ DEBUG(0,(__location__ ": Unknown handling for attributeID_id for %s\n",
+ attr->lDAPDisplayName));
+ return _dsdb_syntax_auto_OID_drsuapi_to_ldb(ldb, schema, attr, in, mem_ctx, out);
}
static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
@@ -903,9 +977,6 @@ static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
struct drsuapi_DsReplicaAttribute *out)
{
- uint32_t i;
- DATA_BLOB *blobs;
-
if (attr->attributeID_id == 0xFFFFFFFF) {
return WERR_FOOBAR;
}
@@ -914,12 +985,15 @@ static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
case DRSUAPI_ATTRIBUTE_objectClass:
case DRSUAPI_ATTRIBUTE_subClassOf:
case DRSUAPI_ATTRIBUTE_auxiliaryClass:
+ case DRSUAPI_ATTRIBUTE_systemAuxiliaryClass:
case DRSUAPI_ATTRIBUTE_systemPossSuperiors:
case DRSUAPI_ATTRIBUTE_possSuperiors:
return _dsdb_syntax_OID_obj_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
case DRSUAPI_ATTRIBUTE_systemMustContain:
case DRSUAPI_ATTRIBUTE_systemMayContain:
case DRSUAPI_ATTRIBUTE_mustContain:
+ case DRSUAPI_ATTRIBUTE_rDNAttId:
+ case DRSUAPI_ATTRIBUTE_transportAddressAttribute:
case DRSUAPI_ATTRIBUTE_mayContain:
return _dsdb_syntax_OID_attr_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
case DRSUAPI_ATTRIBUTE_governsID:
@@ -928,30 +1002,10 @@ static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
return _dsdb_syntax_OID_oid_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
}
- out->attid = attr->attributeID_id;
- out->value_ctr.num_values = in->num_values;
- out->value_ctr.values = talloc_array(mem_ctx,
- struct drsuapi_DsAttributeValue,
- in->num_values);
- W_ERROR_HAVE_NO_MEMORY(out->value_ctr.values);
-
- blobs = talloc_array(mem_ctx, DATA_BLOB, in->num_values);
- W_ERROR_HAVE_NO_MEMORY(blobs);
+ DEBUG(0,(__location__ ": Unknown handling for attributeID_id for %s\n",
+ attr->lDAPDisplayName));
- for (i=0; i < in->num_values; i++) {
- uint32_t v;
-
- out->value_ctr.values[i].blob = &blobs[i];
-
- blobs[i] = data_blob_talloc(blobs, NULL, 4);
- W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
-
- v = strtol((const char *)in->values[i].data, NULL, 10);
-
- SIVAL(blobs[i].data, 0, v);
- }
-
- return WERR_OK;
+ return _dsdb_syntax_auto_OID_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
}
static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(struct ldb_context *ldb,