How to get full name of Active Directory Domain that workstation is a member of
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 do开发者_如何学Cmain is TestDomain.Lan then NetGetJoinInformation()
returns TESTDOMAIN as the domain name.
Need a function that works on W2K & XP without .Net
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;
}
精彩评论