首页 > 解决方案 > Windows 凭据提供程序 - 在接收凭据之前销毁

问题描述

我正在编写一个 Windows 凭据提供程序,但由于缺乏有关该程序如何工作的文档,我一直在苦苦挣扎。

我从 Windows SDK 示例 ( security/SampleCredentialProvider) 开始并对其进行了修改,以便从 SYSTEM 服务接收凭据,该服务通过管道充当服务器。

问题是:当凭证提供者对象(实现的那个ICredentialProviderGetCredentialCount被调用时,它还没有通过该管道从 SYSTEM 服务接收到凭证,因此我返回一个 0 凭证号(*pdwCount = 0;)。

我不确定这是否是问题的原因,但此后不久就会调用对象析构函数。这反过来又破坏了我正在等待传递 SYSTEM 服务凭据的管道,并且没有任何效果。

我的问题是:为什么实现的对象ICredentialProvider被破坏了?为了让提供者等待通过管道传递的凭据,然后通知 LogonUI 我们有新的凭据,我怎样才能避免它的破坏?

我附上了一些从 Windows 事件查看器中获取的关于我的凭据提供程序模块的事件:

- Credential provider object is created
- SetUsageScenario is called, only CPUS_LOGON is supported
- Advise is called, pcpe parameter is saved and AddRef'd
- GetCredentialCount, 0 is returned (no credential received yet)
- UnAdvise is called (this is unexpected, does this mean I can no longer pass credentials? Why is this called?)
- pipe to receive credentials is created
- Credential provider object's destructor is called -> pipe is destroyed and everything terminates

标签: c++windowscomwinlogoncredential-providers

解决方案


发现问题:我卡在 Ctrl+Alt+Del 屏幕上,我正在查看的凭据提供程序日志是 RDP 的(我使用它来登录和调试问题)。


推荐阅读