Solved

Web Service Proxy Authentication

Posted on 2004-03-31
8
910 Views
Last Modified: 2012-08-14
I am writing a windows forms client that uses a web reference.  I am trying to get my app to work through a proxy server, but I need it to use the user's domain credentials if possible.  So far it will work through the proxy, but fails to authenticate using the domain credentials of the currently logged in user.

I would imagine that I need to get them from some built-in OS source, but I can't find any references on how to do that.

-Javier
0
Comment
Question by:jmvoodoo
  • 6
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
nishikanth earned 500 total points
ID: 10729972

oProxy.Credentials = New NetworkCredential(.HTTPUserName, .HTTPPassword,
.HTTPAddress)

Please enter the correct Domain Name for the account. The better approach
is to always consider CredentialCache class:
oProxy.Credentials = New NetworkCredential(.HTTPUserName, .HTTPPassword,
DomainName)
Dim cache As new CredentialCache
Cache.Add(new Uri(.HTTPAddress), "NTLM" , oProxy.Credentials )
oProxy.Credentials = cache

You can also use the default user credentials for NTLM and Negotiate
authentication:
oProxy.Credentials = CredentialCache.DefaultCredentials


http://www.fawcette.com/vsm/2002_06/online/online_eprods/aspnet_jgoodyear_06_24_02/default_pf.aspx
http://codeproject.com/vb/net/web_service_by_proxy.asp
http://support.microsoft.com/default.aspx?scid=kb;en-us;813834
http://support.microsoft.com/default.aspx?scid=kb;en-us;811318


0
 
LVL 1

Author Comment

by:jmvoodoo
ID: 10734570
I think oProxy.Credentials = CredentialCache.DefaultCredentials is what I was looking for... I will test it today and accept if it works.

Thanks!

-Javier
0
 
LVL 1

Author Comment

by:jmvoodoo
ID: 10737322
Ok, I think I'm getting close, but when I do:

myService.Proxy.Credentials = CredentialCache.DefaultCredentials

I get "reference isn't set to an instance of an object" or something along those lines (i'm sure you've seen the error before, the Proxy member isn't set).   I have my config set to usedefaultproxy, so I thought that the Proxy member would contain the default proxy info, but I guess I was mistaken.  So now the question is how to populate the Proxy member of the webservice proxy with the correct proxy info from the system's default proxy... any ideas?
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 1

Author Comment

by:jmvoodoo
ID: 10737438
I think I may have gotten it.  Using myService.Proxy = WebProxy.GetDefaultProxy, but I can't test it from here.  I'll test again tomorrow morning.
0
 
LVL 1

Author Comment

by:jmvoodoo
ID: 10743754
No dice, still getting the same 407 proxy authentication required.  I am completely baffled at this point.
0
 
LVL 1

Author Comment

by:jmvoodoo
ID: 10753144
Ok, so I did a little bit more research, and rewrote the code so I have:

Dim pr As New WebProxy("isaserver", 8080)
Dim cr As New NetworkCredential("login", "password", "domain")
pr.Credentials = cr
WebService.Proxy = pr
WebService.test()

and I'm still getting the 407 proxy authentication required.  I have checked the ISA server logs and it's recording it as anonymous as if credentials aren't even being passed by .NET, is there something else I need to do in order to actually send the credentials, other than setting the credentials method of the webproxy object?
0
 
LVL 8

Expert Comment

by:nishikanth
ID: 10754302
check out your asp.net permisisons and user login... the above one seems to be fine
0
 
LVL 1

Author Comment

by:jmvoodoo
ID: 10754697
ok, i ran a packet sniffer to figure out what was going on, and it was trying to use digest authentication.  Digest authentication was turned on on the server, so it should have worked.  However, when I forced it to use Basic using credentialcache.add() it worked like a charm.

After I got that working, I went to do a packet sniff on the original code (that uses the credentialcache.defaultcredentials) and it worked perfectly... the packet sniffer revealed that it was using Negotiate authentication.  Any idea what might cause such sporatic behavior?  I really need this to use the stored logon credentials, or I'd just stick with basic auth and leave it at that.

-Javier
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question