使用c#使用windows身份验证登录站点

发布于 2024-07-06 15:33:07 字数 165 浏览 5 评论 0原文

我想使用当前登录用户的 Windows 身份验证登录到我的程序内的服务器。我想也许我可以使用

System.Security.Principal.WindowsIdentity.GetCurrent().Name

但是虽然这确实给出了一个名称,但我不明白我如何找到用户的密码来输入它。

I want to log on to a server inside my program using Windows authentication of the current user logged in. I thought that perhaps I could use

System.Security.Principal.WindowsIdentity.GetCurrent().Name

but while that does give a name, I do not see how I can find out the password of the user to enter it.

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

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

发布评论

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

评论(6

兮子 2024-07-13 15:33:07

绝对没有办法获取 Windows 用户的密码,因为 Windows 甚至不存储它(它存储的只是一个不可逆的哈希值)。

There's absolutely no way to get the Windows user's password since Windows doesn't even store it (all it stores is an irreversible hash).

梦里人 2024-07-13 15:33:07

您无法获取密码。 您需要使用模拟将身份传递到您尝试连接的服务器。

You cannot get the password. You need to use Impersonation to pass on the identity to the server that you are trying to connect to.

可爱咩 2024-07-13 15:33:07

除非用户将其密码提供给您的应用程序,否则您将无法使用他们的密码进行基本登录。 您必须根据本地登录的用户进行某种模拟或委派权限。

You won't be able to use their password to a basic login unless the user provides it to your application. You'll have to do some sort impersonation or delegate authority based on the locally logged in user.

烏雲後面有陽光 2024-07-13 15:33:07

在 web.config 中:

  <system.web>
        <authentication mode="Windows" />
        <identity impersonate="true"/>
  </system>

in web.config:

  <system.web>
        <authentication mode="Windows" />
        <identity impersonate="true"/>
  </system>
怪我太投入 2024-07-13 15:33:07

如果您要使用 Windows 用户身份验证,您可能应该使用比简单的用户名/密码组合更安全的部分内容。 (并且可能无法访问密码,因为这意味着每个 .NET 应用程序都可以访问您的完整帐户信息。)

例如,WindowsIdentity.User 被声明对于所有 Windows NT 实现中的用户来说是唯一的。 (我相信这意味着在任何 Windows NT 实现中,这对于给定系统上的每个用户来说都是唯一的......但我不确定。)

If you are going to use the Windows User Authentication, you should probably use some part of it that is more secure than the simple username/password combination. (And there is probably no way to access the password, as that would mean that every .NET application could access your full account information.)

For instance, WindowsIdentity.User is stated to be unique for a user across all Windows NT implementations. (I believe this means that in any Windows NT implementation, this will be unique for each user on a given system... But I'm not sure.)

人│生佛魔见 2024-07-13 15:33:07

如果客户端和服务器都在同一个域中,则不必指定用户名和密码。

如果您使用 HttpRequest,则应设置 LogonUserIdentity< /a>.

如果您正在调用 SOAP 服务,则应设置 凭据 属性。

If both the client and the server are in the same domain, you don't have to specify the username and password.

If you are using HttpRequest, you should set the LogonUserIdentity.

If you are calling a SOAP service, you should set the Credentials property.

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