3

As far as I could understand, when the user presses the Submit button eventually, the GetSerialization method will be called to get login details.

I am programming a Credential Provider that waits for some external signal to log in, and I do not want the user to press the Submit button.

Is it possible to trigger the submit event from the Credential Provider?

cd611
  • 141
  • 7

2 Answers2

7

I found a way to do it. The trick is not to call the submit button, but use the ICredentialProviderEvents::CredentialsChanged method. I have a thread running, that will eventually trigger the CredentialsChanged. This will then enable a new Credential that logs the user in.

This is shown in the Microsoft Sample SampleHardwareEventCredentialProvider.

It is worth notice that the Windows LogonUI automatically selects this new Credential. I do not know if this is in the documentation, but it is the behaviour I experienced.

cd611
  • 141
  • 7
  • 1
    Do you have this thread running in a separate service or did you start a thread within your custom credential provider? When I try to wait for an external signal within a polling thread in my credential provider ,the UI starts flickering as if it reloads the credential provider on every loop. – roberth Dec 08 '17 at 07:33
  • 1
    I start a new thread waiting for the external signal which then calls `CredentialsChanged`. Flickering and reloading, in my experience, means that some invalid access happened (or other error). It would be useful for you to run in a debugger. The way I do this is by running a separate program that basically creates the COM object using `CoCreateInstance` and calling the `ICredentialProvider` methods. – cd611 Dec 10 '17 at 20:26
  • 1
    Thanks @cd611, I'll try. – roberth Dec 11 '17 at 07:58
  • Sorry for late responds, maybe [this](https://stackoverflow.com/a/69908444/16980671) will gonna help you – MH Rahman Dec 08 '21 at 02:36
  • @cd611 Have you got it working for multiple users? – HNR Jun 30 '23 at 09:59
2

The more appropriate way would be to implement the IConnectableCredentialProviderCredential interface, which is designed specifically for this purpose.

James Westgate
  • 11,306
  • 8
  • 61
  • 68
  • Doc says IConnectableCredentialProviderCredential::Connect() gets called after user clicks Submit button. Can you please elaborate on how this interface should be implemented so that it simulates submit button click. Thanks – HNR Jun 30 '23 at 09:54