Solved

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

Posted on 2012-03-28
4
564 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

762 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