Examples Delphi

Password Verification On NT4
Below is part of some code I've used before to do this. Unfortunately this
code requires the privilege SeTcbPrivilege ("Act as part of the operating
system") to run successfully. There may be another way to do it that doesn't
need any special privileges, but I couldn't find one at the time.
Regards,
Chris Coleman
---------------------------------------------------------
ccoleman@tbs.com.au
Territory Business Solutions Pty Ltd
Red Hat Certified Channel Partner
Microsoft Certified Solution Provider
Citrix Solutions Network - Gold Member
ph +61 8 8982 4000 fax +61 8 89418075
http://www.tbs.com.au/
---------------------------------------------------------
{ see if we have the correct credentials... }
sts := LogonUser ( szUsername,
szDomain,
szPassword,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
phToken );
nLastError := GetLastError;
if not sts then
begin
{ an error occurred in LogonUser}
case nLastError of
ERROR_PRIVILEGE_NOT_HELD : strError := chr(13) +
'SeTcbPrivilege required!';
{ Use NT User Manager to grant
the
user "ACT AS PART OF THE
OPERATING SYSTEM" to give
them
the SeTcbPrivilege privilege
}
else strError := chr(13) +
'Invalid username / password';
end; {case}

MessageDlg ( strError,
mtError,
[mbOK],
0 );
end
else
begin
{ the password was correct for the specified username and domain }
MessageDlg ( chr(13) +
'Username / password validated!',
mtInformation,
[mbOK],
0 );
{ free the handle that was created }
CloseHandle ( phToken );
end;
> -----Original Message-----
> From: Dan Hamm [SMTP:Dan.Hamm@btinternet.com]
> Sent: Thursday, January 18, 2001 5:24 PM
> To: Delphi@Elists. Org
> Subject: Login Password Verification on NT 4
>
> Does anybody know how to verify a user password?
> I am using:
>
> WNetVerifyPassword(PChar(PW), N);
>
> where PW is the password.
> This works fine under Win98 - N returns the success or failure value
> (albeit without checking case!).
> However, under NT4 (SP3 or SP5) I get the message:
> WNetVerifyPasswordA not present in mpr.dll
> mpr.dll is present in both Win9X and NT4. Anybody know the appropriate
> function?
>
> --------------------------------------------
> e-mail: [mailto:Dan.Hamm@btinternet.com]
> Delphi mailing list -> Delphi@elists.org
> http://www.elists.org/mailman/listinfo/delphi
********************************************************************
What you need on NT is the API LogonUser. THis has two drawbacks:
1) it isn't supported on Win 95/98/me
2) even for a program to call it on NT, the user running the program
must have the SE_TCB_NAME privilege (Log on as a Batch job)-
this can be granted in the User Manager, under Policy/User Rights
(make sure you tick "Advanced User Rights")