Kbase P21685: How to authenticate a users Operating System Level name and password credentials?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/10/2009 |
|
Status: Verified
GOAL:
How to authenticate Operating System Level user name and password credentials
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
Windows
FIX:
One way to verify a user?s Operating System Level name and password credentials is to call the WIN32 API Function LogonUserA as demonstrated in the 4GL code below.
The WIN32 API Function LogonUserA API is available on Windows NT, Windows 2000, and Windows XP.
On Windows NT and Windows 2000, the process/user that calls LogonUserA must have the "Act as part of the Operating System" privilege/right.
On Windows XP, the above privilege is not required. LogonUserA is not implemented on Windows 95, Windows 98, or Windows Millennium Edition.
/*********************************************************************/
/* How to authenticate Operating System Level user name and password */
/*********************************************************************/
DEFINE VARIABLE clpszUserName AS CHARACTER FORMAT "X(15)" NO-UNDO.
DEFINE VARIABLE clpszDomain AS CHARACTER FORMAT "X(15)" NO-UNDO.
DEFINE VARIABLE clpszPassword AS CHARACTER FORMAT "X(15)" NO-UNDO.
DEFINE VARIABLE idwLogonType AS INTEGER NO-UNDO.
DEFINE VARIABLE idwLogonProvider AS INTEGER NO-UNDO.
DEFINE VARIABLE mphToken AS MEMPTR NO-UNDO.
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
UPDATE clpszUserName clpszDomain clpszPassword.
ASSIGN
SET-SIZE(mphToken) = 32
idwLogonType = 2
idwLogonProvider = 0.
PROCEDURE LogonUserA EXTERNAL "ADVAPI32.DLL":
DEFINE INPUT PARAMETER lpszUserName AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER lpszDomain AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER lpszPassword AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER dwLogonType AS LONG NO-UNDO.
DEFINE INPUT PARAMETER dwLogonProvider AS LONG NO-UNDO.
DEFINE INPUT PARAMETER phToken AS MEMPTR NO-UNDO.
DEFINE RETURN PARAMETER intResult AS SHORT NO-UNDO.
END PROCEDURE.
RUN LogonUserA (INPUT clpszUserName,
INPUT clpszDomain,
INPUT clpszPassword,
INPUT idwLogonType,
INPUT idwLogonProvider,
INPUT mphToken,
OUTPUT intResult).
IF intResult > 0 THEN
MESSAGE "Logon authentication succeeded"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE
MESSAGE "Logon authentication FAILED"
VIEW-AS ALERT-BOX INFO BUTTONS OK.