Solved

Web Service Proxy Authentication

Posted on 2004-03-31
8
913 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 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