ASMX Web服务的授权
问题描述:
我ASMX web服务(C#)。我使用Windows身份验证来访问Web服务。
现在我只需要为用户speciefic提供了一些Web服务方法,例如测试。我找不到这样的授权的例子。 code的一些例子是AP preciated。
I have asmx web service(c#). I'm using Windows Authentication to access web service. Now i need to provide some of web service methods only for speciefic user, for example Test. I cant find examples of such Authorization. Some examples of code would be appreciated.
答
我不认为Web服务都有每memeber这样的限制。也许你需要检查网络服务成员内的用户权限
I don't think that web service have such restriction per memeber. Probably you will need to check the user rights inside of the web service members
[WebMethod]
public void HelloWorld()
{
if (this.DoesUserHaveRights(HttpContext.Current.User))
{
// do the work here
}
else
throw new AuthenticationException();
}
或somethign像这样
or somethign like this