Windows Credential Providers V2 C# Active for All users(Tiles)

232 views Asked by At

I'm new to credential providers and I'm having a problem, I don't know exactly how to display the credentials for all users, right now the credentials are only displayed for the user with index 0, I'm following this example CSharpSampleProvider (FullProject) from https://github.com/djcho

I added a for to the code to generate a credential for each user that was in the system but the credential ended up showing in the last user when the loop finished executing, a new credential is not being created for each user and assigned to the user according to the Id , it's more like you're updating the information and you run the for until you get to the last user and the credential that exists has been available first to the user with index 0, then index 1, and so on.

int EnumerateCredentials()
{
    Log.LogMethodCall();
    int hr = HResultValues.E_UNEXPECTED;
    if (_pCredProviderUserArray != null)
    {
        uint dwUserCount = 0;
        _pCredProviderUserArray.GetCount(out dwUserCount);
        if (dwUserCount > 0)
        {
            for (uint i = 0; i < dwUserCount; i++)
            {
                ICredentialProviderUser pCredUser;
                hr = _pCredProviderUserArray.GetAt(i, out pCredUser);
                if (hr >= 0)
                {
                    _pCredential = new CSharpSampleCredential();
                    if (_pCredential != null)
                    {
                        hr = _pCredential.Initialize(_cpus, Field.s_rgCredProvFieldDescriptors, Field.s_rgFieldStatePairs, pCredUser);
                        if (hr < 0)
                        {
                            var intPtr = Marshal.GetIUnknownForObject(_pCredential);
                            Marshal.Release(intPtr);
                            _pCredential = null;
                        }
                    }
                    else
                    {
                        hr = HResultValues.E_OUTOFMEMORY;
                    }
                    {
                        var intPtr = Marshal.GetIUnknownForObject(pCredUser);
                        Marshal.Release(intPtr);
                    }
                }
            }
        }
    }
    return hr;
}

I really appreciate the help, greetings.

0

There are 0 answers