s4/libnet: Add "dNSHostName" attribute when joining the Site
[kamenim/samba.git] / source4 / libnet / libnet_site.c
index 67935b27eec6d3d28b743301067597a773a33dfe..24311df5a2791c7b8d3f1603ddf689cb61970917 100644 (file)
@@ -22,7 +22,6 @@
 #include "libcli/cldap/cldap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "librpc/rpc/dcerpc.h"
 #include "libcli/resolve/resolve.h"
 #include "param/param.h"
 #include "lib/tsocket/tsocket.h"
@@ -154,6 +153,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
        const char *config_dn_str;
        struct nbt_name name;
        const char *dest_addr = NULL;
+       char *dns_host_name;
 
        tmp_ctx = talloc_named(libnet_r, 0, "libnet_JoinSite temp context");
        if (!tmp_ctx) {
@@ -221,6 +221,15 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
                talloc_free(tmp_ctx);
                return NT_STATUS_NO_MEMORY;
        }
+       dns_host_name = talloc_asprintf(tmp_ctx, "%s.%s",
+                                       libnet_r->in.netbios_name, libnet_r->out.realm);
+       if (!dns_host_name) {
+               r->out.error_string = NULL;
+               talloc_free(tmp_ctx);
+               return NT_STATUS_NO_MEMORY;
+       }
+       strlower_m(dns_host_name);
+       rtn = ldb_msg_add_string(msg, "dNSHostName", dns_host_name);
 
        server_dn = ldb_dn_new(tmp_ctx, remote_ldb, server_dn_str);
        if ( ! ldb_dn_validate(server_dn)) {