dns_server: Use the indexed "name" attribute in wildcard lookup
authorAndrew Bartlett <abartlet@samba.org>
Mon, 18 Dec 2017 03:22:23 +0000 (16:22 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 19 Dec 2017 06:19:21 +0000 (07:19 +0100)
(the RDN, being 'dc' in this use case, does not have an index in
the AD schema).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dns_server/dnsserver_common.c

index 217e65b39f446c189f3e748bb91520bb60b17bf3..b836e847fa76cd6ba952d8e0a6e05f02c045f384 100644 (file)
@@ -305,6 +305,10 @@ static unsigned int number_of_labels(const struct ldb_val *name) {
  *
  * x.y.z -> (|(name=x.y.z)(name=\2a.y.z)(name=\2a.z)(name=\2a))
  *
+ * The attribute 'name' is used as this is what the LDB index is on
+ * (the RDN, being 'dc' in this use case, does not have an index in
+ * the AD schema).
+ *
  * Returns NULL if unable to build the query.
  *
  * The first component of the DN is assumed to be the name being looked up
@@ -318,7 +322,7 @@ static struct ldb_parse_tree *build_wildcard_query(
 {
        const struct ldb_val *name = NULL;            /* The DNS name being
                                                         queried */
-       const char *attr = NULL;                      /* The attribute name */
+       const char *attr = "name";                    /* The attribute name */
        struct ldb_parse_tree *query = NULL;          /* The constructed query
                                                         parse tree*/
        struct ldb_parse_tree *wildcard_query = NULL; /* The parse tree for the
@@ -326,12 +330,6 @@ static struct ldb_parse_tree *build_wildcard_query(
                                                         entries */
        int labels = 0;         /* The number of labels in the name */
 
-       attr = ldb_dn_get_rdn_name(dn);
-       if (attr == NULL) {
-               DBG_ERR("Unable to get rdn_name\n");
-               return NULL;
-       }
-
        name = ldb_dn_get_rdn_val(dn);
        if (name == NULL) {
                DBG_ERR("Unable to get domain name value\n");