コード例 #1
0
//
// Depending on whether SetSerialization has been called and what CPUS we're in
// creates the right set of credentials
//
HRESULT CSampleProvider::_CreateEnumeratedCredentials()
{
    HRESULT hr = E_INVALIDARG;
    switch(_cpus)
    {
    case CPUS_LOGON:
        if (_pkiulSetSerialization)
        {
            hr = _EnumerateSetSerialization();
        }
        else
        {
            hr = _EnumerateCredentials();
        }
        break;

    case CPUS_CHANGE_PASSWORD:
        break;

    case CPUS_UNLOCK_WORKSTATION:
        // a more advanced implementation would only enumerate tiles that could gather creds for the logged on user
        // since those are the only creds that will work to unlock the session
        // but we're going with this for simplicity
        hr = _EnumerateCredentials();  
        break;

    case CPUS_CREDUI:
        _bDefaultToFirstCredential = true;

        if (_pkiulSetSerialization)
        {
            hr = _EnumerateSetSerialization();
        }
        if (_dwCredUIFlags & CREDUIWIN_ENUMERATE_ADMINS)
        {
            // this sample doesn't handle this particular case
            // You would want to handle this in order to participate
            // User Account Control elevations for a non-admin users (where all the
            // admins tiles are enumerated)
        }
        else if (!(_dwCredUIFlags & CREDUIWIN_IN_CRED_ONLY))
        {
            // if we're here, then we're supposed to enumerate whatever we should enumerate for the normal case.  
            // In our case, that's our 2 tiles.  We may already have one tile, though
            if (_pkiulSetSerialization && SUCCEEDED(hr))
            {
                hr = _EnumerateCredentials(true);
            }
            else
            {
                hr = _EnumerateCredentials(false);
            }
        }
        break;

    default:
        break;
    }
    return hr;
}
コード例 #2
0
void MultiotpProvider::_CreateEnumeratedCredentials()
{
	if (DEVELOP_MODE) PrintLn("MultiotpProvider::_CreateEnumeratedCredentials: %d", _cpus);
	switch (_cpus)
    {
    case CPUS_LOGON:
		if (DEVELOP_MODE) PrintLn("MultiotpProvider::_CreateEnumeratedCredentials CPUS_LOGON");
        _EnumerateCredentials();
        break;

    case CPUS_UNLOCK_WORKSTATION:
		if (DEVELOP_MODE) PrintLn("MultiotpProvider::_CreateEnumeratedCredentials CPUS_UNLOCK_WORKSTATION");
        _EnumerateCredentials();
        break;

    default:
        break;
    }
}