NetWkstaGetInfo() Question
-
Hello, I am using the following to pull the domain/workgroup name of a remote computer. This works just fine when I use the remote computers IP address but if I use the machine name it fails with an access is denied error. Has anyone experienced the same problem or does anyone have any ideas why this is happening?
DWORD dwLevel = 100; LPWKSTA\_INFO\_100 pBuf = NULL; NET\_API\_STATUS nStatus; nStatus = NetWkstaGetInfo(L"\\\\\\\\192.168.1.2", dwLevel, (LPBYTE \*)&pBuf); if (nStatus == NERR\_Success) { TRACE(L"Name:\\t\\t%s\\n", pBuf->wki100\_computername); TRACE("Platform:\\t%d\\n", pBuf->wki100\_platform\_id); TRACE(L"Domain:\\t\\t%s\\n", pBuf->wki100\_langroup); } else { char error\[1024\]; FormatMessage(FORMAT\_MESSAGE\_FROM\_SYSTEM, NULL, nStatus, NULL, error, sizeof(error), NULL); TRACE("Error: %s", error); } // Free the allocated memory. if (pBuf != NULL) NetApiBufferFree(pBuf);
Thanks, Rob Whoever said nothing's impossible never tried slamming a revolving door!
-
Hello, I am using the following to pull the domain/workgroup name of a remote computer. This works just fine when I use the remote computers IP address but if I use the machine name it fails with an access is denied error. Has anyone experienced the same problem or does anyone have any ideas why this is happening?
DWORD dwLevel = 100; LPWKSTA\_INFO\_100 pBuf = NULL; NET\_API\_STATUS nStatus; nStatus = NetWkstaGetInfo(L"\\\\\\\\192.168.1.2", dwLevel, (LPBYTE \*)&pBuf); if (nStatus == NERR\_Success) { TRACE(L"Name:\\t\\t%s\\n", pBuf->wki100\_computername); TRACE("Platform:\\t%d\\n", pBuf->wki100\_platform\_id); TRACE(L"Domain:\\t\\t%s\\n", pBuf->wki100\_langroup); } else { char error\[1024\]; FormatMessage(FORMAT\_MESSAGE\_FROM\_SYSTEM, NULL, nStatus, NULL, error, sizeof(error), NULL); TRACE("Error: %s", error); } // Free the allocated memory. if (pBuf != NULL) NetApiBufferFree(pBuf);
Thanks, Rob Whoever said nothing's impossible never tried slamming a revolving door!
RobJones wrote:
...but if I use the machine name it fails with an access is denied error.
Your code snippet works fine for me using either an IP address or a machine name. How are you specifying the machine name?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
RobJones wrote:
...but if I use the machine name it fails with an access is denied error.
Your code snippet works fine for me using either an IP address or a machine name. How are you specifying the machine name?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
I specify it like.... L"\\\\machine". I'm going to test it at work today on a few other machines. Just thought it was weird that simply switching between IP and machine name would cause that error. Whoever said nothing's impossible never tried slamming a revolving door!
-
I specify it like.... L"\\\\machine". I'm going to test it at work today on a few other machines. Just thought it was weird that simply switching between IP and machine name would cause that error. Whoever said nothing's impossible never tried slamming a revolving door!
Makes me wonder if it's a name-resolution issue. Do you have a problem using
gethostbyname()
? In other words, can you use this function to resolve a host name to its IP address?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb