CredUIPromptForCredentials returns ERROR_INVALID_PARAMETER?

Discussion in 'Windows 64bit' started by Leo, Feb 9, 2009.

  1. Leo

    Leo Guest

    Hello there,

    In desktop enviorment, I need to retrieve the current logon user
    credentials and the verify it. I used the code below to ask for
    credentials, but it returned ERROR_INVALID_PARAMETER. How should I
    change parameters (I don't care whether to save credentials or not)?

    I changed flags and CredUIPromptForCredentials didn't complains again,
    but CredUIConfirmCredentials then returned error.

    Is there something wrong on the way I call these two functions? Thanks
    very much in advance!

    Leo

    // Securely get the user name and password.
    CREDUI_INFO cui;
    cui.cbSize = sizeof(CREDUI_INFO);
    cui.hwndParent = NULL;
    cui.pszMessageText = _T("Please use the same credentials that you
    used to log into this Windows session");
    cui.pszCaptionText = _T("Login Credentials");
    cui.hbmBanner = NULL;

    TCHAR pszName[CREDUI_MAX_USERNAME_LENGTH] = _T("");
    TCHAR pszPwd[CREDUI_MAX_PASSWORD_LENGTH] = _T("");
    BOOL fSave = FALSE;

    // Get the user name
    DWORD size = 256;
    ::GetUserName(pszName, &size);

    // Create the UI asking for the credentials.
    DWORD dwErr = CredUIPromptForCredentials(
    &cui, // CREDUI_INFO structure
    TEXT(""), // Target for credentials
    NULL, // Reserved
    0, // Reason
    pszName, // User name
    CREDUI_MAX_USERNAME_LENGTH, // Max number for user name
    pszPwd, // Password
    CREDUI_MAX_PASSWORD_LENGTH, // Max number for password
    &fSave, // State of save check box
    CREDUI_FLAGS_GENERIC_CREDENTIALS |
    CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX |
    CREDUI_FLAGS_ALWAYS_SHOW_UI |
    CREDUI_FLAGS_EXPECT_CONFIRMATION);

    if(dwErr)
    return;

    DWORD dwInvalid = CredUIConfirmCredentials(_T(""), TRUE);
    if (!dwInvalid)
    return;
    Leo, Feb 9, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3RlcGhlbiBJbmtwZW4=?=

    Device search returns devices with zero length strings

    =?Utf-8?B?U3RlcGhlbiBJbmtwZW4=?=, Jul 6, 2005, in forum: Wireless Networking
    Replies:
    2
    Views:
    492
    =?Utf-8?B?TWlsZXM=?=
    Jul 15, 2005
  2. TEM

    VPN Ping returns 1 packet

    TEM, Oct 22, 2003, in forum: Cisco
    Replies:
    1
    Views:
    446
    Rik Bain
    Oct 22, 2003
  3. Richard Antony Burton

    show running returns nothing, routing stops

    Richard Antony Burton, Nov 21, 2003, in forum: Cisco
    Replies:
    10
    Views:
    770
    Richard Antony Burton
    Nov 25, 2003
  4. Replies:
    11
    Views:
    18,777
    Simon Leinen
    Apr 10, 2005
  5. neotx

    CredUIPromptForCredentials

    neotx, Jun 23, 2008, in forum: Windows 64bit
    Replies:
    2
    Views:
    743
Loading...

Share This Page