• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3126
  • Last Modified:

UrlDownloadToFile returns INET_E_RESOURCE_NOT_FOUND under SYSTEM account and when behind a proxy

Hi experts,

I have a very simple looking C++ code that uses URLDownloadToFile and fails when run from behind proxy and under SYSTEM account. It works fine if I either use direct connection or run under a user account. I am making following call:

URLDownloadToFile(NULL, wszURL, wszFullpath, 0, NULL);

I have a service that runs under SYSTEM credentials. This service launches a program, say, DownloadMyFile.exe that downloads a file using above call. This download works.

Then I connect my machine to proxy and specify the proxy thru IE options. After this URLDownloadToFile starts giving INET_E_RESOURCE_NOT_FOUND  (-2146697211) error.

Now when I double click on DownloadMyFile.exe, which makes it run under user credentials, it successfully works, even from behind proxy.

I tried this on Vista/Win7/XP and found same behavior.

Any clues?

Thanks!
0
VineyKumar
Asked:
VineyKumar
  • 4
  • 2
  • 2
  • +1
1 Solution
 
VineyKumarAuthor Commented:
Guys,

This is a very critical requirement for me. I will highly appreciate early replies.

Thanks,
Viney
0
 
jkrCommented:
our problem is that services running under the 'LocalSystem' account have almost OS privileges, but are not allowed to use _any_ networking facilities. To overcome this, make sure to assign your service to run under a predefined user account (preferrably one belonging to the admin group) which does have network access (this is usually done by specifying an account name&password in the call to 'CreateService()', but you're also able to change this from the 'services' control panel applet).
0
 
DanRollinsCommented:
One possibility...
Tee error ("resource not found") leads me to think that perhaps the Service was unable to locate an identifying Client Certificate.  It would tend to look in the "My" Store of LocalSystem, and not find it.
Check to see if your proxy uses a certificate rather than user/password.  If so, let me know and I'll describe how to get that cert into the LocalSystem cert store.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
George TokasCommented:
jkr is right and allready posted solutions about that...
I had the same problem but didn't solved it because I wanted the application - service - to be with no memory leaks...
By the time I solved the leak problem I didn't had a need for the service application...

George Tokas.
0
 
VineyKumarAuthor Commented:
I tried following and had limited success.
-      Find PID of explorer.exe
-      Get token of logged-in user by calling OpenProcessToken() using above PID
-      Lauch copy of MyDownloadApp.exe calling CreateProcessAsUser() and using logged-on users token.
-      Now MyDownloadApp.exe runs under user credential and can successfully download

This solution is working on XP. But on Win7 it gives error INET_E_SECURITY_PROBLEM (0x800C000EL or -2146697202).

Before I get completely diverted, I will find out more on what DanRollins has suggested.
0
 
jkrCommented:
Have you tried running the service under a different account also?
0
 
VineyKumarAuthor Commented:
Guys, finally I could solve my problem. My earlier post was almost the solution. One additional step that I took is that I tried downloading from a secure site. I changed the URL that was having a valid Verisign cert. That removed  INET_E_SECURITY_PROBLEM (0x800C000EL or -2146697202).
0
 
George TokasCommented:
I think that DanRollins has given a valid answer....

George Tokas.
0
 
VineyKumarAuthor Commented:
The solution given was an excellent lead to the right final solution. I needed to dig out more info. I could find out the final solution and posted here.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now