If it has a plug, it's IT stuff


September 29, 2008  9:31 AM

[TLBAT] Intranet: The administration section

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

In the previous posts I’ve described how to restrict the download of certain software packages by using the group membership in an Active Directory.

As already anticipated the Download Center allows to download software from the closest intranet server (called Distribution Point) butthere’s also a section where we need to define the distribuition points, manage the replication between those, add and configure the software packages and so on.

In the next posts we will be covering all these matters so, as usual, stay tuned!!

September 25, 2008  3:16 PM

[TLBAT] Intranet: request_package.asp

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

In the previous post we have seen the code that stays behind the scenes and that checks if a user is allowed to download the file. But what happens if the user is not allowed to download the requested software?

If you check the ASP code in my previous post you will see that there is a subroutine called RequestPack that accepts two parameters: NEEDED_GROUP and FILE. So whenever a user is not allowed there is an IF/THEN clause that, in case of not allowance to download a file, redirects the user to the RequestPack subroutine.

if Licensed = True then

Call GimmePack(FILE)

else

    Call RequestPack(NEEDED_GROUP, FILE)

End if

What the RequestPack will do is to redirect the user to a page called request_package.asp where he/she will be asked if they want to request access to this package, if yes an email will be sent to the Download Center administrator with all necessary information.

Here is the RequestPack routine, present in the download_special.asp page, that builds the link to the request_package.asp page:

Sub RequestPack(NEEDED_GROUP, FILE)

    Response.Redirect “request_package.asp?UserName=” & UCase(USERID) & “?Group=” & NEEDED_GROUP & “?File=” & FILE & ” ”

End Sub

Hereafter the code for the request_package.asp page, in the next post we will start seeing the Administration part of the Download Center where we can add/remove packages, define site’ subnets, configure the replication between distribution points and so on so….stay tuned!!!

======CODE======

<%

USERID = Request.querystring(“UserName”)

NEEDED_GROUP = Request.querystring(“Group”)

FILE = Request.querystring(“File”)

File1 = Split(FILE,”.”)

%>

<center><hr width=50% color=006699><font face=”Tahoma” color=”#006699″> <% response.write UCase(USERID) %> requests <% response.write UCase(File1(0)) %></center><hr width=50% color=006699>

<!–webbot BOT=”GeneratedScript” PREVIEW=” ” startspan –><script Language=”JavaScript” Type=”text/javascript”><!–

function FrontPage_Form1_Validator(theForm)

{

if (theForm.Confirmation.value == “”)

{

alert(“Please enter a value for the \”Confirmation\” field.”);

theForm.Confirmation.focus();

return (false);

}

if (theForm.Confirmation.value.length < 2)

{

alert(“Please enter at least 2 characters in the \”Confirmation\” field.”);

theForm.Confirmation.focus();

return (false);

}

if (theForm.Confirmation.value.length > 3)

{

alert(“Please enter at most 3 characters in the \”Confirmation\” field.”);

theForm.Confirmation.focus();

return (false);

}

var checkOK = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ”;

var checkStr = theForm.Confirmation.value;

var allValid = true;

var validGroups = true;

for (i = 0; i < checkStr.length; i++)

{

ch = checkStr.charAt(i);

for (j = 0; j < checkOK.length; j++)

if (ch == checkOK.charAt(j))

break;

if (j == checkOK.length)

{

allValid = false;

break;

}

}

if (!allValid)

{

alert(“Please enter only letter characters in the \”Confirmation\” field.”);

theForm.Confirmation.focus();

return (false);

}

return (true);

}

//–></script><!–webbot BOT=”GeneratedScript” endspan –><form method=”GET” action=”request_package.asp” onsubmit=”return FrontPage_Form1_Validator(this)” language=”JavaScript” name=”FrontPage_Form1″>

<p align=”center”><font face=”Tahoma” color=”#006699″>You are going to request the license for the software package <b><% response.write File1(0) %></b> do you confirm the request?</font></p>

<p align=”center”>

<!–webbot bot=”Validation” s-display-name=”Confirmation” s-data-type=”String” b-allow-letters=”TRUE” b-value-required=”TRUE” i-minimum-length=”2″ i-maximum-length=”3″ –><input type=”text” name=”Confirmation” size=”20″ value=”Please type YES or NO” maxlength=”3″></p>

<p align=”center”><input type=”submit” value=”Submit” name=”B1″></p>

</form>

</font>

<%

if Request.querystring(“Confirmation”) = “Please type YES or NO” then

elseif Request.querystring(“Confirmation”) = “YES” then

    Set objEmail = CreateObject(“CDO.Message”)

    objEmail.From = download_center@mydomain.com ‘BE SURE TO CHANGE THIS

    objEmail.To = “dloadcenter_admin@mydomain.com”‘BE SURE TO CHANGE THIS

    objEmail.Subject = “[Download Center 2.0] Package request from: ” & UCase(USERID)

    BodyTxt = “The user ” & UCase(USERID) & ” must be added to ” & NEEDED_GROUP & ” group in order to be allowed to download <b>” & FILE & “</b>” & vcbcrlf

    objEmail.Textbody = BodyTxt & “Please verify with the user’s manager to see if the user is allowed to download this software.”

    objEmail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2

    objEmail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “mail.lamrc.com”

    objEmail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25

    objEmail.Configuration.Fields.Update

    objEmail.Send

Else

    Response.redirect(“default.asp”)

End If

%><head><title>..:: Download Center ::..</title></head>

======END CODE======


September 24, 2008  12:52 PM

[TLBAT] Intranet: an image is worth 1000 words!!

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

Hi folks, I just found out that I had an image of the concept behind the Download Center so I think it’s much better to post it so this can clearly explain how the whole thing works…here it is!

Download Center diagram


September 24, 2008  12:36 PM

[TLBAT] Intranet: the download_special.asp

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

So we’re finally at the “interesting” stuff: the page that checks if a user is allowed or not to download a certain package.

As in previous posts in order to allow a user to download a certain file he/she must be a member of a given group; e.g. we want to restrict the downloads of MySoftware.exe and make this available only to the members of the grp_MySoftware group. We defined then in our database that this file has the following entry:

PackageDesc = “My beautiful software 1.0″

PackageName = “MySoftware.exe”

PackageType = “Special”

NeededGroup = “grp_MySoftware”

The code that you find below will check if the user that is visiting the page is part of the grp_MySoftware group and, if successful, build the download link by redirecting him/her to the closest distribution point. Example http://192.168.xxx.1/files/MySoftware.exe where xxx is the subnet of the client visiting the page.

So now let’s see the code and remember to change the MyDomain = “contoso” to your domain name (E.g. if you have mycompany.com just type mycompany).

The code that follows is self-explanatory so just…read it and check the commented lines!

‘======CODE======

<!– #include file=”adovbs.inc” –>

<%

Session.Timeout=10

Dim NEEDED_GROUP

Dim SOURCE

Dim FILE

Dim MyDomain

‘Dim USERID

FILE = Request.querystring(“file”)

USERID = Request.querystring(“UserName”)

MyDomain = “contoso”

Dim Licensed

Set cnnSearch = Server.CreateObject(“ADODB.Connection”)

cnnSearch.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/downloads.mdb”) & “;”

strSQL2 = “SELECT Packages.NeededGroup FROM Packages WHERE (((Packages.PackageName)='” & FILE & “‘)) GROUP BY Packages.NeededGroup;”

Set rstSearch2 = cnnSearch.Execute(strSQL2)

Do While Not rstSearch2.EOF

   NEEDED_GROUP= rstSearch2.Fields(“NeededGroup”).Value

    rstSearch2.MoveNext

Loop

Call CheckGroup

Sub CheckGroup

Set objDictionary = CreateObject(“Scripting.Dictionary”)

set User = GetObject(“WinNT://” & MyDomain & “/” + USERID)

For Each Prop In User.groups

    if instr(Prop.Name,right(NEEDED_GROUP,3)) > 0 then

        Licensed = True

    end if

Next

End Sub

if Licensed = True then

Call GimmePack(FILE)

else

    Call RequestPack(NEEDED_GROUP, FILE)

End if

‘ *** Get the visitor’s subnet

CLIENT_IP = Request.ServerVariables(“REMOTE_ADDR”)

SUBNET0 = Split(CLIENT_IP,”.”)

‘ *** Check the distribution point for the given subnet

strSQL = “SELECT Sites.Subnet, Sites.Distrib_Point FROM Sites WHERE (((Sites.Subnet)='” & SUBNET0(2) & “‘)) GROUP BY Sites.Subnet, Sites.Distrib_Point;”

Set rstSearch = cnnSearch.Execute(strSQL)

Do While Not rstSearch.EOF

    Session(“SOURCE”) = rstSearch.Fields(“Distrib_Point”).Value

    rstSearch.MoveNext

Loop

‘ *** Create the download link and redirect the by using the REFRESH metatag so the package automatically starts downloading

Sub GimmePack(FILE)

    DOWNLOAD_LINK = Session(“SOURCE”) & FILE

    response.write “<html><head><META http-equiv=’refresh’ content=’3;URL=” & DOWNLOAD_LINK & “‘><title>Download page for ” & FILE & “</title></head><body>”

    response.write “<center><FONT FACE=TAHOMA SIZE=2 COLOR=#006699>You are registered to download <b>” & FILE & “</b></FONT><br>”

    response.write “<FONT FACE=TAHOMA SIZE=2 COLOR=#006699>Your download should start in few seconds, if this doesn’t happen, click <a href=” & DOWNLOAD_LINK & “>HERE</a></b> to download the file</FONT><center>”

    LogHit

End Sub

Sub LogHit

    CLIENT_IP = Request.ServerVariables(“REMOTE_ADDR”)

    Dim DB_CONNECTIONSTRING

    DB_CONNECTIONSTRING = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/hits.mdb”) & “;”

    Dim objRecordset

    Set objRecordset = Server.CreateObject(“ADODB.Recordset”)

    strSQL = “SELECT * FROM downloads;”

    objRecordset.Open strSQL, DB_CONNECTIONSTRING, adOpenKeyset, adLockPessimistic, adCmdText

    objRecordset.AddNew

    objRecordset.Fields(“Package”) = FILE

    objRecordset.Fields(“UserName”) = USERID

    objRecordset.Fields(“IP_ADDR”) = CLIENT_IP

    objRecordset.Fields(“Date”) = Date

    objRecordset.Update

    objRecordset.Close

    Set objRecordset = Nothing

End Sub

Sub RequestPack(NEEDED_GROUP, FILE)

    Response.Redirect “request_package.asp?UserName=” & UCase(USERID) & “?Group=” & NEEDED_GROUP & “?File=” & FILE & ” ”

‘    Session.Abandon

End Sub

%><head><title>..:: Download Center ::..</title></head>

‘======END CODE======


September 17, 2008  3:07 PM

Time won’t leave as I am….

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

…but time won’t take the boy out of this man! (U2 – City of blinding lights)

Some of you probably notices that I’m not updating as frequently as before…oh well…soooooooorry but this new job is sucking taking all of my time in styudying, exams and so on. So pleas ebe patient, I’ll be updating soon with other TLBAT stuff for our Download center…stay tuned!


September 11, 2008  10:13 AM

[TLBAT] Intranet: download.asp

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

In this post we will build the page that downloads the packages that we have defined as: STANDARD, GOODIE or PATCH. These software packages are the ones that are available to all users in our domain so no special need is required except being a user in the domain.

What the page will do is to identify in which IP subnet the user is located and build the download URL relative to his or her site; this will save bandwidth and reduce download times for the users.

The page uses an ASP Server Variable that is used to obtain the client’s IP address and then compare this to our sites’ definition in our database, indeed if we look at the code we will see the: Request.ServerVariables(“REMOTE_ADDR”)
string, this variable is the IP address of the computer that is visiting the page.

As an example let’s consider the IP address 192.168.39.123, in this page we will check the 3rd octet of the IP address and compare it to our database; in this case the “39” part identifies the Italian site located in Milan so the final URL will be “http://iis_ita1/download/free/myfile.exe ” where the myfile.exe is passed by the default.asp page.

The page then will also log the hit for the given file to the hits database; this is done by calling the LogHit subroutine.

The next post will discuss the SPECIAL packages where in order to be allowed to download a given file, the user is required to be member of a given domain group…stay tuned!!

<!– #include file=”adovbs.inc” –>

<%

Dim cnnSearch

Dim rstSearch

Dim strDBPath

Dim strSQL

Dim strSearch

Dim SOURCE

Set cnnSearch = Server.CreateObject(“ADODB.Connection”)

cnnSearch.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/downloads.mdb”) & “;”

FILE = Request.QueryString(“file”)

‘ *** Get the visitor’s subnet

CLIENT_IP = Request.ServerVariables(“REMOTE_ADDR”)

SUBNET0 = Split(CLIENT_IP,”.”)

‘ *** Check the distribution point for the given subnet

strSQL = “SELECT Sites.Subnet, Sites.Distrib_Point FROM Sites WHERE (((Sites.Subnet)='” & SUBNET0(2) & “‘)) GROUP BY Sites.Subnet, Sites.Distrib_Point;”

Set rstSearch = cnnSearch.Execute(strSQL)

Do While Not rstSearch.EOF

    SOURCE = rstSearch.Fields(“Distrib_Point”).Value

    rstSearch.MoveNext

Loop

‘ *** Create the download link and redirect the by using the REFRESH metatag so the package automatically starts downloading

DOWNLOAD_LINK = “http://” & SOURCE & “/download/free/” & FILE

response.write “<html><head><META http-equiv=’refresh’ content=’3;URL=” & DOWNLOAD_LINK & “‘><title>Download page for ” & FILE & “</title></head><body bgcolor=’#B1C9E9′>”

response.write “<br><center><font face=tahoma size=3 color=#006699>Your download should start automatically in 3 seconds.<br> If the download doesn’t start, click <b><a href='” & DOWNLOAD_LINK & “‘ style=’text-decoration:none’> HERE</a></b> to download the file you requested.</center></body></html>”

‘ *** Free up some memory

Set rstSearch = Nothing

Set cnnSearch = Nothing

LogHit

Sub LogHit

    USERID = split(Request.ServerVariables(“LOGON_USER”),”\”)

    Dim DB_CONNECTIONSTRING

    DB_CONNECTIONSTRING = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/hits.mdb”) & “;”

    Dim objRecordset

    Set objRecordset = Server.CreateObject(“ADODB.Recordset”)

    strSQL = “SELECT * FROM downloads;”

    objRecordset.Open strSQL, DB_CONNECTIONSTRING, adOpenKeyset, adLockPessimistic, adCmdText

    objRecordset.AddNew

    objRecordset.Fields(“Package”) = FILE

    objRecordset.Fields(“UserName”) = USERID(1)

    objRecordset.Fields(“IP_ADDR”) = CLIENT_IP

    objRecordset.Fields(“Date”) = Date

    objRecordset.Update

    objRecordset.Close

    Set objRecordset = Nothing

End Sub

%><head><title>..:: EIT Download Center ::..</title></head>


September 10, 2008  3:21 PM

[TLBAT] Intranet : The home page

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

In this post I’ll present the home page and will explain how this works….so let’s play J

First in order to have this working we need a file called adovbs.inc that can be downloaded here, this file contains all instructions for connecting to the database via ADO.The we need to download some images that will be used in the pages, the images are available here. So now go to the directorywhere your site will be hosted (E.g. c:\inetpub\wwwroot) and unzip images in a directory called images. Also create a folder named dbwhere you will save the downloads.mdb file that you created as in my previous post so in the end you will have a folder structure as follows:

c:\inetpub\wwwroot\Download_Center

c:\inetpub\wwwroot\Download_Center\images

c:\inetpub\wwwroot\Download_Center\db

Now we need to create our default.asp page, the code is at the bottom of this post. let’s discuss on this code.

It consists of some basic HTML that uses some internal subroutines to build 4 tables (see screen shot) that contain: the software available to everyone, the software for users in given groups, the patches and the goodies.

In order to dynamically build these tables a subroutine called  DoTD is called, this subroutine accepts an option that specifies whic table must be built; possible values are  STANDARD, SPECIAL,PATCH, GOODIE.

In addition to this procedure there’s also a Counter subroutine that is called by the DoTD and that shows how many times the given package has been downloaded. In order fr this to work you need a hits.mdb file (available here) where the hits will be recorded; remember to save this file in the db directory.

Once you have finished downloading the files described above, create a new default.asp page  with the following code andsave it in the root folder of your website.

For now this is enough, in the next post I’ll describe the download_special.asp file  that is the one that checks if the user visiting the page is allowed to download a certain file or not….stay tuned!!!

‘======================

 <%
Session.Timeout=10
USERID = split(Request.ServerVariables(“LOGON_USER”),”\”)
%>
<title>..:: Download Center ::..</title>
<body bgcolor=”#B1C9E9″>

<div align=”center”>
<center>

<table border=”0″ cellpadding=”0″ cellspacing=”0″ style=”border-collapse: collapse” bordercolor=”#111111″ width=”90%”>
<tr>
<td width=”100%” background=”images/tile_sub.gif”>
<p align=”center”><b><font face=”Tahoma” color=”#006699″ size=”5″>..:: Download Center ::..</font></b></p>
</td>
</tr>
</table>

<center><font color=”#006699″ size=”2″ face=”Tahoma”> <img border=”0″ src=”images/dot.gif”> </font><font size=”2″ face=”Tahoma”>
<a style=”text-decoration: none” title=”Click to see all the packages you have downloaded from this site” href=”MY_downloads.asp”><font color=”#006699″>
Click here to view your Download History</font></a><font color=”#006699″>
<img border=”0″ src=”images/dot.gif”></font></font></center><br>

<table border=”0″ cellspacing=”1″ style=”border-collapse: collapse” bordercolor=”#111111″ width=”90%” id=”AutoNumber2″>
<tr>
<td width=”100%”><font face=”Tahoma” color=”#006699″ size=”2″>By clicking the <b>DOWNLOAD</b> button you are automatically
rerouted to the closest software distribution server. <br>
Please try to avoid
software downloads through RAS.</font></td>
</tr>
</table>
</center>
</div> <table border=0 align=center cellspacing=10>
<tr><td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><b><img border=”0″ src=”images/dot.gif”>
No License Required <img border=”0″ src=”images/dot.gif”></b></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b>
<font size=”2″ color=”#006699″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”>
</font></b><font size=”2″><b>
<font face=Tahoma color=#006699>Download</font></b></font><b><font size=”2″ color=”#006699″ face=”Tahoma”> <img border=”0″ src=”images/dot.gif”></font></b></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b>
<font size=”2″ color=”#006699″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”>
</font></b><font size=”2″><b>
<font face=Tahoma color=#006699>Hits</font></b></font><b><font size=”2″ color=”#006699″ face=”Tahoma”> <img border=”0″ src=”images/dot.gif”></font></b></td></tr>
<%
Which = “Standard”
DoTD
%>
</table>
</td>
<td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><b><img border=”0″ src=”images/dot.gif”>
License Required <img border=”0″ src=”images/dot.gif”></b></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> Download <img border=”0″ src=”images/dot.gif”></font></b></td><td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> Hits <img border=”0″ src=”images/dot.gif”></font></b></td></tr>
<%
Which = “Special”
DoTD
%>
</table>
</td></tr>
<tr><td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> <b>Patches
</b><img border=”0″ src=”images/dot.gif”></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> </font><b>
<font face=Tahoma color=#006699 size=2>Download </font></b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> </font><b>
<font face=Tahoma color=#006699 size=2>Hits </font></b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”></font></td></tr>
<%
Which = “Patch”
DoTD
%>
</table>
</td>
<td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><b><img border=”0″ src=”images/dot.gif”> Goodies <img border=”0″ src=”images/dot.gif”></b></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> Download <img border=”0″ src=”images/dot.gif”></font></b></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”>
Hits <img border=”0″ src=”images/dot.gif”></font></b></td></tr>
<%
Which = “Goodie”
DoTD
%>
</table>
</td></tr>
</table>

<%
Sub DoTD()
Dim cnnSearch
Dim rstSearch
Dim strDBPath
Dim strSQL
Dim strSearch
Set cnnSearch = Server.CreateObject(“ADODB.Connection”)
cnnSearch.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/downloads.mdb”) & “;”
strSQL = “SELECT * FROM Packages WHERE (((Packages.PackageType)='” & WHICH & “‘)) ORDER BY Packages.PackageName;”

Set rstSearch = cnnSearch.Execute(strSQL)
Do While Not rstSearch.EOF
Package = rstSearch.Fields(“PackageDesc”).Value
File =  rstSearch.Fields(“PackageName”).Value

If WHICH = “Special” then
response.write “<tr><td><font face=tahoma color=#006699 size=1><b>” & Package  & “</td><td><a href=download_special.asp?File=” & File & “&UserName=” & USERID(1) & “><img border=0 src=images/downloadnow.gif alt=’This page may take some time to load due to the license checking procedures, please be patient.’></a></td>”
response.write Counter(File) & “</tr>”
rstSearch.MoveNext

ElseIf WHICH = “Patch” then
response.write “<tr><td><font face=tahoma color=#006699 size=1><img src=images/alert.gif> <b>” & Package  & “</td><td><a href=download.asp?File=” & File & “><img  border=0 src=images/downloadnow.gif alt=Please download/apply this Patch asap!></a></td>”
response.write Counter(File) & “</tr>”
rstSearch.MoveNext
Else
response.write “<tr><td><font face=tahoma color=#006699 size=1><b>” & Package  & “</td><td align=center><a href=download.asp?File=” & File & “><img  border=0 src=images/downloadnow.gif alt=’This software is approved by EIT.’></a></td>”
response.write Counter(File) & “</tr>”
rstSearch.MoveNext
End if
Loop

Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End Sub

Function Counter(FILENAME)
Dim cnnSearch
Dim rstSearch
Dim strDBPath
Dim strSQL
Dim strSearch
Set cnnSearch = Server.CreateObject(“ADODB.Connection”)
cnnSearch.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/hits.mdb”) & “;”
strSQL = “SELECT Count(downloads.Package) AS HITS FROM downloads WHERE (((downloads.Package)='” & FILENAME & “‘));”
Set rstSearch = cnnSearch.Execute(strSQL)

Do While Not rstSearch.EOF
response.write “<td align=center><b><font face=tahoma size=1 color=006699>” & rstSearch.Fields(“HITS”).Value & “</font></td>”
rstSearch.MoveNext
Loop

Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End Function

%>

‘======================


August 29, 2008  1:11 PM

[TLBAT] Intranet: The database behind

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

As described in the last post, the Download Center relies on a Microsoft Access database that will be described in this post.

So, first create a new MSAccess database and then create a table called “Packages” like the following:

Packages
ID PackageDesc PackageName PackageType NeededGroup

ID:         Auto increment

PackageDesc:    Contains a short description of the file (E.g. Microsoft FrontPage)

PackageName:    Is the filename, avoid using spaces (E.g. “MSaccess.exe” better than “MS Access.exe”) because this will be used to construct the download link

PackageType:    Can be Special or Standard or Goodie. Standard/Goodie will be available for download to everyone while Special will be only for the users that are members of given groups.

NeededGroup:    In case of Special package the visiting user must be part of this group in order to download the package.

Then create another table called “Sites” as the following:

Sites
Country Subnet Distrib_Point

Country:    Short name of the Country (E.g. ITA=Italy, GER=Germany)

Subnet:        The third octet of the country/site’s IP address range (E.g. ITA= 192.168.39.x)

Distrib_Point:    The web server in the given country (E.g. websrv_ITA)

The first table will handle information on the packages themselves and whether they’re freely accessible or not; the second table instead will be used in order to redirect the user to his/her local web server in order to save bandwidth. This is applicable only in environments in which the IP subnets are correctly set for country level and where in every country or site there is a local IIS web site.

In the next post I’ll be showing you how to build the homepage for this site and the techniques used for it….keep on reading!


August 28, 2008  7:01 AM

[TLBAT] Intranet: The concept behind it

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

In this post I’ll explain how our Download Center will be constructed, how it works and what’s the idea behind it.

The Download Center is a project I developed in the past for a company where I worked for; this project was a part of another part of the project that had two main goals: first I was trying to reduce the overall cost of the IT department in Europe, the second was to improve the relationship the IT Department and the rest of the world, that’s to say The Users!

At that period the IT Dept. wasn’t seen very good because we were spending a lot of money for upgrades, technology changes and so on, this was resulting in a bad consideration of our department versus the users because they just thought “They are spending a lot of money with no real advantage and, above all, I have no visibility on how this budget is spent.”

By creating this project and others I was able to A) reduce IT costs by 20% (reduced telecommunication costs with another project) and B) Give the Users more control on their IT assets, expenses and have them do many things “self-service” resulting for us in a significant decrease of the customer calls and consequentially reducing the workload on the IT staff.

Ok, go ahead now and see why I created this project! The company had a lot or “road-runners” that means that many users were travelling a lot in Europe, Asia, US and most of them had no Administrative privileges at all so we had the need of providing them a tool that allowed to obtain the Company licensed software in the easiest, fastest way possible.

The Download Center is a set of ASP pages that relies on 2 Microsoft Access databases and the Domain users/groups membership to work.

The two databases were called downloads.mdb and hits.mdb (we’ll discuss later their table structure), while the Domain users/groups part was used to check whether the user visiting the page was entitled to download/install the given software. Let’s say: you need Microsoft Frontpage? You must be a member of the “MSFrontPage” security group.

In addition to this feature the Download Center is also capable of redirecting the users to the closes server possible so this also reduce the download times and costs because the road-runners where mainly connected in RAS and VPN from Hotels.

In the next post I’ll discuss more about the databases and the start page…keep on reading!


July 31, 2008  3:34 PM

[TLBAT] Intranet: Enumerate client computer groups and their members

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

So here we are…on the field :)

This is just a soft start, in this page we will create a page that shows the groups on the client computer that is surfing the ASP page and their relative members.

First we need to understand that this will work only in an environment where the security has been correctly set and on the IIS server for the directory where we will store the ASP files, the anonymous authentication has been disabled and the Windows authentication enabled. This must be done otherwise the pages will be run with the IUSR_xxxx account that has no privilege on the computers, if we enable the Windows authentication instead, the pages will be run by the logged on User.

Here is our first ASP page, copy the text below and paste it to your local_groups_members.asp page in the folder for the self service portal and run it.

==================================

<%@ language=”VBSCRIPT” %>

<%

Dim ComputerName

ComputerName = Request.ServerVariables(“REMOTE_HOST”)

%>

<html>

<head>

<meta name=”GENERATOR” content=”SAPIEN Technologies PrimalScript 3.1″>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<title>[<% Response.Write ComputerName %>] Local Groups and their members</title>

</head>

<body>

<%

Set colGroups = GetObject(“WinNT://” & ComputerName & “”)

colGroups.Filter = Array(“group”)

Response.Write “<font face=tahoma size=3>”

Response.Write “Here is the list of the local Groups and their members for computer:<b>” & ComputerName & “</b><br><br>”

Response.Write “<table border=2 bordercolor=#006699>” & VbCrLf

For Each objGroup In colGroups

Response.Write “<tr><td bgcolor=’#006699′><font face=tahoma size=3 color=’white’> <b>” & objGroup.Name & ” </td></tr>” & VbCrLf

For Each objUser in objGroup.Members

Response.Write “<tr><td bgcolor=white><font face=tahoma size=2 color=’#006699′> ” & objUser.Name & ” </td></tr>” & VbCrLf

Next

Next

Response.Write “</table>” & VbCrLf

%>

</body>

</html>

==================================


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: