Showing posts with label unauthorized. Show all posts
Showing posts with label unauthorized. Show all posts

Wednesday, March 28, 2012

web service 401 unauthorized

I am using Avanade ACA web services which I guess uses .net web
services under the wraps. My requirement is use windows authentication
and allow user identity to pass thru to the web service and then to a
database.
I have two websites in the same box - one is the UI and other is the
webservices. It works when I have anonymous clicked on in the
webservices but it does not work when I switch this off and windows
authentication on. It throws the exception - system.net.webexception
401 Unathorrized.
I have tried using
<system.net>
<defaultProxy useDefaultCredentials="true">
<system.net>
in the web services but with no success. I have also given all
permissions to the Network Service (default app pool identity) for the
file system for the web site.
Now this looks like a common problem with .net web services and I am
not sure what else I can try.
Anyone done this before or have some idea?
Thanks in advance
Kishana Webservice method call simply transmits a SOAP envelope; no windows
credentials are included. So using Windows authentication in the IIS without
some sort of mechanism to transmit credentials as one would get with a norma
l
browser request that knows how to reply to the www-authenticate challenge is
not going to work.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
"kishan.bisht@.gmail.com" wrote:

> I am using Avanade ACA web services which I guess uses .net web
> services under the wraps. My requirement is use windows authentication
> and allow user identity to pass thru to the web service and then to a
> database.
> I have two websites in the same box - one is the UI and other is the
> webservices. It works when I have anonymous clicked on in the
> webservices but it does not work when I switch this off and windows
> authentication on. It throws the exception - system.net.webexception
> 401 Unathorrized.
> I have tried using
> <system.net>
> <defaultProxy useDefaultCredentials="true">
> <system.net>
> in the web services but with no success. I have also given all
> permissions to the Network Service (default app pool identity) for the
> file system for the web site.
> Now this looks like a common problem with .net web services and I am
> not sure what else I can try.
> Anyone done this before or have some idea?
> Thanks in advance
> Kishan
>
On Mar 20, 12:46=A0am, Peter Bromberg [C# MVP]
<pbromb...@.yahoo.NoSpamMaam.com> wrote:
> a Webservice method call simply transmits a SOAP envelope; no windows
> credentials are included. So using Windows authentication in the IIS witho=[/color
]
ut
> some sort of mechanism to transmit credentials as one would get with a nor=[/color
]
mal
> browser request that knows how to reply to the www-authenticate challenge =[/color
]
is
> not going to work.
> -- Peter
> Site:http://www.eggheadcafe.com
> UnBlog:http://petesbloggerama.blogspot.com
> Short Urls & more:http://ittyurl.net
>
> "kishan.bi...@.gmail.com" wrote:
>
>
>
>
>
>
>
> - Show quoted text -
Thanks Peter.
So that means if I need to invoke web services programmatically from
the asp.net I will have to explicitly set user credentials on the SOAP
header.
Is there something built into the framework to do that?
Kishan

Monday, March 26, 2012

web service error: The request failed with HTTP status 401: Unauthorized.

I am doing the web service walk-through from here:http://msdn2.microsoft.com/library/87h5xz7x(en-us,vs.80).aspx

I get the error 'The request failed with HTTP status 401: Unauthorized'. My app is using windows authentication, I made sure the web service folder has permissions for everyone to execute and that didn't work. IIS has annonymous access checked.

I'm not sure what else to do.

Help?

Another thing... I'm using the integrated web server that comes with Visual Studio... does using it change things?

Hello.

I've faced that error when I tried to use async pages (at the time I thought that building a simple web service was the easiest way to test them). if i'm not mistaken, I started facing that kind of problems when I moved to beta 2 (pre-beta 2 releases worked without any problems). at that time i tried using IIS and the 1st attempts worked ok. However, at home I always got that error. never solved at home...really strange thing (in my case the exampl was really simple: the web service only had a single method which returned "hello word"). If anyone knows what wrong please let us know.


I get the same 401 failure under the same conditions. Some additional behaviors are that I can only get the web service discovery to work within the current project with the web service in the same directory. Web service discovery doesn't work for the localhost using a separate project under a different directory. I also have to include the port number in the namespace := "http://localhost:1363/" line for the 'follow link' to work.
The port number changes for each instance of the localhost webserver but seems to be hardcoded into the web service discovery files in the app_webreference folder.
I didn't change the proxy settings.

I mentioned in my previous post that I got the same 401 error.

I found that UNCHECKING the NTLM authentication checkbox in the website, start options dialog boxremoves the 401 error. I'm using Visual Studio Express, Beta 2.
When I go back and re-check the NTLM authentication checkbox, I get the same error or some other strange behavior such as the default.aspx page loads...( I suppose as part of the NTLM authentication process). I created a new page Call_HelloWorld_WebService.aspx that just calls the Hello_World web service as in the walkthrough. I start the Call_HelloWorld_WebService.aspx page using <ctrl><f5> and use the default web server that ships with VSE Beta 2.
SBR

Monday, March 12, 2012

Web Services - Unauthorized

I am attempting to create my first web service. I am now stuck at the following error.

Exception Details:System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

I believe I have included the necessary code for assistance. If anything else is needed please let me know and I will reply ASAP.

Test.asmx<%@dotnet.itags.org. WebService Language="VB" CodeBehind="~/App_Code/Test.vb"Class="Test" %>
/App_Code/Test.vbImports System.WebImports System.Web.ServicesImports System.Web.Services.Protocols<WebService( _Namespace:="http://serverName.dev.intranet/")> _Public Class TestInherits System.Web.Services.WebService <WebMethod()> _Public Function PI()As Double Return System.Math.PIEnd Function <WebMethod()> _Public Function HelloWorld()As String Return"Hello World"End FunctionEnd Class
Client.aspx.vb...Sub btn1_Click( _ByVal senderAs Object, _ByVal eAs EventArgs)Dim srvAs New intranet.dev.serverName.Test srv.Credentials = System.Net.CredentialCache.DefaultCredentials lblTest.Text = srv.PIEnd Sub...
 
web.config...<authentication mode="Windows"/><identity impersonate="false"/>...
 
Thank you for your help.

Update -

When I run this on the development server (http://serverName.dev.intranet) it fails. When I run it on my local machine (http://localhost:port/...) it works. I hope that helps pinpoint the problem.

Thank you again for all of your help.


Usually this error means that the client application is not sending any credentials or the credentials are wrong. But I think you are setting the credentials correctly in your btn1_Click event handler. Most likely the permissions on the folder where the web service is located are not properly setup for IUSR_xxx.

Can you provide a description of your serverName.dev.intranet environment? Is it a shared hosting plan? Do you have full access to a dedicated server? etc.


It is an shared hosting environment on a corporate intranet. I do not have full access to the server settings.

You are probably correct about the folder permissions. Without having access to the server how can I get this to work?


If you know a network username andpassword that is guaranteed to have permissions to that folder you can try using aNetworkCredential.

See if the following article helps:How to: Configure an XML Web Service for Windows Authentication


I have attempted the Network Credential option and it also did not work. I have read/write permissions so I assumed my credentials would work but that was incorrect.

I will try it on another server and see if that works.