<para>Remove host dns entry from Active Directory.</para>
</refsect3>
-<refsect3>
-<title>ADS DNS GETHOSTBYNAME <NAMESERVER|HOSTNAME></title>
-<para>Look up the hostname from Active Directory. You can either provide nameserver ie IPv4|IPv6 address or the hostname. Only one should be provided at a time.</para>
-</refsect3>
-
</refsect2>
<refsect2>
#endif
}
-static int net_ads_dns_gethostbyname(struct net_context *c, int argc, const char **argv)
-{
-#if defined(WITH_DNS_UPDATES)
- DNS_ERROR err;
-
-#ifdef DEVELOPER
- talloc_enable_leak_report();
-#endif
-
- if (argc != 2 || c->display_usage) {
- d_printf( "%s\n"
- " %s\n"
- " %s\n",
- _("Usage:"),
- _("net ads dns gethostbyname <server> <name>\n"),
- _(" Look up hostname from the AD\n"
- " nameserver\tName server to use\n"
- " hostname\tName to look up\n"));
- return -1;
- }
-
- err = do_gethostbyname(argv[0], argv[1]);
- if (!ERR_DNS_IS_OK(err)) {
- d_printf(_("do_gethostbyname returned %s (%d)\n"),
- dns_errstr(err), ERROR_DNS_V(err));
- }
-#endif
- return 0;
-}
static int net_ads_dns_async(struct net_context *c, int argc, const char **argv)
{
N_("net ads dns unregister\n"
" Remove host dns entry from AD")
},
- {
- "gethostbyname",
- net_ads_dns_gethostbyname,
- NET_TRANSPORT_ADS,
- N_("Look up host"),
- N_("net ads dns gethostbyname\n"
- " Look up host")
- },
{
"async",
net_ads_dns_async,
return count;
}
-DNS_ERROR do_gethostbyname(const char *server, const char *host)
-{
- struct dns_connection *conn = NULL;
- struct dns_request *req, *resp;
- DNS_ERROR err;
- int ans = 0;
-
- err = dns_open_connection(server, DNS_UDP, NULL, &conn);
- if (!ERR_DNS_IS_OK(err)) {
- goto error;
- }
-
- err = dns_create_query(conn, host, QTYPE_A, DNS_CLASS_IN, &req);
- if (!ERR_DNS_IS_OK(err)) {
- goto error;
- }
-
- err = dns_transaction(conn, conn, req, &resp);
- if (!ERR_DNS_IS_OK(err)) {
- goto error;
- }
-
- if (resp->num_answers == 0) {
- printf("%s", "No answers!\n");
- goto error;
- }
-
- for (ans = 0; ans < resp->num_answers; ans++) {
- struct in_addr resp_ip;
-
- if (ans > 0)
- printf("%s", " ");
-
- resp_ip.s_addr = *((uint32_t *)resp->answers[ans]->data);
- printf("%s", inet_ntoa(resp_ip));
- }
-
- printf("%s", "\n");
-
- error:
- TALLOC_FREE(conn);
- return err;
-}
-
#endif /* defined(WITH_DNS_UPDATES) */
size_t num_addrs,
uint32_t flags, bool remove_host);
-DNS_ERROR do_gethostbyname(const char *server, const char *host);
-
#endif /* defined(WITH_DNS_UPDATES) */