473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

401 While Accessing Web Service

Ben
I'm trying to access a c# web service from a web form.

I set up the web reference proxy object as follows:

proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.

my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).

Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).

Thanks!
Jun 27 '08 #1
10 1934
http://www.dotnetbips.com/articles/d...d151103b2.aspx

check this and see..

--
L.W.C. Nirosh
"Ben" <be******@gmail.comwrote in message
news:b5**********************************@m73g2000 hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.

I set up the web reference proxy object as follows:

proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.

my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).

Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).

Thanks!

Jun 27 '08 #2
Ben
On Apr 29, 2:30*pm, "Nirosh" <Nir...@News.Comwrote:
http://www.dotnetbips.com/articles/d...dfb-190d151103...

check this and see..

--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message

news:b5**********************************@m73g2000 hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
* *proxy.PreAuthenticate = true;
* *proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. *If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -

- Show quoted text -
thanks,
anyway to do it without using web form authentication?

the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .
Jun 27 '08 #3
okay, check WSE (Web Service Enhancement) to see how to improve the web
service security..

to avoid the dependacy with integrated authentication, create a new web site
for your web service, that way it should work fine.

--
L.W.C. Nirosh

"Ben" <be******@gmail.comwrote in message
news:69**********************************@b64g2000 hsa.googlegroups.com...
On Apr 29, 2:30 pm, "Nirosh" <Nir...@News.Comwrote:
http://www.dotnetbips.com/articles/d...dfb-190d151103...

check this and see..

--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message

news:b5**********************************@m73g2000 hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -

- Show quoted text -
thanks,
anyway to do it without using web form authentication?

the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .
Jun 27 '08 #4
Ben
On Apr 29, 3:03*pm, "Nirosh" <Nir...@News.Comwrote:
okay, check WSE (Web Service Enhancement) to see how to improve the web
service security..

to avoid the dependacy with integrated authentication, create a new web site
for your web service, that way it should work fine.

--
L.W.C. Nirosh

"Ben" <benm5...@gmail.comwrote in message

news:69**********************************@b64g2000 hsa.googlegroups.com...
On Apr 29, 2:30 pm, "Nirosh" <Nir...@News.Comwrote:


http://www.dotnetbips.com/articles/d...dfb-190d151103...
check this and see..
--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message
news:b5**********************************@m73g2000 hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -
- Show quoted text -

thanks,
anyway to do it without using web form authentication?

the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .- Hide quoted text -

- Show quoted text -
I'm using VS2008... is there WSE for that version? i can only find it
for VS2005?

is this the only way? i made C# web services before that were hosted
on an IIS site with intergrated windows auth, but the client side was C
++ and i was able to pass current nt credentials without a problem....
this is my first attempt where the client side is another c# web page.
Jun 27 '08 #5
I am not sure whether this is the only way.. When you say it worked with C++
and now is not working with aspx/c# web site, that is interesting..

The WSE 3.0 should work fine with framework 3.0/3.5. But if you want it to
work with VSS 2008 IDE then you need to trick it.

e.g.:-
http://devlicio.us/blogs/derik_whitt...2008-hack.aspx
But I din't do this.. so please do it with extra care..

--
L.W.C. Nirosh

"Ben" <be******@gmail.comwrote in message
news:d4**********************************@2g2000hs n.googlegroups.com...
On Apr 29, 3:03 pm, "Nirosh" <Nir...@News.Comwrote:
okay, check WSE (Web Service Enhancement) to see how to improve the web
service security..

to avoid the dependacy with integrated authentication, create a new web
site
for your web service, that way it should work fine.

--
L.W.C. Nirosh

"Ben" <benm5...@gmail.comwrote in message

news:69**********************************@b64g2000 hsa.googlegroups.com...
On Apr 29, 2:30 pm, "Nirosh" <Nir...@News.Comwrote:


http://www.dotnetbips.com/articles/d...dfb-190d151103...
check this and see..
--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message
news:b5**********************************@m73g2000 hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -
- Show quoted text -

thanks,
anyway to do it without using web form authentication?

the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .- Hide quoted text -

- Show quoted text -
I'm using VS2008... is there WSE for that version? i can only find it
for VS2005?

is this the only way? i made C# web services before that were hosted
on an IIS site with intergrated windows auth, but the client side was C
++ and i was able to pass current nt credentials without a problem....
this is my first attempt where the client side is another c# web page.
Jun 27 '08 #6
Ben
On Apr 29, 3:32*pm, "Nirosh" <Nir...@News.Comwrote:
I am not sure whether this is the only way.. When you say it worked with C++
and now is not working with aspx/c# web site, that is interesting..

The WSE 3.0 should work fine with framework 3.0/3.5. But if you want it to
work with VSS 2008 IDE then you need to trick it.

e.g.:-http://devlicio.us/blogs/derik_whittaker/archive/2008/04/03/wse-3-0-s...
But I din't do this.. so please do it with extra care..

--
L.W.C. Nirosh

"Ben" <benm5...@gmail.comwrote in message

news:d4**********************************@2g2000hs n.googlegroups.com...
On Apr 29, 3:03 pm, "Nirosh" <Nir...@News.Comwrote:


okay, check WSE (Web Service Enhancement) to see how to improve the web
service security..
to avoid the dependacy with integrated authentication, create a new web
site
for your web service, that way it should work fine.
--
L.W.C. Nirosh
"Ben" <benm5...@gmail.comwrote in message
news:69**********************************@b64g2000 hsa.googlegroups.com...
On Apr 29, 2:30 pm, "Nirosh" <Nir...@News.Comwrote:
>http://www.dotnetbips.com/articles/d...dfb-190d151103....
check this and see..
--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message
>news:b5**********************************@m73g200 0hsh.googlegroups.com....
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -
- Show quoted text -
thanks,
anyway to do it without using web form authentication?
the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .- Hide quoted text -
- Show quoted text -

I'm using VS2008... is there WSE for that version? i can only find it
for VS2005?

is this the only way? *i made C# web services before that were hosted
on an IIS site with intergrated windows auth, but the client side was C
++ and i was able to pass current nt credentials without a problem....
this is my first attempt where the client side is another c# web page.- Hide quoted text -

- Show quoted text -
I switched the project to VS2005 just to test and enabled WSE 3.0
support -- is there any additional settings i need to change since it
still throws the same error...
Jun 27 '08 #7
You need to get the web service configure into a another web site, then you
can remove the integrated authentication just for that web site.. then your
web service will be vulnerable, so to improve security use the WSE..

just converting the project to 2005 and enable wse won't do any good. as the
webservice is still having integrated security..

--
L.W.C. Nirosh
"Ben" <be******@gmail.comwrote in message
news:48**********************************@k37g2000 hsf.googlegroups.com...
On Apr 29, 3:32 pm, "Nirosh" <Nir...@News.Comwrote:
I am not sure whether this is the only way.. When you say it worked with
C++
and now is not working with aspx/c# web site, that is interesting..

The WSE 3.0 should work fine with framework 3.0/3.5. But if you want it to
work with VSS 2008 IDE then you need to trick it.

e.g.:-http://devlicio.us/blogs/derik_whittaker/archive/2008/04/03/wse-3-0-s...
But I din't do this.. so please do it with extra care..

--
L.W.C. Nirosh

"Ben" <benm5...@gmail.comwrote in message

news:d4**********************************@2g2000hs n.googlegroups.com...
On Apr 29, 3:03 pm, "Nirosh" <Nir...@News.Comwrote:


okay, check WSE (Web Service Enhancement) to see how to improve the web
service security..
to avoid the dependacy with integrated authentication, create a new web
site
for your web service, that way it should work fine.
--
L.W.C. Nirosh
"Ben" <benm5...@gmail.comwrote in message
news:69**********************************@b64g2000 hsa.googlegroups.com...
On Apr 29, 2:30 pm, "Nirosh" <Nir...@News.Comwrote:
>http://www.dotnetbips.com/articles/d...dfb-190d151103...
check this and see..
--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message
>news:b5**********************************@m73g200 0hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the
web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -
- Show quoted text -
thanks,
anyway to do it without using web form authentication?
the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .- Hide quoted text -
- Show quoted text -

I'm using VS2008... is there WSE for that version? i can only find it
for VS2005?

is this the only way? i made C# web services before that were hosted
on an IIS site with intergrated windows auth, but the client side was C
++ and i was able to pass current nt credentials without a problem....
this is my first attempt where the client side is another c# web page.-
Hide quoted text -

- Show quoted text -
I switched the project to VS2005 just to test and enabled WSE 3.0
support -- is there any additional settings i need to change since it
still throws the same error...
Jun 27 '08 #8
Ben
On Apr 29, 4:11*pm, "Nirosh" <Nir...@News.Comwrote:
You need to get the web service configure into a another web site, then you
can remove the integrated authentication just for that web site.. then your
web service will be vulnerable, so to improve security use the WSE..

just converting the project to 2005 and enable wse won't do any good. as the
webservice is still having integrated security..

--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message

news:48**********************************@k37g2000 hsf.googlegroups.com...
On Apr 29, 3:32 pm, "Nirosh" <Nir...@News.Comwrote:


I am not sure whether this is the only way.. When you say it worked with
C++
and now is not working with aspx/c# web site, that is interesting..
The WSE 3.0 should work fine with framework 3.0/3.5. But if you want it to
work with VSS 2008 IDE then you need to trick it.
e.g.:-http://devlicio.us/blogs/derik_whittaker/archive/2008/04/03/wse-3-0-s...
But I din't do this.. so please do it with extra care..
--
L.W.C. Nirosh
"Ben" <benm5...@gmail.comwrote in message
news:d4**********************************@2g2000hs n.googlegroups.com...
On Apr 29, 3:03 pm, "Nirosh" <Nir...@News.Comwrote:
okay, check WSE (Web Service Enhancement) to see how to improve the web
service security..
to avoid the dependacy with integrated authentication, create a new web
site
for your web service, that way it should work fine.
--
L.W.C. Nirosh
"Ben" <benm5...@gmail.comwrote in message
>news:69**********************************@b64g200 0hsa.googlegroups.com....
On Apr 29, 2:30 pm, "Nirosh" <Nir...@News.Comwrote:
http://www.dotnetbips.com/articles/d...dfb-190d151103....
check this and see..
--
L.W.C. Nirosh"Ben" <benm5...@gmail.comwrote in message
news:b5**********************************@m73g2000 hsh.googlegroups.com...
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the
web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -
- Show quoted text -
thanks,
anyway to do it without using web form authentication?
the crazy thing is that if i fire up my web form from Visual Studio it
works just fine and can access the web service, but if i publish it to
another server and try from there I get the 401 (the site i'm
publishing to is using 'intergrated windows auth') .- Hide quoted text-
- Show quoted text -
I'm using VS2008... is there WSE for that version? i can only find it
for VS2005?
is this the only way? i made C# web services before that were hosted
on an IIS site with intergrated windows auth, but the client side was C
++ and i was able to pass current nt credentials without a problem....
this is my first attempt where the client side is another c# web page.-
Hide quoted text -
- Show quoted text -

I switched the project to VS2005 just to test and enabled WSE 3.0
support -- is there any additional settings i need to change since it
still throws the same error...- Hide quoted text -

- Show quoted text -
so are u saying I cannot use integrated security on a WS?

btw, it works fine if my client is a C# windows form (instead of a web
form)... so I think this shows the WS is okay... it's just there's
something i'm missing on the web form to make it work... but
everywhere i read i see they just say to set the Credentials param and
i did that already.
Jun 27 '08 #9
you are hitting the one hop rule with nt creditals. it should work if you hit
the web site locally, but not from another computer.

to do this you have two options:

1) switch to basic, which will give the web server a primary token it can
use to access a second server.
2) switch to kerberos and enable server credentials delegation.
-- bruce (sqlwork.com)
"Ben" wrote:
I'm trying to access a c# web service from a web form.

I set up the web reference proxy object as follows:

proxy.PreAuthenticate = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.

my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).

Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).

Thanks!
Jun 27 '08 #10
Ben
On Apr 29, 5:58*pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
you are hitting the one hop rule with nt creditals. it should work if you hit
the web site locally, but not from another computer.

to do this you have two options:

1) switch to basic, which will give the web server a primary token it can
use to access a second server.
2) switch to kerberos and enable server credentials delegation.

-- bruce (sqlwork.com)

"Ben" wrote:
I'm trying to access a c# web service from a web form.
I set up the web reference proxy object as follows:
* * proxy.PreAuthenticate = true;
* * proxy.Credentials = CredentialCache.DefaultCredentials;
but i get a 401 error. *If I switch the IIS website from Integrated
Windows Auth to Anonymous, it works... but i want it to use windows
security.
my web.config of the web form is set to imperonsate the logged on
user, and i verified that's working by checking that
this.User.Identity.Name is my domain user (which has access to the web
service).
Any ideas what i'm doing wrong? (btw, the web service is SSL if that
makes a difference).
Thanks!- Hide quoted text -

- Show quoted text -
for option 1 it sounds like i'll need to know the user/pwd which i
won't...

option 2 sounds interesting... is this a complicated thing to setup?
i've been trying to search on the issue and haven't found a good
description on how to set it up yet... if anyone has any further info
on it i'd really appreciate it!

Thanks!!!
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Keith E. | last post by:
I have implemented a Web Service on an IIS 5.0 platform using the ASP listener I can access the Web Service just fine from a VB 6 App and classic ASP using the SOAP 3.0 toolkit and its...
4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
1
by: Eirik Brattbakk | last post by:
Hi I have some problems accessing a soap service made in c# using an ATL/MFC client over SSL. I have tried both CSoapMSXMLInetClient and CSoapWininetClient as template arguments with my stub...
3
by: Jim Lewis | last post by:
I have read several things that state accessing a Web Service through a Query String should work. However, when I try to execute http://localhost/webservice1/service1.asmx/HelloWorld I get the...
7
by: David Laub | last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be an integration issue, this may be the better place to posr: I have written a dot net/c# Web Services doesn't fully...
4
by: Khalique | last post by:
I have built a web service whose purpose is to copy files from a secure place to client machine and vice versa. The problem I am having is perhaps related to permissions and access rights. For...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
4
by: Jon | last post by:
I wrote a VS 2005 C# express programme that accesses a web service. It works fine when there's a direct connection to the internet, but on two different PCs with internet access via a proxy, I get...
10
by: Anton | last post by:
Hi, when accessing a secured 3rd party webservice i'm getting a 401 HTTP Statuscode (unauthorized). When entering the url in a browser and entering the username and password manually, the wsdl is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.