6

I am trying to write a custom Windows credential provider. I have downloaded the V2 credential provider sample and I am able build, register and use it.

For testing I have set up a hyper-v Windows 8.1 instance and joined a windows test domain.

However, the custom credential provider is only displayed on user tiles, not on the 'Other user' tile.

The documentation (Credential Provider Framework Changes in Windows 8.docx) provides a small snippet:

// Gets the SID of the user corresponding to the credential. HRESULT CSampleCredential::GetUserSid(__deref_out PWSTR *ppszSid)
{
    *ppszSid = nullptr;
    HRESULT hr = E_UNEXPECTED;

    // _pszUserSid is a private member of CSampleCredential
    if (_pszUserSid != nullptr)
    {
        // ppszSid will be freed by Logon UI
        hr = SHStrDupW(_pszUserSid, ppszSid);
    }
    // Return S_FALSE with a null SID in ppszSid for the
    // credential to be associated with an anonymous user tile.
    else if (_fIsOtherUserTile)
    {
        hr = S_FALSE;
    }

    return hr;
}

I am not sure where '_fIsOtherUserTile' is coming from. If I am ignoring this and just set 'hr' to S_FALSE the credential provider is still not showing up on the 'Other user' tile.

What am I missing? What do I have to change so I am able to use the credential provider on the 'Other user' tile?

Usually I do web projects so I have little experience with the Windows SDK.

4

1 回答 1

3

如果您使用示例,它总是在 Initialize 函数中初始化 SID,所以这段代码将始终将 SID 复制到函数的返回指针中,无论您之后做什么(_pszUserSid != nullptr 在示例中始终为 true )。如果你想拥有这个功能,让你的CP显示在“其他用户”下,那么body应该是:

    *ppszSid = nullptr;
    return S_FALSE;

如果您不希望您的磁贴与用户绑定,则根本不必实现 ICredentialProviderCredential2,因为它只添加了此功能。如果没有实现此界面,您的 CP 将始终显示在“其他用户”下。实现 ICredentialProviderCredential 就足够了。

于 2017-08-29T06:55:07.413 回答