fra*_*tim 6 c++ windows winapi credentials credential-providers
我正在尝试编写自定义Windows凭据提供程序.我已经下载了V2凭证提供程序示例,我可以构建,注册和使用它.
为了测试,我已经设置了一个hyper-v Windows 8.1实例并加入了一个Windows测试域.
但是,自定义凭据提供程序仅显示在用户切片上,而不显示在"其他用户"磁贴上.
文档(Windows 8.docx中的凭据提供程序框架更改)提供了一个小代码段:
// 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;
}
Run Code Online (Sandbox Code Playgroud)
我不确定'_fIsOtherUserTile'来自哪里.如果我忽略了这一点并且只是将'hr'设置为S_FALSE,则凭证提供程序仍未显示在"其他用户"磁贴上.
我错过了什么?我需要更改哪些内容才能在"其他用户"磁贴上使用凭据提供程序?
通常我会做Web项目,所以我对Windows SDK没什么经验.
如果您使用该示例,它始终在 Initialize 函数中初始化 SID,因此此代码始终将 SID 复制到函数的返回指针中,无论您之后做什么(_pszUserSid != nullptr 在示例中始终为 true )。如果你想拥有这个功能,并且让你的CP显示在“其他用户”下,那么body应该无非是:
*ppszSid = nullptr;
return S_FALSE;
Run Code Online (Sandbox Code Playgroud)
如果您不希望您的磁贴与用户绑定,则根本不必实现 ICredentialProviderCredential2,因为它仅添加此功能。如果没有实现此接口,您的 CP 将始终显示在“其他用户”下。实现 ICredentialProviderCredential 就足够了。