11-25-2007 01:13 PM
11-26-2007 02:33 PM
11-26-2007 03:05 PM
11-27-2007 03:23 PM
11-28-2007 03:10 PM
Using the sample routine for whoami.prj in the samples directory to try this function. Need to add valid login name..etc obviously. It very well maybe a SDK variable type as the issue? Please try to actually run it, I get a GPF.
/*---------------------------------------------------------------------------*/
/* */
/* FILE: */
/* */
/* */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Include files */
/*---------------------------------------------------------------------------*/
#include "windows.h"
#include <utility.h>
#include <ansi_c.h>
#include <userint.h>
#include "whoami.h"
/*---------------------------------------------------------------------------*/
/* Module-globals */
/*---------------------------------------------------------------------------*/
static OSVERSIONINFO verInfo = {0};
static HANDLE hProcess, hAccessToken;
static UCHAR InfoBuffer[1000],szAccountName[200], szDomainName[200], szPassWord[200];
static PTOKEN_USER pTokenUser = (PTOKEN_USER)InfoBuffer;
static DWORD dwInfoBufferSize,dwAccountSize = 200, dwDomainSize = 200;
static SID_NAME_USE snu;
static PTOKEN_GROUPS ptgGroups = (PTOKEN_GROUPS)InfoBuffer;
static PSID psidAdministrators;
static SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY;
static UINT x;
static PHANDLE phToken;
static UINT aszAccountName[200], aszDomainName[200], aszPassWord[200];
int status;
/*---------------------------------------------------------------------------*/
/* This is the application's entry-point. */
/*---------------------------------------------------------------------------*/
int main (int argc, char *argv[])
{
int hpanel;
if (InitCVIRTE (0, argv, 0) == 0)
return -1;
/* Verify that we are on Windows NT */
verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if ((GetVersionEx(&verInfo)==0)
|| (verInfo.dwPlatformId != VER_PLATFORM_WIN32_NT))
{
MessagePopup ("Wrong Windows version",
"These functions are only valid on Windows NT");
return 0;
}
sprintf( szAccountName, "login" );
sprintf( szDomainName, "Domain" );
sprintf( szPassWord, "password" );
status = LogonUser(
szAccountName, // user name
szDomainName, // domain or server
szPassWord, // password
LOGON32_LOGON_NETWORK, // type of logon operation
LOGON32_PROVIDER_DEFAULT, // logon provider
phToken // receive tokens handle
);
CloseCVIRTE ();
return 0;
}
11-29-2007 11:51 AM
11-29-2007 01:02 PM
11-29-2007 03:32 PM
I suspected it probably was a variable issue. These are variable types I do not have any experience with. Thank you for looking at this with an observant eye for the variables. I just tried it and it does indeed work for a valid login user and non valid user...
cvier
11-30-2007 10:41 AM
12-10-2007 04:10 AM - edited 12-10-2007 04:11 AM