简体   繁体   中英

How can I find whether SQL Server is installed in a system on a network by using the IP address?

How can I check whether SQL Server is installed in a system on a network?

I have to find it using IP address. Is this possible?

How to achieve it in c# code?

In general SQL Server listens on port 1433:

http://support.microsoft.com/kb/287932

so if you find that this port is open there is a good chance (but not certain) that SQL Server is installed on that machine and is accessible.

You can check that this port is open by opening a socket to it: see the Socket class (doc: http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx ) for details.

However, it's also possible to install SQL Server in many other modes where it is not accessible through this port. It's also possible to have this port open (and responsive) from other programs.

It's worth bearing in mind that best practice for securing a server accessible over the Internet would have the SQL Server on a non-standard port, no access to WMI, and (ideally) the server locked down to only open its port to the TCP/IP addresses of known white-listed clients. So in general: there is no way to do this scan that will always work. (Just as well, if you think about it...)

You could try to use WMI.

Here's how to detect if SQL Server is installed using WMI: FAQ: Detecting SQL Server 2005 using WMI (works for 2005, should be easy to adapt for other versions).

To connect to a remote computer using WMI, read this .

Of course WMI must be installed, accessible, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM