473,387 Members | 1,504 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,387 software developers and data experts.

C# Ping

Is there a way to do a Ping from C# if you are not logged
in as administrator on W2k?

I am trying to do a Ping from C# running under ASP.NET.

I have found several examples on the web, mostly derived
from Lance Olson's code.

The examples use raw sockets and I get a permissions
error: "An attempt was made to access a socket in a way
forbidden by its access permissions".

The KB article Q195445 indicates that raw sockets can only
be opened by an administrator under W2k and there is no
workaround.

I found a reference to ICMP.DLL, but its use is reported
to be highly discouraged. The examples are C++.

Nov 15 '05 #1
2 10181
Tim,

You don't have to be an administrator to ping another machine in
ASP.NET. However, you do have to be running under an account that has the
appropriate permissions to access the network. By default, ASP.NET runs
under the ASPNET local account, which has no rights to the network. To
change this user, you can change the setting in the web.config file for the
directory where the page resides (the impersonation element, as well as the
identity element), or you can make a specific call to the Impersonate method
on the WindowsIdentity class.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tim C" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Is there a way to do a Ping from C# if you are not logged
in as administrator on W2k?

I am trying to do a Ping from C# running under ASP.NET.

I have found several examples on the web, mostly derived
from Lance Olson's code.

The examples use raw sockets and I get a permissions
error: "An attempt was made to access a socket in a way
forbidden by its access permissions".

The KB article Q195445 indicates that raw sockets can only
be opened by an administrator under W2k and there is no
workaround.

I found a reference to ICMP.DLL, but its use is reported
to be highly discouraged. The examples are C++.

Nov 15 '05 #2
Check out www.mvptools.com. If you like the ping tools, let me know. They
use the ICMP class in the library I will put up their soon. Please provide
feedback. Cheers!

--
William Stacey, MVP

"Tim C" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Is there a way to do a Ping from C# if you are not logged
in as administrator on W2k?

I am trying to do a Ping from C# running under ASP.NET.

I have found several examples on the web, mostly derived
from Lance Olson's code.

The examples use raw sockets and I get a permissions
error: "An attempt was made to access a socket in a way
forbidden by its access permissions".

The KB article Q195445 indicates that raw sockets can only
be opened by an administrator under W2k and there is no
workaround.

I found a reference to ICMP.DLL, but its use is reported
to be highly discouraged. The examples are C++.

Nov 15 '05 #3

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

Similar topics

3
by: Jason Rodman | last post by:
I have downloaded every example on how to create a ping utility in .Net in both VB and C#, but have been disappointed with the results. I have YET to find an example that returns consistent results...
9
by: Mantorok | last post by:
Hi all I want to ping an ipaddress/host to check for a response. Is there any easy way in C#/.Net to do this? Thanks Kev
2
by: Eric Wenger | last post by:
I'm pretty new to C# and I'm trying to do what I believe should be a simple thing. I want to modify a program that is using the System.Net.NetworkInformation.Ping class to have some custom...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
0
by: scotty | last post by:
I need to do a ping scan of a subnet. I can Enum through the IPs and do this, but it takes over 5 minutes as I can only create 1 process at a time. Does anyone know how I can create multiple Ping...
21
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
5
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to...
1
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking...
3
by: imughal | last post by:
I got the perl script which does following task. This solution reads in a line from a text file that is passed in as input parameter 1 to a Perl script. This script will then ping the machine...
6
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.