From d68f86a595dcf0f1ba8c62fa30f06e731277e4e6 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Wed, 20 May 2015 08:07:20 -0700 Subject: [PATCH] Do not assume that the backlink has the same syntax as the forward attribute Also use dsdb_parse_dn as the "DN" might be a DN+String or DN+Binary object. ldb_dn_from_ldb_val is not able to parse properly DN+x format and extract the DN part out of it. We have to deal with this use case for msExchOWATranscodingFileTypes/msExchOWATranscodingFileTypesBL attributes (and exchange loves to store a lot of them). msExchOWATranscodingFileTypes: S:5:.pptx:CN=owa (Default Web Site),CN=HTTP,CN= Protocols,CN=S1-W2K8R2,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF2 3SPDLT),CN=Administrative Groups,CN=Samba,CN=Microsoft Exchange,CN=Services,C N=Configuration,DC=exchange,DC=home,DC=matws,DC=net msExchOWATranscodingFileTypesBL: CN=owa (Default Web Site),CN=HTTP,CN=Protocol s,CN=S1-W2K8R2,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT), CN=Administrative Groups,CN=Samba,CN=Microsoft Exchange,CN=Services,CN=Config uration,DC=exchange,DC=home,DC=matws,DC=net Change-Id: I78eb567cb68b3b6c20e56c8077eb915991fab766 Signed-off-by: Matthieu Patou --- source4/dsdb/samdb/ldb_modules/linked_attributes.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index 63ccbde..60ab7ce 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -173,16 +173,16 @@ static int la_guid_from_dn(struct ldb_module *module, * series of modify requests */ static int la_store_op(struct la_context *ac, enum la_op op, struct ldb_val *dn, - const char *name) + const char *name, + const char *ldap_oid) { struct ldb_context *ldb; struct la_op_store *os; - struct ldb_dn *op_dn; + struct dsdb_dn *op_dn; int ret; ldb = ldb_module_get_ctx(ac->module); - - op_dn = ldb_dn_from_ldb_val(ac, ldb, dn); + op_dn = dsdb_dn_parse(ac, ldb, dn, ldap_oid); if (!op_dn) { ldb_asprintf_errstring(ldb, "could not parse attribute as a DN"); @@ -196,7 +196,7 @@ static int la_store_op(struct la_context *ac, os->op = op; - ret = la_guid_from_dn(ac->module, ac->req, op_dn, &os->guid); + ret = la_guid_from_dn(ac->module, ac->req, op_dn->dn, &os->guid); talloc_free(op_dn); if (ret == LDB_ERR_NO_SUCH_OBJECT && ac->req->operation == LDB_DELETE) { /* we are deleting an object, and we've found it has a @@ -320,7 +320,8 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * for (j = 0; j < el->num_values; j++) { ret = la_store_op(ac, LA_OP_ADD, &el->values[j], - attr_name); + attr_name, + schema_attr->syntax->ldap_oid); if (ret != LDB_SUCCESS) { return ret; } @@ -424,7 +425,8 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are for (j = 0; j < search_el->num_values; j++) { ret = la_store_op(ac, LA_OP_DEL, &search_el->values[j], - attr_name); + attr_name, + schema_attr->syntax->ldap_oid); if (ret != LDB_SUCCESS) { talloc_free(ares); return ldb_module_done(ac->req, @@ -571,7 +573,8 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques for (j = 0; j < el->num_values; j++) { ret = la_store_op(ac, LA_OP_ADD, &el->values[j], - attr_name); + attr_name, + schema_attr->syntax->ldap_oid); if (ret != LDB_SUCCESS) { return ret; } @@ -585,7 +588,8 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques for (j = 0; j < el->num_values; j++) { ret = la_store_op(ac, LA_OP_DEL, &el->values[j], - attr_name); + attr_name, + schema_attr->syntax->ldap_oid); if (ret != LDB_SUCCESS) { return ret; } -- 2.1.4