473,418 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

InternetGetConnectedState gets Access denied when running as Local

nHi!

We have a C# .NET application (exe) that is started by a service (like a
watchdog) and the application is thereby runing as Local System account.

On cetain computers (only a very few of thousands) it seems like the call
InternetGetConnectedState gets FALSE back (even when there is a connection)
and when i check GetLastError it says 5=Access denied, that
InternetGetConnectedState got Access denied and thereby returns false (I
assume).

Summery:
-So it seems like the app gets Access denied when it tries to call
InternetGetConnectedState when app runs as Local System account.
-If we remove the call to InternetGetConnectedState and just go on,
everything works fine. (But we need the check, of course.)
-If we run application as User (not Local system account / service) then
application works.

The problem seem to appeared the latest weeks, but we're not sure.

Any ideas?

Regards
/Marcus

Jun 27 '08 #1
4 2636
Are you using this syntax?

//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int
Description, int ReservedValue ) ;

//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}

________________________
sa@dailycoding.com
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL
Jun 27 '08 #2
Hi!

Thanks for your answer!
Are you using this syntax?
Yes, we do.

It works fine if we run "as user" (start exe manually) but if the exe run as
"Local System" (started by the service / watchdog), it fails.

This only happens on a few computers (aprox ten). We have thousands of
computers where it works and only about ten where it fails.

Regards
/Marcus

"DailyCoder" wrote:
Are you using this syntax?

//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int
Description, int ReservedValue ) ;

//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}

________________________
sa@dailycoding.com
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL
Jun 27 '08 #3
I know the documentation refers to the "system" being connected to the
internet, but it's my experience that some user-specific registry entries
are sometimes used, and the system account won't have them. Are there any
proxy servers involved? The system account will fail attempting to check a
proxy server but a user can be validated.

--
Phil Wilson
Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
"EGON" <EG**@discussions.microsoft.comwrote in message
news:A7**********************************@microsof t.com...
Hi!

Thanks for your answer!
>Are you using this syntax?
Yes, we do.

It works fine if we run "as user" (start exe manually) but if the exe run
as
"Local System" (started by the service / watchdog), it fails.

This only happens on a few computers (aprox ten). We have thousands of
computers where it works and only about ten where it fails.

Regards
/Marcus

"DailyCoder" wrote:
>Are you using this syntax?

//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int
Description, int ReservedValue ) ;

//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}

________________________
sa@dailycoding.com
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL

Jun 27 '08 #4
Hi!

Yes you are right! As we run as Local System we will not get the user-proxy
but a default-proxy. This is solved by group-policies , to set per-client
instead of per-user... which has been done, then there is only one proxy
configuration for the whole client and not one per user. Anyhow, this client
doesn't use proxy so it was/is unnecessary in this case.

So I'm sorry, I don't think this is a proxy problem.

What I think is that the Local System content (service) call to
InternetGetConnectedState is prohibited (Access denied). This shouldn't be
proxy related as it is a call to the Win32 API?

I have read:
http://support.microsoft.com/kb/315035/en-us
but that didn't help. We have a default gateway.

Thanks for your input ... all input is appreciatad!

/Marcus
"Phil Wilson" wrote:
I know the documentation refers to the "system" being connected to the
internet, but it's my experience that some user-specific registry entries
are sometimes used, and the system account won't have them. Are there any
proxy servers involved? The system account will fail attempting to check a
proxy server but a user can be validated.

--
Phil Wilson
Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
"EGON" <EG**@discussions.microsoft.comwrote in message
news:A7**********************************@microsof t.com...
Hi!

Thanks for your answer!
Are you using this syntax?
Yes, we do.

It works fine if we run "as user" (start exe manually) but if the exe run
as
"Local System" (started by the service / watchdog), it fails.

This only happens on a few computers (aprox ten). We have thousands of
computers where it works and only about ten where it fails.

Regards
/Marcus

"DailyCoder" wrote:
Are you using this syntax?

//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int
Description, int ReservedValue ) ;

//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}

________________________
sa@dailycoding.com
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL


Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
5
by: Jim Andersen | last post by:
Hi, I made a DTS-package and it works when I execute it manually, but when it is run by the SQL Server Agent, it fails. I have use the guide to create a maintenance plan. That doesn't work so...
9
by: | last post by:
Hi All, I have allready tried to ask a similar question , but got no answer until now. In the meantime, I found, that I cannot understand some thread-settings for the Main() function . If I use...
12
by: Chad Crowder | last post by:
Hi all, I hope someone can give me a hand, because I'm out of ideas. I keep getting this message: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
1
by: Duffman | last post by:
Hi, I have what seems to be a common problem, but the solutions I've found don't seem to work. I would like to use a web service to create a file at a UNC location in a shared file. Currently...
0
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then, Process.Start throws an Access is Denied Exception. This is with .NET 2.0, of course...
3
by: Simon | last post by:
Hi All, I'm hoping someone will have some words of wisdom for me regarding MS Clustering on Windows 2003. I have a service that runs on a cluster. During invocation it's supposed to...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.