in common/util.hpp [659:708]
static std::vector<std::string> get_FQDNs( std::string domain_name )
{
/**
* Find SRV record
* "The SRV or "service locator" DNS record type enables service discovery in the DNS.
* SRV records allow services to be advertised on specific ports and used in an order
* controlled by the owner of the service. SRV also provides a load balancing feature."
* https://www.nslookup.io/learning/dns-record-types/srv/
*/
// https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/verify-srv-dns-records-have-been-created#method-3-use-nslookup
std::string cmd = "nslookup -type=srv _ldap._tcp.dc._msdcs." + domain_name + " | grep " +
domain_name + " | sed 's/^.* //g'";
std::pair<int, std::string> nslookup_output = Util::exec_shell_cmd( cmd );
std::vector<std::string> fqdns;
if ( nslookup_output.first == 0 )
{
fqdns = split_string( nslookup_output.second, '\n' );
for ( auto& fqdn : fqdns )
{
if ( fqdn.back() == '.' )
{
fqdn.pop_back();
}
}
return fqdns;
}
else
{
cmd = "dig +short _ldap._tcp.dc._msdcs." + domain_name + " -t any | sed 's/^.* //g'";
nslookup_output = Util::exec_shell_cmd( cmd );
if ( nslookup_output.first == 0 )
{
std::vector<std::string> fqdns = split_string( nslookup_output.second, '\n' );
for ( auto& fqdn : fqdns )
{
if ( fqdn.back() == '.' )
{
fqdn.pop_back();
}
}
return fqdns;
}
}
return fqdns;
}