Web 服务的基本身份验证

发布于 2024-10-06 07:50:03 字数 700 浏览 0 评论 0原文

我在设置 Web 服务的基本身份验证时遇到问题。 我正在使用 .NET 4.0 编写标准 Web 服务(不是 WCF)

在 web.config 中我有以下设置:

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

Web 服务有一种方法:

[WebMethod(Description = "Returns currently logged in user.")]
public string WhoAmI()
{
    return "You are logged in as: " + System.Threading.Thread.CurrentPrincipal.Identity.Name;
}

测试服务器是与我的计算机位于同一域的虚拟机。当我访问它时,我没有得到任何有关 CurrentPrincipal.Identity.Name 的信息。

我还尝试使用soapUI 访问Web 服务。我输入了用户名、密码和域名,但仍然无法使用。

任何帮助将不胜感激。

I'm having problems to set up the basic authentication for the web service.
I'm writing standard web service (not WCF) using .NET 4.0

In the web.config I have the following settings:

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

The web service has one method:

[WebMethod(Description = "Returns currently logged in user.")]
public string WhoAmI()
{
    return "You are logged in as: " + System.Threading.Thread.CurrentPrincipal.Identity.Name;
}

The test server is virtual machine located on the same domain as my machine. When I access it, I don't get anything for the CurrentPrincipal.Identity.Name.

I also tried to access the web service using the soapUI. I entered my username, password and domain but I still can't get it to work.

Any help would be appreciated.

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

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

发布评论

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

评论(2

飞烟轻若梦 2024-10-13 07:50:03

在 IIS (inetmgr) 上,您可以找到“身份验证方法”窗口。(WebService1->属性->目录安全性->身份验证控制->编辑按钮)

您可以选择身份验证访问。 (摘要、基本、集成认证)
之后改变你的方法就会如你所愿。

On IIS (inetmgr) you can find Authendication Method window.(WebService1->Properties->Directory Security->Authendication Controls->Edit Button)

You can choose Authendicated access. (Diggest,Basic,Integrated Authendication)
After that changing your method will work as you want.

将军与妓 2024-10-13 07:50:03

如果将 impresionate 更改为 impersonate 是否有效?

Does it work if you change impresionate to impersonate?

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