开发者

How to get full name of Active Directory Domain that workstation is a member of

开发者 https://www.devze.com 2022-12-27 06:08 出处:网络
I thought theNetGetJoinInformation() 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.

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消