Web 服务的基本身份验证
我在设置 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 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.
如果将
impresionate
更改为impersonate
是否有效?Does it work if you change
impresionate
toimpersonate
?