Question

I can't seem to find a way to get a DN of a workstation (computer) with C++ and WinAPIs. Any ideas how to do this?

PS. The workstation is connected to a domain controller.

PS2. I need the DN of a computer and not the logged on user.

Was it helpful?

Solution

If you want the name of the computer on which your code is running, and it is participating in a domain, then you can use GetComputerObjectName:

#include <security.h>
#include <secext.h>

TCHAR szDN[1024];
ULONG ulSize = sizeof(szDN)/sizeof(szDN[0]);
BOOL res = GetComputerObjectName(NameFullyQualifiedDN, szDN, &ulSize);

OTHER TIPS

You probably want the GetComputerNameEx function documented on http://msdn.microsoft.com/en-us/library/windows/desktop/ms724301%28v=vs.85%29.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top