views:

138

answers:

1

I thought the NetGetJoinInformation() function might provide the name of the AD Domain a Workstation is a member of but it only provides the domain name in pre-windows 2000 (Netbios) format.

For example if the full name of the AD domain is TestDomain.Lan then NetGetJoinInformation() returns TESTDOMAIN as the domain name.

Need a function that works on W2K & XP without .Net

A: 

I believe GetNetworkParams() is what you're looking for. Q&D demo code:

#include <windows.h>
#include <iphlpapi.h>
#include <iostream>

#pragma comment(lib, "iphlpapi.lib")

int main() { 
    FIXED_INFO *net_params = NULL;
    unsigned long length = 0;

    GetNetworkParams(net_params, &length);
    net_params = static_cast<FIXED_INFO *>(::operator new(length));
    GetNetworkParams(net_params, &length);

    std::cout << "Domain Name: " << net_params->DomainName << "\n";
    ::operator delete(net_params);
    return 0;
}
Jerry Coffin
That function looks like it retrieves the DNS Domain suffix rather than the Active Directory Domain the computer is a member of. Im trying to prevent the possibly that a computer is a member of an active directory domain but the DNS suffix is not present or not configured correctly on the workstation. If I can obtain the AD domain name proper I don't need to worry about an missing or mis-configure network settings on the workstation.
Canacourse