title: Remote Desktop Connection with Custom Credential Provider
body: <p>I have developed a custom credential provider using the SampleWrapExistingCredentialProvider from VistaCredentialProviderSamples. The credential provider has a filter implemented that filters all other credential providers and I see just my credential provider at the time of logon. The issue is that if we connect to it using remote desktop connection, the username/password are not passed from windows RDP client to the Credential provider and I have to enter it again when RDP session opens (unlike the behavior with default provider)</p>
  
  <p>I am trying to explore which part of the code handles this scenario that the credential provider accepts the username/password from remote desktop client and does not ask again. Attached is the screenshot of my credential provider after providing successful credentials on the RDP client. After I click this icon of my credential provider, I am shown the credential provider tile that asking again for the username and password. Any help would be highly appreciated on how to receive credentials from RDP client.<a href="https://i.stack.imgur.com/hpcdO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hpcdO.png" alt="This is the logon screen that appears after I enter username password on remote desktop connection"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bSkhE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bSkhE.png" alt="This appears after I select my CP. Username and password not filled up"></a></p>
  
  <p>I have returned S_OK for CREDUI. My SetUsageScenario is as follows:</p>
  
  <pre><code>HRESULT CSampleProvider::SetUsageScenario(
  CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus,
  DWORD dwFlags
  )
  {
      HRESULT hr;
  
  // Create the password credential provider and query its interface for an
  // ICredentialProvider we can use. Once it's up and running, ask it about the 
  // usage scenario being provided.
  IUnknown *pUnknown = NULL;
  hr = ::CoCreateInstance(CLSID_PasswordCredentialProvider, NULL, CLSCTX_ALL, IID_PPV_ARGS(&amp;pUnknown));
  if (SUCCEEDED(hr))
  {
      hr = pUnknown-&gt;QueryInterface(IID_PPV_ARGS(&amp;(_pWrappedProvider)));
      if (SUCCEEDED(hr))
      {
          hr = _pWrappedProvider-&gt;SetUsageScenario(cpus, dwFlags);
          switch (cpus)
          {
          case CPUS_LOGON:
          case CPUS_UNLOCK_WORKSTATION:
          case CPUS_CREDUI:
          {
              hr = S_OK;
              break;
          }
          case CPUS_CHANGE_PASSWORD:
          default:
              hr = E_INVALIDARG;
              break;
          }
      }
  }
  if (FAILED(hr))
  {
      if (_pWrappedProvider != NULL)
      {
          _pWrappedProvider-&gt;Release();
          _pWrappedProvider = NULL;
      }
  }
  
  return hr;
  }
  </code></pre>