In my program, I am calling DsGetDcName to get a domain controller.
Microsoft's documentation for DsGetDcName says this:
By default, this function does not ensure that the returned domain controller is currently available. Instead, the caller should attempt to use the returned domain controller.
I can't ping the domain controller to "use the domain controller" as the firewall might be turned on
So, my question is...how do I "attempt to use the returned domain controller"?
#include <Windows.h>
#include <DsGetDC.h>
#include <wchar.h>
#pragma comment(lib, "NetApi32.lib")
int main()
{
PDOMAIN_CONTROLLER_INFOW pdci{};
ULONG flags = DS_DIRECTORY_SERVICE_REQUIRED;
DWORD dwRet = DsGetDcNameW(NULL, NULL, NULL, NULL, flags, &pdci);
wprintf(L"%s\n", pdci->DomainControllerName);
}