In my application I need to know if the computer is the primary domain controller of a domain, so I need to know the domain of the computer to call NetGetDCName function.
Thanks.
EDIT: The problem is related with the DCOM authentication so I need to know the domain to use the DOMAIN\USERNAME in case of a PDC or COMPUTER\USERNAME if I need to use the local authentication database of the computer.
The NetWkstaGetInfo()
function returns either the domain name or the workgroup of the computer, and is therefore not a reliable way to determine if the computer is a member of a domain.
The GetComputerNameEx()
function will help, used with the ComputerNameDnsDomain
parameter, as shown below. This will return an empty string if the computer is in a workgroup, or the DNS name of the domain:
DWORD bufSize = MAX_PATH;
TCHAR domainNameBuf[ MAX_PATH ];
GetComputerNameEx( ComputerNameDnsDomain, domainNameBuf, &bufSize );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With