470,849 Members | 1,106 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

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 2492
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ryan Schefke | last post: by
5 posts views Thread by Jim Andersen | last post: by
12 posts views Thread by Chad Crowder | last post: by
3 posts views Thread by Shailesh Humbad | last post: by
1 post views Thread by Duffman | last post: by
1 post views Thread by cpajoe2001 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.