Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about raw sockets

Status
Not open for further replies.

Bobby2001

Programmer
Dec 12, 2002
4
CA
I have an application that uses sockets. At some point It checks whether the certain IP address exists in our network. In order to do that I create raw socket. Here is code segment:

SOCKET sockRaw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
if(sockRaw == INVALID_SOCKET)
{
SetErrorCode(WSAGetLastError());
return FALSE;
}

This works fine as long as user logs in with administrative rights. However if user logs in with user rights only (not administrative) the socket creation failed. This application runs under Windows NT 4.0. According to the following article, this behavior is by design:
support.microsoft.com/default.aspx?scid=KB;en-us;195445&

Having said all that, I noticed however that ping command works just fine from DOS prompt, even though user doesn't have administrative rights. It means that we can find out whether the certain IP address exists in the network or not, even without administrative rights. Here is question:
How can I accomplish the same goal of checking whether the certain IP address exists in the network without using raw sockets? I need solution that will work for the case when user doesn't have administrative rights on Windows NT 4.0. Thanks

 
if this is for internal use only, you could try ImpersonateUser

Matt
 
Could you provide a bit more info. What is it ImpersonateUser? How can I use that? Thanks
 
If the ping works fine why dont you just:

[tt]system("ping IPADDRESS > somefile.txt");[/tt]

and then examine the contents of 'somefile.txt'?
tellis.gif

programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top