Descobrindo o domínio da máquina



	#include <Windows.h>
	#include <DSRole.h>
	#include <stdio.h>
	
	#pragma comment(lib, "netapi32.lib")	

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

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




Comentários

Copyright © 2018 Anderson Bravo
www.andersonbravo.com.br
anderson@andersonbravo.com.br