1

In my applications I generally use SQL Instance enumerator to get all the instances of SQL Server. But I've found that running a firewall and/or internet security doesn't allow the application to access the instances. For this, I've to advise the person to turn off the firewall so that it can access the instances which isn't a good idea. I googled but I found some batch file scripts that work for particular Windows version (Windows Server 2008, XP etc).

But I want to know some generic script or method which opens the ports for SQL Server on any machine. How do I resolve the issue?

Muhammad Ali Dildar
  • 1,467
  • 6
  • 24
  • 35
  • I understand the question, and even the potential "need". However, I really think that you should change the architecture of your application instead of asking people to expose their database server. Exposing database servers is very bad practice and there is no way I would install your application if that's the only way it could run. – NotMe Feb 03 '12 at 18:56
  • @ChrisLively- I've mentioned that turning off the firewall (but for short time) isn't a good practice. – Muhammad Ali Dildar Feb 03 '12 at 19:01
  • I think allowing the SQL Server to use resources of your own machine will not expose the database. – Muhammad Ali Dildar Feb 03 '12 at 19:04
  • I was going further. Asking them to open the SQL ports on a firewall is just as bad. If it is purely local then you should be able to just switch from TCP to using named pipes in your connection strings. – NotMe Feb 03 '12 at 20:51

1 Answers1

2

You'll probably find this link, and this one useful (C# code).

Maybe also some powershell scripts would do the trick: here and here

But it's about Windows Firewall only. Keep in mind there are different software firewalls on the market, and most of the time there also is an hardware firewall (sometimes more than one).

Community
  • 1
  • 1
ken2k
  • 48,145
  • 10
  • 116
  • 176