Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with LogonUser !!!

Status
Not open for further replies.

WebStar

Programmer
May 1, 2002
69
DE
ihave this part of code:
HANDLE hUser;
bool b=FALSE;
if:):LogonUser("Administrator", NULL, "zxb0bPQp", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUser)) b=TRUE;
if(b) MessageBox(0,"pass valid","pass valid",MB_OK);
else MessageBox(0,"pass invalid","pass invalid",MB_OK);

it always returns false ("pass invalid"), the user name and pass are good for sure, my OS is Win2k. what should i do?
 
Well that's because your LogonUser call is failing and it's skipping the b=TRUE. So since you have set b=FALSE the if statement if(b) displays "Invalid".

You'll have to determine why the LogonUser is failing.

HTH William
Software Engineer
ICQ No. 56047340
 
char * User = "Administrator" ;
char * Pass = "zxb0bPQp" ;
HANDLE hUser = 0 ;
bool b=FALSE;
if:):LogonUser(User, _T("."), Pass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUser) == 0)
{
LPVOID lpMsgBuf ;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL) ;
AfxMessageBox((LPCTSTR) lpMsgBuf) ;
LocalFree(lpMsgBuf) ;
}
else { b = TRUE ; }

This should give you an insight as to what is happening.

William
Software Engineer
ICQ No. 56047340
 
Thanx that really works...but :)
it works only when i'm logged in as Administrator, if i'm another user, i can't veify the admin pass... i need this 'cause i'm making a windows shell, and if i whant to administrate my shell i must provide the admin pass... and if i'm already logged in as admin, LogonUser it's not much help, but if i'm logged in as another user i need pass confirmation, and sadly this is not working. Anyway thanx.
 
In the past, I have also had to specify the domain with the username

username = "\\domain\name"
password = "password"

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top