s4-dsdb: removed the last use of samdb_search_*() from the dsdb ldb modules
authorAndrew Tridgell <tridge@samba.org>
Fri, 14 Jan 2011 04:46:32 +0000 (15:46 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 14 Jan 2011 05:39:33 +0000 (16:39 +1100)
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/samdb/ldb_modules/rootdse.c

index 2571bc3c8b150b682366d3650d4ed1c63d2e8ffd..2c0fcfcdd1663e2ab9051014be85bd558c32bdec 100644 (file)
@@ -202,10 +202,18 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
        }
 
        if (do_attribute(attrs, "dnsHostName")) {
-               if (ldb_msg_add_string(msg, "dnsHostName",
-                       samdb_search_string(ldb, msg, samdb_server_dn(ldb, msg),
-                                           "dNSHostName", NULL)) != LDB_SUCCESS) {
-                       goto failed;
+               struct ldb_result *res;
+               int ret;
+               const char *dns_attrs[] = { "dNSHostName", NULL };
+               ret = dsdb_module_search_dn(module, msg, &res, samdb_server_dn(ldb, msg),
+                                           dns_attrs, DSDB_FLAG_NEXT_MODULE);
+               if (ret == LDB_SUCCESS) {
+                       const char *hostname = ldb_msg_find_attr_as_string(res->msgs[0], "dNSHostName", NULL);
+                       if (hostname != NULL) {
+                               if (ldb_msg_add_string(msg, "dNSHostName", hostname)) {
+                                       goto failed;
+                               }
+                       }
                }
        }