CredUIPromptForWindowsCredentials (credui.dll) not working Windows 11

Leon Wolf 41 Reputation points
2022-05-30T05:36:52.317+00:00

Hello,
i am currently working on a C# project that contains interaction with the credui.dll, calling the CredUIPromptForWindowsCredentials on a secure desktop. When executing on a Windows 10 machine, it all executes the way i want it to, however the same code fails to call up the CredUI and i am then stuck on a secure desktop when executing on Windows 11.
Are there any known bugs about this, or any changes made to Windows 11 that have changed the behaviour of the CredUI?
I haven't found anything on common help sites.

Thank you for your help!

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,617 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,245 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,164 questions
{count} vote

Accepted answer
  1. Junjie Zhu - MSFT 14,751 Reputation points Microsoft Vendor
    2022-06-20T07:11:42.613+00:00

    Hello, Leon
    Welcome to Microsoft Q&A!

    Microsoft does not want ISVs to continue to create their own custom desktops through CreateDesktop() in win11, so the correct solution is to use the CREDUIWIN_SECURE_PROMPT flag, cancel the use of CreateDesktop, and use Ctrl+Alt+Delete to enter CredUI, which should also meet your needs.

      dialogReturn = CredentialsPromptHelper.CredUIPromptForWindowsCredentials(ref credui, errorcode, ref authPackage, IntPtr.Zero, 0, out outCredBuffer, out outCredSize, ref save, CredentialsPromptHelper.PromptForWindowsCredentialsFlags.CREDUIWIN_SECURE_PROMPT);  
    

    212789-gif-2022-6-20-15-09-42.gif

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,351 Reputation points
    2022-06-06T07:20:29.743+00:00

    Hello Leon,

    If the desktop becomes out of focus or secured, most likely is due to the way that UAC handles the credentials popup request.

    To confirm this, just disable temporary UAC through powershell with:

    New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -PropertyType DWord -Value 0 -Force


    --If the reply is helpful, please Upvote and Accept as answer--