Search code examples
c++windowscredential-providers

How to call default windows credential in my code?


I have my own implementation of "windows credential provider".
In some scenarios my custom credential must switch to windows default credential and the user must see the "windows credential provider" to do the login process.
How can I exit my own "credential" and call the default "windows credential"?


Solution

  • In new scenario of Microsoft Windows's Credential Providers, you can't direct which other provider user must use to log on to the system.

    The only thing you can do is to force logon using your own provider or decline logon using your provider.

    To do this you must:

    1. Set pdwDefault to any useful value and pbAutoLogonWithDefault to true inside of call to GetCredentialCount.

    2. Set the CREDENTIAL_PROVIDER_GET_SERIALIZATION_RESPONSE *pcpgsr parameter inside of GetSerialization method to one of the following values:

      • CPGSR_RETURN_CREDENTIAL_FINISHED - to do auto-logon,
      • CPGSR_RETURN_NO_CREDENTIAL_FINISHED - to cancel logon UI process.

    In any case your provider (tile) will loose the focus. Check out this doc.

    Update

    You can remove your provider from entire logon process by returning E_NOTIMPL value from inside of the call to SetUsageScenario method.

    User and/or Logon UI will be forced to use any other existing provider(s).