Solved

Web Service Proxy Authentication

Posted on 2004-03-31
8
907 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now