Solved

Web Service Proxy Authentication

Posted on 2004-03-31
8
908 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
3 Use Cases for Connected Systems

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

 
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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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)…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

19 Experts available now in Live!

Get 1:1 Help Now