Creates and displays a configurable dialog box that accepts credentials information from a user
#include <WinAPIDlg.au3>
_WinAPI_ShellUserAuthenticationDlgEx ( $sCaption, $sMessage, $sUser, $sPassword [, $iFlags = 0 [, $iAuthError = 0 [, $bSave = False [, $iPackage = 0 [, $hParent = 0]]]]] )
$sCaption | The title for the dialog box. |
$sMessage | A brief message to display in the dialog box. |
$sUser | The user name to populate the credential fields in the dialog box. For domain users, the string must be in the following format: DomainName\UserName |
$sPassword | The initial password. |
$iFlags | [optional] The flags that specifies behavior for this function. It can be a combination of the following values. $CREDUIWIN_AUTHPACKAGE_ONLY $CREDUIWIN_CHECKBOX $CREDUIWIN_ENUMERATE_ADMINS $CREDUIWIN_ENUMERATE_CURRENT_USER $CREDUIWIN_GENERIC $CREDUIWIN_IN_CRED_ONLY $CREDUIWIN_SECURE_PROMPT $CREDUIWIN_PACK_32_WOW $CREDUIWIN_PREPROMPTING |
$iAuthError | [optional] The system error code that is displayed in the dialog box. |
$bSave | [optional] Specifies whether the "Save" check box is selected in the dialog box (it makes sense only if the $CREDUIWIN_CHECKBOX flag is used), valid values: True - Selected. False - Deselected (Default). |
$iPackage | [optional] The authentication package for which the credentials are serialized. |
$hParent | [optional] The dialog box is modal with respect to the parent window. If this parameter is 0 (Default), the desktop is the parent window of the dialog box. |
Success: | The array containing the following information: [0] - The user name, including domain name (if necessary). [1] - The password. [2] - The state of the "Save" check box. [3] - The authentication package. |
Failure: | Sets the @error flag to non-zero. If the function is cancelled by the user, @extended flag will contain the ERROR_CANCELLED (1223) system error code. Any other value indicates that the function failed to load. |
This function requires Windows Vista or later.
Search CredUIPromptForWindowsCredentials in MSDN Library.
#include <APIDlgConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WinAPIShPath.au3>
#include <WinAPISys.au3>
If Number(_WinAPI_GetVersion()) < 6.0 Then
MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
Exit
EndIf
Local $aData = _WinAPI_ShellUserAuthenticationDlgEx('Authentication', 'To continue, type a login and password, and then click OK.', '', '', BitOR($CREDUIWIN_ENUMERATE_CURRENT_USER, $CREDUIWIN_CHECKBOX))
If @error Then Exit
Local $aUser = _WinAPI_ParseUserName($aData[0])
If @error Then
Exit
EndIf
ConsoleWrite('Domain: ' & $aUser[0] & @CRLF)
ConsoleWrite('User: ' & $aUser[1] & @CRLF)
ConsoleWrite('Password: ' & $aData[1] & @CRLF)
ConsoleWrite('Save: ' & $aData[2] & @CRLF)
ConsoleWrite('Package: ' & $aData[3] & @CRLF)