Skip to content

Commit

Permalink
MSFT: 11202393 Reuse the wrapped credential instead of recreating it
Browse files Browse the repository at this point in the history
LogonUI can call SetUsageScenario multiple times, which
caused us to recreate the wrapped credential provider.
  • Loading branch information
edetoc authored and oldnewthing committed Apr 27, 2017
1 parent 02f6cc7 commit e758de9
Showing 1 changed file with 12 additions and 12 deletions.
Expand Up @@ -72,22 +72,22 @@ HRESULT CSampleProvider::SetUsageScenario(
__in DWORD dwFlags
)
{
HRESULT hr;
HRESULT hr = S_OK;

// Create the password credential provider if we don't already have one,
// and query its interface for an ICredentialProvider we can use.
if (_pWrappedProvider == NULL)
{
hr = CoCreateInstance(CLSID_PasswordCredentialProvider, NULL, CLSCTX_ALL, IID_PPV_ARGS(&_pWrappedProvider));
}

// 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(&pUnknown));
// Once the provider is up and running, ask it about the usage scenario
// being provided.
if (SUCCEEDED(hr))
{
hr = pUnknown->QueryInterface(IID_PPV_ARGS(&(_pWrappedProvider)));
if (SUCCEEDED(hr))
{
hr = _pWrappedProvider->SetUsageScenario(cpus, dwFlags);
}
pUnknown->Release();
hr = _pWrappedProvider->SetUsageScenario(cpus, dwFlags);
}

if (FAILED(hr))
{
if (_pWrappedProvider != NULL)
Expand Down

0 comments on commit e758de9

Please sign in to comment.