c++判断当前登录账户是否在域环境内

#include <Windows.h>

#include <DSRole.h>

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

#include <stdio.h>


int main(int argc, char ** argv)
{
    DSROLE_PRIMARY_DOMAIN_INFO_BASIC * info;
    DWORD dw;


    dw = DsRoleGetPrimaryDomainInformation(NULL,
                                           DsRolePrimaryDomainInfoBasic,
                                           (PBYTE *)&info);
    if (dw != ERROR_SUCCESS)
    {
        wprintf(L"DsRoleGetPrimaryDomainInformation: %u\n", dw);
        return dw;
    }

    if (info->DomainNameDns == NULL)
    {
        wprintf(L"DomainNameDns is NULL\n");
    }
    else
    {
        wprintf(L"DomainNameDns: %s\n", info->DomainNameDns);
    }

    return 0;
}
 【转】:https://blog.csdn.net/licheng2345738/article/details/79847772

https://stackoverflow.com/questions/9792411/how-to-get-windows-domain-name

猜你喜欢

转载自www.cnblogs.com/hshy/p/10888882.html