在 Winform 应用程序中获取用户 NT 凭据
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用 CredentialCache .默认凭据?这似乎可以让您获得当前登录的用户凭据。
Can you try using CredentialCache.DefaultCredential? That seems to get you the current logged in users credential.
如果“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?