TMG 2010 uses a script to import the URL set and the domain name set

Source: Internet
Author: User


As a network manager, I believe there are leaders who ask you to restrict your employees ' access to the Internet, such as restricting access to certain websites. When the number of banned sites is low, adding a URL set or a domain name set is a simple matter, if the number of banned sites up to 1500? If you use the management console of ISA Server again to add, I believe you will only have no words to the extreme. Rest assured that this has been taken into account in ISA Server 2004. With the programming interface it provides, you can easily accomplish this task. You just need to put these domain name set or URL set in a text file, and then other things, you can rest assured that the script to do.


Create an import script


Here is a script that imports the URL set from the "Urls.txt" file into the "URLs" object defined in ISA Server. Copy the following code into a file, and then save as importurls.vbs.

<------------------Start with the line below this one----------------------->

Set Isa = CreateObject ("FPC. Root ")

Set Curarray = Isa.getcontainingarray

Set ruleelements = curarray.ruleelements

Set urlsets = ruleelements.urlsets

Set Urlset = Urlsets.item ("Urls")

Set Filesys = CreateObject ("Scripting.FileSystemObject")

Set urlsfile = Filesys.opentextfile ("urls.txt", 1)

For i = 1 to Urlset.count

Urlset.remove 1

Next

Do While Urlsfile.atendofstream <> True

Urlset.add Urlsfile.readline

Loop

WScript.Echo "Saving ..."

Curarray.save

WScript.Echo "Done"

<------------------End with the line above this one----------------------->

Yellow highlighted items you can replace them according to your own needs.

This line:

Set urlset = Urlsets.item ("Urls")

You can modify URLs for the set of URLs you set up in ISA Server;

This line:

Set urlsfile = Filesys.opentextfile ("urls.txt", 1)

You can change the urls.txt to your URL set text file name.


The following script imports the domain name set from the Domains.txt file into the Domains object in ISA Server, copies the code to a file, and saves it as Importdomains.vbs.

<------------------Start with the line below this one----------------------->

Set Isa = CreateObject ("FPC. Root ")

Set Curarray = Isa.getcontainingarray

Set ruleelements = curarray.ruleelements

Set domainnamesets = ruleelements.domainnamesets

Set Domainnameset = Domainnamesets.item ("Domains")

Set Filesys = CreateObject ("Scripting.FileSystemObject")

Set domainsfile = Filesys.opentextfile ("domains.txt", 1)

For i = 1 to Domainnameset.count

Domainnameset.remove 1

Next

Do While Domainsfile.atendofstream <> True

Domainnameset.add Domainsfile.readline

Loop

WScript.Echo "Saving ..."

Curarray.save

WScript.Echo "Done"

<------------------End with the line above this one----------------------->

Yellow highlighted items you can replace them according to your own needs.

This line:

Set domainnameset = Domainnamesets.item ("Domains")

You can modify the domains for the set of domains that you set up in ISA Server;

This line:

Set domainsfile = Filesys.opentextfile ("domains.txt", 1)

You can put D

using the Import script

Before using the import script, you need to establish the corresponding URL set and the domain name set object in ISA Server.

Follow these steps to establish a URL set named URLs:


    • In the ISA Server Management console, expand Servers, click Firewall Policies ;
    • In the firewall policy, click on the Toolbox on the task panel and click on the Network Object tab;

    • In the Network Objects tab, click New , and then select URL set ;
    • In the new URL Set rule Element dialog box, enter the URLsin the Name text box and click OK ;




    • In this case, the newly established URLsare displayed in the URL set of the network object .




Next we build the domain name set named Domains , and notice that we created the name just to correspond to the name in the script file. Perform the following steps:


    • In the ISA Server Management console, expand Servers, click Firewall Policies ;
    • In the firewall policy, click on the Toolbox on the task panel and click on the Network Object tab;

    • In the Network Objects tab, click New , then select the domain name set ;
    • In the new domain Set rule Element dialog box, enter Domainsin the Name text box and click OK ;




    • In this case, the newly established Domainsis displayed in the domain name set of the network object ;




    • Click Apply in the Firewall Policy Panel to save the Modify and update firewall policy.


Now we need to build two text files urls.txt and domains.txt, which is the default file name used in the script

In this example, thedomains.txt file contains the following:

Stuff.com

Blah.com

Scumware.com

The urls.txt file contains the following content:

Http://www.cisco.com

Http://www.checkpoint.com

Http://www.sonicwall.com

Next, place these two files in the same directory as the two script files, where we copy to the root of the C drive.

Double-click the importurls.vbs file and you will see the following display " Saving..." dialog box, click OK;



Depending on how much you have imported the number of URLs, after a few seconds you will see the following dialog box showing that the import is complete and click OK.



Similarly, double-click importdomains.vbs to finish importing the domain name set from the Domains.txt file.

If the ISA Server console is already open, turn it off again (or click Refresh on the ISA Server Management Console), at which point you can set the network object in the Toolbox You see the imported URL set and the domain name set.





If you already have the same URL or domain name at the time of import, ISA server does not create duplicate entries and retains the original entries.

Omains.txt changes to your URL set text file name.

TMG 2010 uses a script to import the URL set and the domain name set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.