mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Add net-ads-join dnshostname=fqdn option
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14396 Signed-off-by: Isaac Boukris <iboukris@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri May 29 13:33:28 UTC 2020 on sn-devel-184
This commit is contained in:
parent
2b62bd5137
commit
ce0e96e6f4
@ -481,7 +481,7 @@ The remote server must be specified with the -S option.
|
||||
|
||||
<refsect2>
|
||||
<title>[RPC|ADS] JOIN [TYPE] [--no-dns-updates] [-U username[%password]]
|
||||
[createupn=UPN] [createcomputer=OU] [machinepass=PASS]
|
||||
[dnshostname=FQDN] [createupn=UPN] [createcomputer=OU] [machinepass=PASS]
|
||||
[osName=string osVer=string] [options]</title>
|
||||
|
||||
<para>
|
||||
@ -496,6 +496,11 @@ be created.</para>
|
||||
joining the domain.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
[FQDN] (ADS only) set the dnsHosName attribute during the join.
|
||||
The default format is netbiosname.dnsdomain.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
[UPN] (ADS only) set the principalname attribute during the join. The default
|
||||
format is host/netbiosname@REALM.
|
||||
|
@ -546,7 +546,12 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx,
|
||||
goto done;
|
||||
}
|
||||
|
||||
fstr_sprintf(my_fqdn, "%s.%s", r->in.machine_name, lp_dnsdomain());
|
||||
if (r->in.dnshostname != NULL) {
|
||||
fstr_sprintf(my_fqdn, "%s", r->in.dnshostname);
|
||||
} else {
|
||||
fstr_sprintf(my_fqdn, "%s.%s", r->in.machine_name,
|
||||
lp_dnsdomain());
|
||||
}
|
||||
|
||||
if (!strlower_m(my_fqdn)) {
|
||||
status = ADS_ERROR_LDAP(LDAP_NO_MEMORY);
|
||||
|
@ -37,6 +37,7 @@ interface libnetjoin
|
||||
[in] string os_servicepack,
|
||||
[in] boolean8 create_upn,
|
||||
[in] string upn,
|
||||
[in] string dnshostname,
|
||||
[in] boolean8 modify_config,
|
||||
[in,unique] ads_struct *ads,
|
||||
[in] boolean8 debug,
|
||||
|
@ -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;
|
||||
|
@ -277,6 +277,21 @@ rm -f $dedicated_keytab_file
|
||||
|
||||
testit "leave+createupn" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1`
|
||||
|
||||
#
|
||||
# Test dnshostname option of 'net ads join'
|
||||
#
|
||||
testit "join+dnshostname" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD dnshostname="alt.hostname.$HOSTNAME" || failed=`expr $failed + 1`
|
||||
|
||||
testit_grep "check dnshostname opt" "dNSHostName: alt.hostname.$HOSTNAME" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM -s base -b "CN=$HOSTNAME,CN=Computers,$base_dn" || failed=`expr $failed + 1`
|
||||
|
||||
testit "create_keytab+dnshostname" $VALGRIND $net_tool ads keytab create --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=`expr $failed + 1`
|
||||
|
||||
testit_grep "check dnshostname+keytab" "host/alt.hostname.$HOSTNAME@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=`expr $failed + 1`
|
||||
|
||||
rm -f $dedicated_keytab_file
|
||||
|
||||
testit "leave+dnshostname" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1`
|
||||
|
||||
rm -rf $BASEDIR/$WORKDIR
|
||||
|
||||
exit $failed
|
||||
|
Loading…
Reference in New Issue
Block a user