Help User Password Check

  • Thread starter Marek Szarafiñski junior
  • Start date
M

Marek Szarafiñski junior

Please help...

My problem is I need to write simple function which checks if user (system
user - Windows 2000 Professional), and password matches. Someone told me I
should use function LogonUser. So I wrote quite a simple program which looks
like below:

<code>
void main()
{
HANDLE han;
BOOL bRet;
DWORD err;

for( int i = 0; i < 10; i++ ) // point 1
for( int j = 0; j < 10; j++ )
{
bRet = LogonUser( "userName",
".",
"password",
i,
j,
&han );
if( bRet )
{
cout << "OK i = " << i << " j = " << j << endl; // point2
CloseHandle( han );
}
else
{
err = GetLastError();
if( err != 87 && err != 1314 ) // point3
cout << err << endl;
}
}
return;
}
</code>

ad. point 1.

I know that this iteration is not elegant, but now I am sure, that I use all
posible combination of :
DWORD dwLogonType, // type of logon operation
DWORD dwLogonProvider, // logon provider

dwLogonType/dwLogonProvider may be:
#define LOGON32_LOGON_INTERACTIVE 2
#define LOGON32_LOGON_NETWORK 3
#define LOGON32_LOGON_BATCH 4
#define LOGON32_LOGON_SERVICE 5

#define LOGON32_PROVIDER_DEFAULT 0
#define LOGON32_PROVIDER_WINNT35 1
#if(_WIN32_WINNT >= 0x0400)
#define LOGON32_PROVIDER_WINNT40 2
#endif /* _WIN32_WINNT >= 0x0400 */
#if(_WIN32_WINNT >= 0x0500)
#define LOGON32_PROVIDER_WINNT50 3
#endif // (_WIN32_WINNT >= 0x0500)

so it is from 0 to 10, I've checked all combination.

ad. point 2.
If one of combination was correct I put it on the screan. Unfortunetally
nothing was presented on the screan.

ad. point 3
If some error occure, but not one of known than I want it to be presented.
Till that moment only errors 87, and 1314 occure.

Error 87:
The parameter is incorrect - This is a thing I understand. There are illegal
combinations of dwLogonType/dwLogonProvider

Error 1314:
A required privilege is not held by the client. - hmmm at first it seemed
interesting, because I've tried loging on user which had administrative
privilidges. After some tests, and reading MSDN I suppose the problem is,
that even administrator do not have Log On Locally permission on the local
computer. Especially administrator should not have such a privilidge,
because it would make possibility of direct login, so danger, that sombody
would do it from outside. (I hope I didn't mess up). But if I think
correctly after instalation nobody has this privilidge.

So the question is:
1. is there any other way to check if combination password and user is
correct ?
2. if not how to setup on Windows 2000 Professional this privilidge ?

Thank you for any help
Marek Szarafiñski junior
 
K

Karl Heinz Buchegger

Marek Szarafiñski junior said:
So the question is:
1. is there any other way to check if combination password and user is
correct ?
2. if not how to setup on Windows 2000 Professional this privilidge ?

your problem is not about C++ per se but about a using a system
specific extension your operating system provides. You should
ask a newsgroup dedicated to programming your operating system.

The Welcome message contains some suggestions on where to ask.
http://www.slack.net/~shiva/welcome.txt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,473
Latest member
pioneertraining

Latest Threads

Top