?
Solved

Add SQL Server Port to exceptions in Windows Firewall from vb.net

Posted on 2012-03-28
4
Medium Priority
?
622 Views
Last Modified: 2012-04-02
I'm looking for a way to get the Port number SQL server is running on (if possible)
and then add that port as an exception to the windows firewall for a VB.net application.
0
Comment
Question by:koossa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 5

Expert Comment

by:Apothis
ID: 37776579
SQL Server is a Winsock application that communicates over TCP/IP by using the sockets network library. SQL Server listens for incoming connections on a particular port. The default port for SQL Server is 1433. The port doesn't need to be 1433, but 1433 is the official Internet Assigned Number Authority (IANA) socket number for SQL Server.

Gathered from here:

http://support.microsoft.com

Hope that's what you were looking for.
0
 

Author Comment

by:koossa
ID: 37777517
Hi

I know what the port is, but what I'm looking for is from Visual basic .net, how do I add this port to the firewall's exception list.
In other word, I want to write a piece of code that adds port 1433 to the exception list.
0
 

Accepted Solution

by:
koossa earned 0 total points
ID: 37777636
Ok, I found it:
    Dim objFirewall As Object
    Dim objPolicy As Object
    Dim objPort As Object
    Dim colPorts As Object
    objFirewall = CreateObject("HNetCfg.FwMgr")
    objPolicy = objFirewall.LocalPolicy.CurrentProfile

    objPort = CreateObject("HNetCfg.FwOpenPort")
    objPort.Port = 1433
    objPort.Name = "SQL Server"
    objPort.Enabled = True
    colPorts = objPolicy.GloballyOpenPorts

    Call colPorts.Add(objPort)

Open in new window

0
 

Author Closing Comment

by:koossa
ID: 37795131
Correct
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question