Win32:CredUIConfirmCredentials 行为异常

发布于 2024-08-19 03:03:46 字数 1879 浏览 13 评论 0原文

我将 CredUIConfirmCredentialsCredUIPromptForCredentials

设置了EXPECT_CONFIRMATION,当凭证首先由 用户对 CredUIConfirmCredentials 的调用按预期返回 NO_ERROR

但是,在对 CredUIConfirmCredentials 的所有后续调用中,使用相同的 凭据,返回ERROR_INVALID_PARAMETER。这是由 SDK文档为

尝试确认等待 凭证失败,因为 凭证包含无效或 数据不一致。

这相当令人困惑,因为它们与最初成功保存的凭据完全相同。

如果您为同一密码输入不同密码,则会返回相同的结果 用户名。更令人困惑的是,新的凭证是 实际上持续存在 - 这似乎表明返回值是 实际上表明持久的凭据被覆盖 - 不是 出现错误。我是否遗漏了什么,或者是文档 不正确?


背景

您可以使用 Window 的凭据系统来存储您自己的应用程序的凭据。您告诉 Windows 您想要提示输入某些“目标”的“通用”凭据:

伪代码:

CredUIPromptForCredentials("My Application", ref username, ref password);

然后将导致 Windows 显示一个对话框:

alt text

然后您的工作就是检查用户输入的凭据。如果它们有效,您可以通过调用 ConfirmCredentials 告诉 Windows。这是为了确保仅保存有效的凭据:

CredUIConfirmCredentials("My Application", true);

一旦确认凭据有效,Windows 会将它们保存在安全存储中,您可以通过控制面板查看:

替代文字

关键词:credui、CredUIConfirmCredentials

I'm using CredUIConfirmCredentials in combination with
CredUIPromptForCredentials.

I set the EXPECT_CONFIRMATION, and when the credentials are first provided by
the user the call to CredUIConfirmCredentials returns NO_ERROR as expected.

However, on all subsequent calls to CredUIConfirmCredentials, with the same
credentials, ERROR_INVALID_PARAMETER is returned. This is described by the
SDK docs as
:

An attempt to confirm a waiting
credential failed because the
credential contained invalid or
inconsistent data.

which is rather confusing as they are exactly the same credentials that were successfully saved originally.

The same result is returned if you enter a different password for the same
username. What is even more confusing is that the new credentials are
actually persisted - which seems to indicate that the return value is
actually indicating that the persisted credentials were overwritten - not
that there was a error. Am I missing something, or is the documentation
incorrect?


Background

You can use Window's credential system to store credentials for your own application. You tell Windows you want to prompt for "generic" credentials for some "target":

pseudo-code:

CredUIPromptForCredentials("My Application", ref username, ref password);

will then cause Windows to display a dialog box:

alt text

It is then your job to check the credentials the user has entered. If they are valid, you tell Windows this by calling ConfirmCredentials. This is to ensure that only valid credentials are saved:

CredUIConfirmCredentials("My Application", true);

Once the credentials have been confirmed as valid, Windows will save them in the secure store, which you can see through the Control Panel:

alt text

Keywords: credui, CredUIConfirmCredentials

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2024-08-26 03:03:46

我找到了答案:根据设计

CredUIConfirmCredentials 将返回错误“当无事可做时”。这意味着:

  • 如果凭据与凭据存储中已有的凭据相同,则
  • 用户没有选中记住我的密码复选框,
  • 您没有设置CREDUI_FLAGS_EXPECT_CONFIRMATION标志

事实上,当凭据与 MSDN 上记录的存储中已有的凭据相同时,CredUIConfirmCredentials 会失败。 (我知道它已记录,因为我添加到 文档页面。)

i found the answer: by design

CredUIConfirmCredentials will return an error "when there's nothing to do". This means:

  • if the credentials are the same as what's already in the credential store
  • the user didn't check the Rembember my password check box
  • you didn't set the CREDUI_FLAGS_EXPECT_CONFIRMATION flag

The fact that CredUIConfirmCredentials fails when the credentials are the same as what's already in the store documented on MSDN. (i know it's documented because i added to the documentation page.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文