Solved

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

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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.   …
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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