在 Winform 应用程序中获取用户 NT 凭据

发布于 2024-10-14 05:58:19 字数 434 浏览 3 评论 0原文

我有一个 winform 应用程序,需要我检查我们的 Wiki 上是否存在某个页面。但是,该查询需要传递用户的 NetWork 凭据。

我不想对我的凭据进行硬编码,也不希望用户每次其他人使用 App.config 时都必须对其进行操作(还存在他们必须在 App.Config 中公开其密码的问题)。有没有办法获取当前用户的 NT 凭据?我不需要看到它(这将是一个明显的安全问题),我只需要它来执行以下代码行:

HttpWebRequest WikiPageRequest;
WikiPageRequest.Credentials = new NetworkCredential("user", "pass", "dom");
//maybe do something like this
WikiPageRequest.Credentials = GetNTCredentials();

I have a winform app that requires me to check whether a page exists on our Wiki or not. However, that query requires a users NetWork credentials to be passed.

I don't want to hardcode my credentials, and I don't want users to have to manipulate the App.config everytime someone else uses it (there's also the issue of them having to expose their password in the App.Config). Is there a way I can get the current user's NT credentials? I don't need to see it (that would be an obvious security issue), I just need it for the following line of code:

HttpWebRequest WikiPageRequest;
WikiPageRequest.Credentials = new NetworkCredential("user", "pass", "dom");
//maybe do something like this
WikiPageRequest.Credentials = GetNTCredentials();

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

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

发布评论

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

评论(2

垂暮老矣 2024-10-21 05:58:19

您可以尝试使用 CredentialCache .默认凭据?这似乎可以让您获得当前登录的用户凭据。

Can you try using CredentialCache.DefaultCredential? That seems to get you the current logged in users credential.

感性不性感 2024-10-21 05:58:19

如果“wiki”是指 MediaWiki 的部署,那么遗憾的是您需要用户 ID 和密码。

不幸的是,您无法从 Windows 获取该密码,因为即使 Windows 操作系统本身也不知道该密码。它只存储密码的哈希值。

顺便说一句,为什么不在每次用户启动应用程序时询问 wiki 的用户 ID/密码呢?

If by "wiki", you mean a deployment of MediaWiki, then sadly you need user id and password.

Unfortunately you cannot get it from Windows, because, even the Windows OS itself does not know the password. It just stores a hash of the password.

By the way, why dont you ask for user id/password for wiki each time the user starts the app?

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