locked
Credential Provider for Windows 8 not working RRS feed

  • Question

  • Hi,

    I built a Custom CP for windows8 with the existing Windows7 and with the help of new document(Credential Provider framework changes in Windows8) available.

    But, My CP doesn't showed up on the logon screen. What could be the reason?

    Following are the changes that I made.   

    HRESULT CSampleCredential::GetUserSid(__deref_out LPWSTR *ppszSid)
    {
        *ppszSid = nullptr;
        HRESULT hr = E_UNEXPECTED;

        if (_pszUserSid != nullptr)
        {
    // ppszSid will be freed by Logon UI
            hr = SHStrDupW((LPCWSTR)_pszUserSid, ppszSid);
        }
        else //if (_fIsOtherUserTile) //I don't understand where this bool value can be set in the code (Let me know if anyone knows it)
        {
            hr = S_FALSE;
        }
        return hr;
    }


    HRESULT CSampleProvider::GetCredentialCount(
        __out DWORD* pdwCount,
        __out_range(<,*pdwCount) DWORD* pdwDefault,
        __out BOOL* pbAutoLogonWithDefault
        )
    {
        *pdwCount = 1;
        *pdwDefault = 0;
        *pbAutoLogonWithDefault = FALSE;

    if(_pCredProviderUserArray != nullptr)
    {
    HRESULT hr = S_OK;
    ICredentialProviderUser* pCredUser;
    hr = _pCredProviderUserArray->GetAt(0, & pCredUser);  
            if(SUCCEEDED(hr))
            {
            _pCredential = new(std::nothrow) CSampleCredential();
           if (_pCredential != nullptr)
           {
               hr = _pCredential->Initialize(_cpus, s_rgCredProvFieldDescriptors, s_rgFieldStatePairs, pCredUser);
               if (FAILED(hr))
               {
                   _pCredential->Release();
                   _pCredential = nullptr;
               }
           }
           else
           {
               hr = E_OUTOFMEMORY;
           }
    pCredUser->Release();
            }
    }
        return S_OK;
    }

    During initialization, 

    HRESULT CSampleCredential::Initialize(
    __in CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus,
    __in const CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR* rgcpfd,
    __in const FIELD_STATE_PAIR* rgfsp,
    __in ICredentialProviderUser* credUser
    )
    {

    ...

    // Got the user sid as below

    *_pszUserSid = new TCHAR[256];
    hr = credUser->GetSid(_pszUserSid);

    ...

    }

    HRESULT  CSampleProvider::SetUserArray (__in ICredentialProviderUserArray * users)
    {
    if (_pCredProviderUserArray)  
        {  
            _pCredProviderUserArray-> Release();  
        }  
        _pCredProviderUserArray = users;  
        _pCredProviderUserArray-> AddRef ();  
        return  S_OK;
    }

    And I couldn't figure out how can I set my provider image ? Please let me know how to solve the issue.

    If someone can share the sample code of implementation for Windows8 is very much appreciated.

    Thanks,

    Ranga

    Tuesday, May 21, 2013 11:25 AM