0

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.

  • 1
    You must create another one tile and DON'T associate it with any user. – Alexander Feb 14 '23 at 09:02
  • @Alexander What exactly do you mean by not associating it with a user? I don't know if this should be executed this way but, in the ```GetCredentialCount()``` class, by matching the ```pdwCount``` parameter to the number of users ```dwUserCount``` instead to create a tile for each user, all the tiles go to the same user, which in this case with the for loop are implemented in the user with the last index, index 2. https://gyazo.com/162ef659e7ad5c2c94691766c557245d- The result https://gyazo.com/911c5497481fdca15b42c9e8b4dcdab4 - Code – Jose alberto Feb 14 '23 at 10:12
  • Credentials tiles your provider reporting is not 1 to 1 dependent on the user list. It can be smaller or greater - it is your choice. – Alexander Feb 14 '23 at 16:21
  • When I implemented my provider I returned an 2-4 `Other User` tiles without any `User` tiles. – Alexander Feb 14 '23 at 16:25
  • @Alexander Right now I wouldn't know how to solve that dependency either because I can't think of exactly how it is failing, so I think the credential data is being overwritten and it changes from user with index 0, then to user index 1 and so on until the last user on the array ```_pCredProviderUserArray``` I checked the ```GetUserSid()``` method in case there was any problem when sending the data, but neither – Jose alberto Feb 14 '23 at 16:54

0 Answers0