Ethereal-dev: [Ethereal-dev] NetWKSTA.cpp (fwd)
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Richard Sharpe <rsharpe@xxxxxxxxxxxxxxxxx>
Date: Thu, 1 May 2003 11:11:38 -0700 (PDT)
Hi, for those who want to take part in the fun of figuring out some more RPCs, here is the C++ program I have been using. Of course, you need VC++ for the include files and libraries. // NetWKSTA.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <stdio.h> #include <assert.h> #include <windows.h> #include <lm.h> int main(int argc, char* argv[]) { LPWKSTA_USER_INFO_0 pBuf = NULL; LPWKSTA_USER_INFO_0 pTmpBuf; LPWKSTA_INFO_102 pInfoBuf100 = NULL; LPWKSTA_INFO_502 pInfoBuf502 = NULL; WKSTA_INFO_502 wi; DWORD dwLevel = 0; DWORD dwPrefMaxLen = -1; DWORD dwEntriesRead = 0; DWORD dwTotalEntries = 0; DWORD dwResumeHandle = 0; DWORD i; DWORD dwTotalCount = 0; NET_API_STATUS nStatus; LPTSTR pszServerName = NULL; if (argc > 2) { fprintf(stderr, "Usage: %s [\\\\ServerName]\n", argv[0]); return 1; } // The server is not the default local computer. // if (argc == 2) pszServerName = (char *)L"\\\\NT4PDC"; fprintf(stdout, "\nUsers currently logged on %s:\n", pszServerName); // // Call the NetWkstaUserEnum function, specifying level 0. // fprintf(stdout, "\n"); dwLevel = 100; nStatus = NetWkstaGetInfo(pszServerName, dwLevel, (LPBYTE *)&pInfoBuf100); dwLevel = 101; nStatus = NetWkstaGetInfo(pszServerName, dwLevel, (LPBYTE *)&pInfoBuf100); dwLevel = 102; nStatus = NetWkstaGetInfo(pszServerName, dwLevel, (LPBYTE *)&pInfoBuf100); dwLevel = 502; nStatus = NetWkstaGetInfo(pszServerName, dwLevel, (LPBYTE *)&pInfoBuf502); if (pInfoBuf502 != NULL) { // // Copy the existing settings to the new structure, // and free the buffer. // CopyMemory(&wi, pInfoBuf502, sizeof(wi)); NetApiBufferFree(pInfoBuf502); } nStatus = NetWkstaSetInfo(pszServerName, dwLevel, (LPBYTE)&wi, NULL); dwLevel = 0; nStatus = NetWkstaUserEnum(pszServerName, dwLevel, (LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle); if ((nStatus != NERR_Success) && (nStatus != ERROR_MORE_DATA)) fprintf(stderr, "A system error has occurred: %d\n", nStatus); dwLevel = 1; nStatus = NetWkstaUserEnum(pszServerName, dwLevel, (LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle); if ((nStatus != NERR_Success) && (nStatus != ERROR_MORE_DATA)) fprintf(stderr, "A system error has occurred: %d\n", nStatus); // Get info about a user ... nStatus = NetWkstaUserGetInfo(pszServerName, dwLevel, (LPBYTE *)&pBuf); if ((nStatus != NERR_Success) && (nStatus != ERROR_MORE_DATA)) fprintf(stderr, "A system error has occurred: %d\n", nStatus); dwLevel = 0; nStatus = NetWkstaTransportEnum(pszServerName, dwLevel, (LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle); if ((nStatus != NERR_Success) && (nStatus != ERROR_MORE_DATA)) fprintf(stderr, "A system error has occurred: %d\n", nStatus); return 0; } Regards ----- Richard Sharpe, rsharpe[at]ns.aus.com, rsharpe[at]samba.org, sharpe[at]ethereal.com, http://www.richardsharpe.com
- Follow-Ups:
- [Ethereal-dev] Re: NetWKSTA.cpp (fwd)
- From: Ronan Waide
- [Ethereal-dev] Re: NetWKSTA.cpp (fwd)
- Prev by Date: Re: [Ethereal-dev] win32 compilation?
- Next by Date: Re: [Ethereal-dev] patch to add id'ing of new types from netbios name services
- Previous by thread: Re: [Ethereal-dev] bug in ethereal version 0.9.11 concerning pflog
- Next by thread: [Ethereal-dev] Re: NetWKSTA.cpp (fwd)
- Index(es):