5

Does the Indy ICMP component require Administrator privileges to ping?

If I run with UAC turned on but without elevated privileges I get an "Access Denied" error message.
Looking at this question it sounds like Indy ICMP uses RAW sockets and thus needs elevated privileges?

I'm developing using Delphi 2007 & Indy 10.x and testing under Windows 7 Pro.

Community
  • 1
  • 1
SteB
  • 1,999
  • 4
  • 32
  • 57

1 Answers1

10

My colleague found this Article states that the Indy ICMP component uses RAW Windows sockets, which under Vista or later requires elevated privileges to run under UAC.

I adapted the program to request UAC elevation and it's now pinging okay.

The alternative would be to call the ICMPSendEcho() and it's related functions directly.

SteB
  • 1,999
  • 4
  • 32
  • 57
  • 2
    If you elevate only for the pings then I would suggest to find alternatives for pinging - think about security. Elevation is desirable only in cases where your program need to do some administrative tasks. ICMP is not such task :) – iPath ツ Nov 28 '12 at 20:35
  • Microsoft circumvents its own security rules to allow its ICMP APIs (ICMPSendEcho) to get through. Using RAW sockets directly always requires admin rights, this it is not Indys fault. See http://stackoverflow.com/a/7691109/80901 – mjn Nov 29 '12 at 08:02
  • @iPath - Agreed, though it was more important to quickly find the cause and fix it (even requiring UAC elevation) than design, implement and test a low-privilege solution - think about the business requirements :) – SteB Nov 30 '12 at 11:10
  • @mjn - didn't mean to blame Indy (it's a fantastic suite of components), though it would be nice if Indy's ICMP wrapped ICMPSendEcho directly and didn't use RAW sockets :) – SteB Nov 30 '12 at 11:19