replmd linked attributes: use really_parse_trusted_dn everywhere
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 11 Jan 2017 04:49:24 +0000 (17:49 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 Feb 2017 02:17:16 +0000 (03:17 +0100)
This function fills out the DN and GUID fields of an unparsed
parsed_dn struct, which was happening in a few other places already.

In some places the GUID was not being filled out, which would probably
cause problems if the sorted_links switch was turned on.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 48bf555b6da8327ca85fcebc3210525d40b9d1f5..5951e83e2b84e8ce1d4e528d0aec4a5b9fc05ca2 100644 (file)
@@ -1867,26 +1867,14 @@ static int la_guid_compare_with_trusted_dn(struct compare_ctx *ctx,
         * We assume the second argument refers to a DN is from the database
         * and has a GUID -- but this GUID might not have been parsed out yet.
         */
-       NTSTATUS status;
-
-       if (GUID_all_zero(&p->guid)) {
-
-               if (p->dsdb_dn == NULL) {
-                       p->dsdb_dn = dsdb_dn_parse_trusted(ctx->mem_ctx, ctx->ldb, p->v,
-                                                         ctx->ldap_oid);
-                       if (p->dsdb_dn == NULL) {
-                               ctx->err = LDB_ERR_INVALID_DN_SYNTAX;
-                               return 0;
-                       }
-               }
-
-               status = dsdb_get_extended_dn_guid(p->dsdb_dn->dn, &p->guid, "GUID");
-               if (!NT_STATUS_IS_OK(status)) {
-                       ctx->err = LDB_ERR_OPERATIONS_ERROR;
+       if (p->dsdb_dn == NULL) {
+               int ret = really_parse_trusted_dn(ctx->mem_ctx, ctx->ldb, p,
+                                                 ctx->ldap_oid);
+               if (ret != LDB_SUCCESS) {
+                       ctx->err = ret;
                        return 0;
                }
        }
-
        return ndr_guid_compare(ctx->guid, &p->guid);
 }
 
@@ -1941,16 +1929,14 @@ static int parsed_dn_find(struct ldb_context *ldb, struct parsed_dn *pdn,
                        int cmp;
                        p = &pdn[i];
                        if (p->dsdb_dn == NULL) {
-                               p->dsdb_dn = dsdb_dn_parse_trusted(pdn, ldb,
-                                                                  p->v, ldap_oid);
-                               if (p->dsdb_dn == NULL) {
+                               int ret = really_parse_trusted_dn(pdn, ldb, p, ldap_oid);
+                               if (ret != LDB_SUCCESS) {
                                        return LDB_ERR_OPERATIONS_ERROR;
                                }
                        }
+
                        cmp = ldb_dn_compare(p->dsdb_dn->dn, target_dn);
                        if (cmp == 0) {
-                               dsdb_get_extended_dn_guid(p->dsdb_dn->dn,
-                                                         &p->guid, "GUID");
                                *exact = p;
                                return LDB_SUCCESS;
                        }