Add net-ads-join dnshostname=fqdn option
[bbaumbach/samba-autobuild/.git] / source3 / utils / net_ads.c
index 9d9bc5f7982296ca43839c13ac022883b0cd1b05..d4bf5fa12b386b1c35081c8b146a0b09c53fb2ff 100644 (file)
@@ -1711,6 +1711,8 @@ static int net_ads_join_usage(struct net_context *c, int argc, const char **argv
 {
        d_printf(_("net ads join [--no-dns-updates] [options]\n"
                   "Valid options:\n"));
+       d_printf(_("   dnshostname=FQDN      Set the dnsHostName attribute during the join.\n"
+                  "                         The default is in the form netbiosname.dnsdomain\n"));
        d_printf(_("   createupn[=UPN]       Set the userPrincipalName attribute during the join.\n"
                   "                         The default UPN is in the form host/netbiosname@REALM.\n"));
        d_printf(_("   createcomputer=OU     Precreate the computer account in a specific OU.\n"
@@ -1831,6 +1833,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
        const char *domain = lp_realm();
        WERROR werr = WERR_NERR_SETUPNOTJOINED;
        bool createupn = false;
+       const char *dnshostname = NULL;
        const char *machineupn = NULL;
        const char *machine_password = NULL;
        const char *create_in_ou = NULL;
@@ -1871,7 +1874,10 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
        /* process additional command line args */
 
        for ( i=0; i<argc; i++ ) {
-               if ( !strncasecmp_m(argv[i], "createupn", strlen("createupn")) ) {
+               if ( !strncasecmp_m(argv[i], "dnshostname", strlen("dnshostname")) ) {
+                       dnshostname = get_string_param(argv[i]);
+               }
+               else if ( !strncasecmp_m(argv[i], "createupn", strlen("createupn")) ) {
                        createupn = true;
                        machineupn = get_string_param(argv[i]);
                }
@@ -1939,6 +1945,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
        r->in.domain_name_type  = domain_name_type;
        r->in.create_upn        = createupn;
        r->in.upn               = machineupn;
+       r->in.dnshostname       = dnshostname;
        r->in.account_ou        = create_in_ou;
        r->in.os_name           = os_name;
        r->in.os_version        = os_version;