Reputation: 9644
I've a simple Web Service getAD.asmx
that I use to retrieve data from active directory. I need to execute WS as a specific user, and be sure that only corporate user could consume it, so I'm using Windows authentication and ASP.NET Impersonation.
I tried to add a local simple web form to test my service, and it seems to work correctly
getAD myWS = new getAD();
string testResult = myWS.test(); // testResult execute correctly
Now I'm trying to call the same service from another C# application, so I added a Web Reference and did the same call, but I get a 401 error (Unauthorized) with any user.
rbasws01.getAD myWS = new rbasws01.getAD();
string testResult = myWS.test(); // error 401, not authorized
Am I missing something?
EDIT: this is the code of my WebService
[WebService(Namespace = "http://myUri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class getAD : System.Web.Services.WebService {
[WebMethod]
public string test() {
return "Test positive";
}
}
Upvotes: 0
Views: 803
Reputation: 28097
Try setting a localhost:[some-port-number]
binding on your IIS and pointing your request of the webservice to that.
So instead of calling http://myUri.org/ws/something
, call http://localhost:1234/ws/something
from within your application.
IIS can be a bit funny sometimes about talking to itself - I read this is to prevent some kind of attacks, but never was able to find the link again! Thanks to @LeeHarrison, this is called Loopback Checking.
Another way of getting round this issue is to disable Loopback Checking as described in this KB Article.
Upvotes: 1