I am using CredUIPromptForCredentials to prompt the user for credentials which are then passed to a web service.
The prompt shows the "Remember my password" option, so that User Name and Password can be populated with previously used values.
When the prompt appears and the credentials are pre-filled, I can't proceed until I actually select the User Name from the drop-down.
This is the screen I am seeing:
Clicking OK does nothing but bring up the Examples tip, but if I manually select "Greg" from the drop-down, I am able to proceed.
Here's the code I'm using:
StringBuilder userPassword = new StringBuilder(), userID = new StringBuilder();
CREDUI_INFO credUI = new CREDUI_INFO();
credUI.cbSize = Marshal.SizeOf(credUI);
bool save = true;
CREDUI_FLAGS flags = CREDUI_FLAGS.ALWAYS_SHOW_UI | CREDUI_FLAGS.GENERIC_CREDENTIALS
| CREDUI_FLAGS.SHOW_SAVE_CHECK_BOX ;
//Display password prompt:
CredUIReturnCodes returnCode = CredUIPromptForCredentials
(ref credUI, this.serverName, IntPtr.Zero, 0, userID, 100, userPassword, 100, ref save, flags);
OS is Windows 7 and Server 2008 r2.
I have created a complete but simple sample application which can be downloaded from https://docs.google.com/open?id=0BxSAZ9JlU2w9VHZWWFBjVEhTNG02N1Q4WkFrUkhDUQ for testing.
I was going to attempt to answer your question, but you solved it yourself too quickly.
However, in reading the documentation on CredUIPromptForCredentials I notice that you are recommended to use CredUIPromptForWindowsCredentials on Windows 7 and Server 2008.
In Googling around I found this excellent free class library which contains wrappers for several native APIs including a complete example of showing the credential dialog using the CredUIPromptForWindowsCredentials API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With