Solved

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

Posted on 2012-03-28
4
547 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
  • 3
4 Comments
 
LVL 5

Expert Comment

by:Apothis
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Correct
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.   …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now