InternetGetConnectedState gets Access denied when running as Local

E

EGON

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
 
D

DailyCoder

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 ) ;
}

________________________
(e-mail address removed)
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL
 
E

EGON

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 said:
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 ) ;
}

________________________
(e-mail address removed)
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL
 
P

Phil Wilson

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 said:
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 said:
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 ) ;
}

________________________
(e-mail address removed)
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL
 
E

EGON

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 said:
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 said:
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 said:
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 ) ;
}

________________________
(e-mail address removed)
http://www.dailycoding.com
DailyCoding.com - daily code for C#, .NET, ASP.NET, SQL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top