Custom Mobile Application

Originally, a lack of real-time access for students to their grades and attendance, grew to parent access, and district support access. Which all then grew to internal demands to access the same presentation with advanced filter and sort. That in the spirit of advancement, grew to streamline school process, and promote ease of access.

Student Portal was built on VB/ClassicASP running on a AD Domain Microsoft Internet Information Services server using a Microsoft SQL Server backend configured with SQL Views to a FoxPro DB connector into the student information system database. This enabled transparent authentication on managed assets and an SSL encrypted basic AD authentication catch-all which prompted when transparent authentication failed.

Parent Portal was developed with a locally managed authentication sequence that included parent and student unique information, that was communicated home on Report Cards and parent mailings.

District Portal was developed with a locally managed authentication sequence that included district unique information that was communicated directly with district representatives. As a vocational technical school service over 1000 student from 13 participating districts, connecting district personnel to their part-time students enhanced communication processes, and empowered our partnership.

Internally, faculty and staff preferred the portal presentation of their students grades and attendance, along with the increased filter and sort flexibility that was not available in the student information system itself. This was extended to include real-time access to the accounting data that previously required printed or PDF’s reports to be manually generated in the business office.

Student Portal was enhanced along the way with data visualizations and reports of student internet activity, to provide self awareness and discourage distractions with the detail that is kept and logged. Additional enhancements included custom links to LMS based on student data, fostering transparent authentication. Windows BYOD device support for RDP access to VDI desktops. Classroom Printer Links. Classroom Cast device links.

After years of this portals success, the school transitioned to a new student information system, which was another grand project in itself. But after the transition, the adoration for the now legacy portal remained, and the demands to increase it’s function grew. From photo rosters, to many other student list functions that were comparatively cumbersome in SQL Reporting Server, the portal grew for internal staff. With the advancement in student BYOD from 1:1 initiatives, the portal grew to helping those devices access classroom technology more seamlessly.

It was all written in VB/ASP, and continued to serve the school until long after my departure in 2021.

index.asp

<%
Dim arr2User, arrUser, strCurrentUser, strCurrentDomain, strNTUser

If Right(Left(Request.ServerVariables("LOGON_USER"),11),1) = "\" Then

  arr2User = Split(Request.ServerVariables("LOGON_USER"), "\")
  strCurrentDomain = arr2User(0)
  strCurrentUser = arr2User(1)

elseif Left(Right(Request.ServerVariables("LOGON_USER"),20),1) = "@" or Left(Right(Request.ServerVariables("LOGON_USER"),10),1) = "@" Then

  arrUser = Split(Request.ServerVariables("LOGON_USER"), "@")
  strCurrentDomain = arrUser(1)
  strCurrentUser = arrUser(0)

else

  strCurrentDomain = "Unknown"
  strCurrentUser = "Unknown"

End If

strNTUser = strCurrentUser

If Request.QueryString("CMD") = "Logoff" Then
Session.Abandon
Response.Redirect("/index.asp")
ElseIf Request.QueryString("EULA") <> "true" Then

If Request.QueryString("test") = 1 Then
isTest = 1
End If

dim isAdmin,isInstructor,isStaff,isSSO,homeURL

   hasKeys=Request.Cookies(strNTUser).HasKeys
   isStaff=Request.Cookies(strNTUser)("IsStaff")
   isAdmin=Request.Cookies(strNTUser)("IsAdmin")
   isSSO=Request.Cookies(strNTUser)("IsSSO")
   isInstructor=Request.Cookies(strNTUser)("IsInstructor")
   isTech=Request.Cookies(strNTUser)("IsTech")
   isAide=Request.Cookies(strNTUser)("IsAide")
   isCAEP=Request.Cookies(strNTUser)("IsCAEP")


 If (isInstructor = 1 or isStaff = 1 or isSSO = 1 or isTech = 1 or isAdmin = 1 or isAide = 1 or isTech = 1 or isCAEP = 1) AND NOT IsTest = 1 Then
  homeURL = "/eDesx/Faculty/"
  Response.Redirect(homeURL)
 ElseIf hasKeys = False Then
  Response.Redirect("/login.asp?edesx=1")
 Else

%>

<table width="100%">
 <tr>
  <td width="10%">
  </td>
  <td width="*"><font style="font-family: Arial; font-size: 9pt">
   <h2>Acceptable Use Policy</h2>
   <font style="font-size: 8pt">
   <i>You must accept these terms below.</i><br><br>
   <!--#include file="aup.txt" -->
   </font>
   <center><input type=button onClick="location.href='?eula=true'" value='Accept'>&nbsp;&nbsp;&nbsp;&nbsp;<input type=button onClick="parent.location.href='/'" value='Decline'></center>
  </td>
  <td width="10%">
  </td>
 </tr>
</table>

<%

 End If
Else

  homeURL = "home.html"

strAttributes="samaccountname,physicalDeliveryOfficeName"

Set oRootDSE = GetObject("LDAP://RootDSE")
strNamingContext = oRootDSE.Get("defaultNamingContext")
Set oRootDSE = Nothing

strHomeFolder = Right(strNTUser,LEN(strNTUser)-4)

strPrg = Left(strNTUser,3)
strFilter="samaccountname=" & strNTUser
strADOQuery = "<LDAP://" & strNamingContext & ">;(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)" + strFilter + ");" + strAttributes + ";subtree"

If Request.QueryString("test") = 1 Then

Response.Write Request.ServerVariables("AUTH_USER") & "<br>"
Response.Write Request.ServerVariables("LOGON_USER") & "<br>"
Response.Write Request.ServerVariables("REMOTE_USER") & "<br>"

Response.Write strNTUser & "<br>"
Response.Write strNamingContext & "<br>"
Response.Write strADOQuery

Else


Dim CurrentYear, CurrentTerm
CurrentYear = Year(Now())
If Month(Now()) > 7 Then
CurrentTerm = Right(CStr(CurrentYear),2) & Right(CStr(CurrentYear + 1),2)
Else
CurrentTerm = Right(CStr(CurrentYear - 1),2) & Right(CStr(CurrentYear),2)
End If
CurrentYear = "0910"

' Retrieve Active Directory Values

Dim oConnection 'As ADODB.Connection
Dim oCmd 'As ADODB.Command
Dim oField 'As ADODB.Field
Dim oRootDSE 'As IADs
Dim strNamingContext 'As String
Dim strADOQuery 'As String
Dim strAttributes 'As String
Dim strFilter 'As String

Set oConnection = server.CreateObject("ADODB.Connection")
Set oCmd = server.CreateObject("ADODB.Command")
Set oRecordSet = server.CreateObject("ADODB.Recordset")

If strNTUser <> "" Then

Const ADS_SERVER_BIND = &h0200
oConnection.Provider = "ADsDSOObject"
oConnection.Properties("ADSI Flag") = ADS_SERVER_BIND
oConnection.Open "ADs Provider"
Set oCmd.ActiveConnection = oConnection
set errorObject = CreateObject("ADODB.Error")

oCmd.CommandText = strADOQuery
ocmd.Properties("Sort on")="samaccountname"
ocmd.Properties("Page Size") = 6000

oRecordSet.CursorLocation = 3
Dim strADStatus
oRecordSet.Open oCmd, , 0, 1

While NOT oRecordSet.EOF

Dim arrStuID, strStuID
If oRecordSet("physicalDeliveryOfficeName") <> "" Then
arrStuID = Split(oRecordSet("physicalDeliveryOfficeName"), " : ")
strStuID = arrStuID(0)
Else
strStuID = 0
End If

ORecordSet.MoveNext
Wend

End If

' Retrieve Websense User_ID number

   Set Conn = Server.CreateObject("ADODB.connection")
   Conn.Open "DSN=WSELogs;UID=xxxxxxx;PWD=--------;Database=WSLogV7"
   Set cmdTemp = Server.CreateObject("ADODB.Command")
   Set rs = Server.CreateObject("ADODB.Recordset")


   SQLText="select user_id from dbo.users where user_login_info = '" & Replace(strNTUser,"'","''") & "'"

   cmdTemp.CommandText = SQLText
   cmdTemp.CommandType = 1 'SQL statement
   Set cmdTemp.ActiveConnection = Conn
   rs.CacheSize = 10
   rs.Open cmdTemp,,adOpenStatic

If NOT rs.EOF Then
While NOT rs.EOF
WSEUser = rs("user_id")
rs.MoveNext
Wend
End If

WkOld = Date()
SQLDate = YEAR(WkOld) & _ 
        "-" & Month(WkOld) & _ 
        "-" & DAY(WkOld) 

   Set rsWSL = Server.CreateObject("ADODB.Recordset")


   SQLText="select count(*) from dbo.log_details where user_id = '" & WSEUser & "' AND date_time > '" & SQLDate & "'"

   cmdTemp.CommandText = SQLText
   cmdTemp.CommandType = 1 'SQL statement
   Set cmdTemp.ActiveConnection = Conn
   rsWSL.CacheSize = 10
   rsWSL.Open cmdTemp,,adOpenStatic

If rsWSL.EOF Then
WSLCount = 0
Else
WSLCount = rsWSL(0)
End If

If strPRG = "RCI" Then
homeURL = "eClass.asp"
End If

%>

<script language="javascript">
 
     function FormSubmit(actionurl){ 

      if (actionurl=='webFolders.asp')
      {
        document.edesx.target = "eDesxFrame";
      } else {
        document.edesx.target = "eDesxFrame";
      }      

        document.edesx.action = actionurl ;
	document.edesx.submit();
      } 
</script>

<html>
<head>
<BASE target="eDesxFrame">

</head>
<body>

 <form name="edesx" method="post" action="" target="eDesxFrame">
   <table width="99%" height="99%">
     <tr>
       <td width="180" valign="top">

          <input type="hidden" name="stu_id" value="<%=strStuID%>">

          <input type="hidden" name="ProgCode" value="<%=strPrg%>">

          <input type="hidden" name="TermCode" value="<%=CurrentTerm%>">

          <input type="hidden" name="WSEUser" value="<%=WSEUser%>">

          <!-- #include virtual="/Student Connection/menu.asp" -->
          <!-- #include virtual="/top_menu.asp" -->
          <!-- #include virtual="/eeo.asp" -->

        </td>
        <td width="*">
        <iframe src="<%=homeURL%>" width="100%" height="100%" frameborder="0" name="eDesxFrame" style="border: none"></iframe>
        </td>
        <td width="100" valign="top"><center>

<%
If NOT strPRG = "RCI" Then
%>

          <a href="home.html" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/e-home.gif"></a><br>

          <a onClick="return FormSubmit('report_card.asp')" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/stucard-logo.gif"></a><br>

          <a onClick="return FormSubmit('att.asp')" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/stuatt-logo.gif"></a><br>
<%
End If
%>

          <a onClick="return FormSubmit('eClass.asp')" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/eClass.gif"></a><br>

          <a target="_blank" href="https://eclass.ects.org/highschool/Math/" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/e-Math.gif"></a><br>

          <a target="_blank" href="https://eclass.ects.org/highschool/Literacy/" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/e-Reading.gif"></a><br>

          <a onClick="return FormSubmit('weblogs.asp')" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/web-logs.gif"></a><br>

<%
If NOT strPRG = "RCI" Then
%>

          <a onClick="return FormSubmit('webFolders.asp')" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/e-docs.gif"></a><br>

<%
End If
%>

          <a onClick="return FormSubmit('printers.asp')" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/e-print.gif"></a><br>

          <a target="bottom" href="/edesx/?Cmd=Logoff" onMouseOver="this.style.cursor='hand'"><img width="100" border="0" src="/img/e-logoff.gif"></a>


          <p align="left"><font style="font-face: Arial; font-size: 8pt">Internet Usage Counter: <%=WSLCount%></font></p>

        </center>
       </td>
     </tr>
  <table>
</form>
</body>
</html>

<%

End If
End If
%>

report_card.asp

<%
   On Error Resume Next

   Set Conn = Server.CreateObject("ADODB.connection")
   Conn.Open "DSN=ICWeb;uid=--------;pwd=xxxxxxxxx;database=Admissions"
   Set cmdTemp = Server.CreateObject("ADODB.Command")
   Set rs = Server.CreateObject("ADODB.Recordset")

   lastname=Request.Form("lastname")
   firstname=Request.Form("firstname")
   district=Request.Form("district")
   stu_id=Request.Form("stu_id")
   dob=Request.Form("dob")
   term=Request.Form("termcode")
   isTeacher=Request.Cookies("IsTeacher")


   SQLText="SELECT * FROM IC_ReportCard where studentNumber = " & stu_id

   cmdTemp.CommandText = SQLText
   cmdTemp.CommandType = 1 'SQL statement
   Set cmdTemp.ActiveConnection = Conn
   rs.CacheSize = 10
   rs.Open cmdTemp,,adOpenStatic


%>
<html>
<head>
</head>
<body style="font-family: Arial; font-size: 10px;">
<%

If RS.EOF Then
Response.Write "<center><h1><br><br>"
Response.Write "Student Record not found.  Contact High School Office."
Response.Write "</h1></center>"
Response.Write "There was an issue retrieving your data from the Student database.  This event has been logged to the ECTS Helpdesk."

Else

%>

<table style="background-image: url('/img/ectsbg.gif');" width="100%">
 <tr>
  <td colspan="3" height="20" nowrap>
    <%=rs("Lastname") & ", " & rs("FirstName")%> 
  </td>
  <td colspan="6" align="right" >
    <%=rs("Session") & " Session"%>
  </td>
 </tr>
  <td colspan="4"><font size="-1">
    <b>Program: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><%=rs("prgName")%><br>
    <b>Home School: &nbsp;&nbsp;</b><%=rs("hsName")%><br>
    <b># classes found </b></font>
  </td>
  <td colspan="5"><font size="-1">
    <b>Student-ID: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><%=rs("studentNumber")%><br>
    <b>DOB: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><%=rs("birthdate")%><br>
    <b>PA-ID: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><%=rs("stateID")%></font>
  </td>
 </tr>
 <tr>
  <th colspan="2" align="left" height="20" nowrap>
  <font style="font-weight: b; font-size: 10pt">Course</font>
  </th>
  <th colspan="2" align="left" nowrap>
  <font style="font-weight: b; font-size: 10pt">Description</font>
  </th>
  <th align="left" nowrap>
  <font style="font-weight: b; font-size: 10pt">Term</font>
  </th>
  <th align="left" nowrap>
  <font style="font-weight: b; font-size: 10pt">Quarter</font>
  </th>
  <th align="left" nowrap>
  <font style="font-weight: b; font-size: 10pt">Credit Hours</font>
  </th>
  <th align="right" nowrap>
  <font style="font-weight: b; font-size: 10pt">Posted</font>
  </th>
  <th align="right" nowrap>
  <font style="font-weight: b; font-size: 10pt">Current</font>
  </th>
 </tr>
  

<%

While NOT RS.EOF

  classStyle = "<b>"
  ClassStyleClose = "</b>"



ClassHours = (cInt(rs("Credits")))
ClassGrade = Round(rs("Progress"),3)
ClassPGrade = Round(rs("Grade"),3)

If ClassGrade > 0 Then
GradeSum = ((ClassHours * ClassGrade) + GradeSum)
Credits = (ClassHours + Credits)
Else
ClassGrade="-"
End If

If ClassPGrade > 0 Then
GradePSum = ((ClassHours * ClassPGrade) + GradePSum)
PCredits = (ClassHours + PCredits)
Else
ClassPGrade="-"
End If


	If Left(rs("Term"),4) = term Then

If ClassGrade <> "-" AND Int(RIGHT(rs("Quarter"),1)) = 4 Then
Q4GradeSum = ((ClassHours * ClassGrade) + Q4GradeSum)
Q4Credits = (ClassHours + Q4Credits)
 If ClassPGrade <> "-" Then
 Q4PGradeSum = ((ClassHours * ClassPGrade) + Q4PGradeSum)
 Q4PCredits = (ClassHours + Q4PCredits)
 End If
End If

If ClassGrade <> "-" AND Int(RIGHT(rs("Quarter"),1)) = 3 Then
Q3GradeSum = ((ClassHours * ClassGrade) + Q3GradeSum)
Q3Credits = (ClassHours + Q3Credits)
 If ClassPGrade <> "-" Then
 Q3PGradeSum = ((ClassHours * ClassPGrade) + Q3PGradeSum)
 Q3PCredits = (ClassHours + Q43PCredits)
 End If
End If

If ClassGrade <> "-" AND Int(RIGHT(rs("Quarter"),1)) = 2 Then
Q2GradeSum = ((ClassHours * ClassGrade) + Q2GradeSum)
Q2Credits = (ClassHours + Q2Credits)
 If ClassPGrade <> "-" Then
 Q2PGradeSum = ((ClassHours * ClassPGrade) + Q2PGradeSum)
 Q2PCredits = (ClassHours + Q2PCredits)
 End If
End If

If ClassGrade <> "-" AND Int(RIGHT(rs("Quarter"),1)) = 1 Then
Q1GradeSum = ((ClassHours * ClassGrade) + Q1GradeSum)
Q1Credits = (ClassHours + Q1Credits)
 If ClassPGrade <> "-" Then
 Q1PGradeSum = ((ClassHours * ClassPGrade) + Q1PGradeSum)
 Q1PCredits = (ClassHours + Q1PCredits)
 End If
End If

	End If

%>

 <tr>
  <td nowrap height="20">
  </td>
  <td nowrap>
    <a href=classdetail.asp?>
    <%=ClassStyle & rs("Number") & ClassStyleEnd%></a>
  </td>
  <td nowrap>
    <%=ClassStyle & rs("Name") & ClassStyleEnd%>
  </td>
  <td>
  <td nowrap>
     <%=ClassStyle & rs("Term") & ClassStyleEnd%>
  <td nowrap>
     &nbsp;&nbsp;&nbsp;&nbsp;
     <%=ClassStyle & Int(Right(rs("Quarter"),1)) & ClassStyleEnd%>
  </td>
  <td align="left" nowrap>
    <%=ClassStyle & rs("Credits") & "<font style='font-size: 9px;'> Hrs</font>" & ClassStyleEnd%>&nbsp;&nbsp;
  </td>
  <td align="right" nowrap>
    <%=ClassStyle & Round(rs("Grade")) & ClassStyleEnd%>
  </td>
  <td align="right" nowrap>
    <%=ClassStyle & Round(rs("Progress")) & ClassStyleEnd%>
  </td>
 </tr>

<%
RS.MoveNext
Wend

' Perform Cleanup

rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing 

If Q1GradeSum Then
Q1Average = Round(Q1GradeSum / Q1Credits)
Else
Q1Average = "n/a"
End If
If Q2GradeSum Then
Q2Average = Round(Q2GradeSum / Q2Credits)
Else
Q2Average="n/a"
End If
If Q3GradeSum Then
Q3Average = Round(Q3GradeSum / Q3Credits)
Else
Q3Average="n/a"
End If
If Q4GradeSum Then
Q4Average = Round(Q4GradeSum / Q4Credits)
Else
Q4Average="n/a"
End If

If Q1GradeSum Then
StudentAverage = Round(GradeSum / Credits)
Else
StudentAverage = "N/A"
End If

If Q1PGradeSum Then
Q1PAverage = Round(Q1PGradeSum / Q1Credits)
Else
Q1PAverage = "n/a"
End If
If Q2PGradeSum Then
Q2PAverage = Round(Q2PGradeSum / Q2Credits)
Else
Q2PAverage="n/a"
End If
If Q3PGradeSum Then
Q3PAverage = Round(Q3PGradeSum / Q3Credits)
Else
Q3PAverage="n/a"
End If
If Q4PGradeSum Then
Q4PAverage = Round(Q4PGradeSum / Q4Credits)
Else
Q4PAverage="n/a"
End If

If Q1PGradeSum Then
StudentPAverage = Round(GradePSum / PCredits)
Else
StudentPAverage = "N/A"
End If


%>
 <tr>
 <td colspan="9" height="80">
 </td>
 </tr>
 <tr>
  <td colspan="5" height="80">
  </td>
  <td colspan="2" align="right">
  <b>Q1 Grade:</b><br>
  <b>Q2 Grade:</b><br>
  <b>Q3 Grade:</b><br>
  <b>Q4 Grade:</b><br>
  <font style="font-size: 20px;"><b><%=term%> Grade:</b></font>
  </td>
  <td align="right">
    <b><%=Q1PAverage%></b><br>
    <b><%=Q2PAverage%></b><br>
    <b><%=Q3PAverage%></b><br>
    <b><%=Q4PAverage%></b><br>
    <font style="font-size: 20px;"><b><%=StudentPAverage%></b></font>
  </td>
  <td align="right">
    <b><%=Q1Average%></b><br>
    <b><%=Q2Average%></b><br>
    <b><%=Q3Average%></b><br>
    <b><%=Q4Average%></b><br>
    <font style="font-size: 20px;"><b><%=StudentAverage%></b></font>
  </td>
 </tr>
 <tr>
  <td colspan="8">
  </td>
 </tr>

</table>
<%
End If

%>
</body>
</html>

login.asp

<%
Option Explicit

Dim strDestination, strSQL
Dim oRoot, oDomain, fqDomain, arrUser, strCurrentDomain, strCurrentUser, objRecordSet
Dim objADUser, strGroup, objGroupList
Dim adoCommand, adoConnection, strBase, strAttributes

strDestination = "main.asp"
strSQL = "none"

Dim arr2User

If Right(Left(Request.ServerVariables("LOGON_USER"),11),1) = "\" Then

  arr2User = Split(Request.ServerVariables("LOGON_USER"), "\")
  strCurrentDomain = arr2User(0)
  strCurrentUser = arr2User(1)

elseif Left(Right(Request.ServerVariables("LOGON_USER"),20),1) = "@" or Left(Right(Request.ServerVariables("LOGON_USER"),10),1) = "@" Then

  arrUser = Split(Request.ServerVariables("LOGON_USER"), "@")
  strCurrentDomain = arrUser(1)
  strCurrentUser = arrUser(0)

else

  strCurrentDomain = "Unknown"
  strCurrentUser = "Unknown"

End If

If Request.QueryString("test") = 1 Then

Response.Write "<html>"
Response.Write "<head>"
Response.Write "<title>Erie County Technical School </title>"
Response.Write "</head>"
Response.Write "<body>"
Response.Write "<br><br><br>"
Response.Write "This page is used only to setup server data, you will be redirected.  If the page does not redirect <a href='main.asp'> please click here.</a>"
Response.Write "<br><br><br>"


End If


set objADUser = GetObject("LDAP://" & findDN)

Response.Write "User " & strCurrentUser & "<br><br>"
' Create Cookie
Response.Cookies(strCurrentUser).Domain = Request.ServerVariables("SERVER_NAME")
Response.Cookies(strCurrentUser).Path = "/"
Response.Cookies(strCurrentUser).Expires = Date + 7

' Test for group membership.
strGroup = "Students --- Highschool"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsStudent") = 1
    strDestination = "/edesx/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "All Highschool Users"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsStaff") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Withdrawal Users"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsGuid") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "RCTC Members"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsRCTC") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Secretaries"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsAssistant") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Student Services Users"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsSSO") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Technology Staff"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsTech") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Facilities Staff"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsMaintenance") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Highschool Instructors"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsInstructor") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Student Support Aides"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsAide") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Administrative Staff"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsAdmin") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Alternative Education Staff"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsCaep") = 1
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Helpdesk Users"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    strDestination = "/HelpDesk/"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Math Teachers"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("PRG") = "Math"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "Reading Teachers"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("PRG") = "Reading"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = "District Staff Users"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("IsDistrict") = 1
    strDestination = "/DistrictPortal2/index2.asp"
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

Dim i, prgs(20)
prgs(0)="ADS"
prgs(1)="AUR"
prgs(2)="AUT"
prgs(3)="CMP"
prgs(4)="CNT"
prgs(5)="COS"
prgs(6)="CUA"
prgs(7)="DDE"
prgs(8)="ECE"
prgs(9)="ELC"
prgs(10)="EET"
prgs(11)="FMT"
prgs(12)="GRA"
prgs(13)="HEA"
prgs(14)="MTF"
prgs(15)="CMN"
prgs(16)="PMT"
prgs(17)="THM"
prgs(18)="RCI"
prgs(19)="TRC"

For Each i in prgs

strGroup = i & " PM --- Teachers"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("PRG") = Cstr(i)
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

strGroup = i & " AM --- Teachers"
If (IsMember(objADUser, strGroup) = True) Then
    Response.Write " is a member of group " & strGroup & "<br>"
    Response.Cookies(strCurrentUser)("PRG") = Cstr(i)
Else
    Response.Write " is NOT a member of group " & strGroup & "<br>"
End If

Next


' Clean up.
If (IsObject(adoConnection) = True) Then
    adoConnection.Close
    Set adoCommand = Nothing
    Set adoConnection = Nothing
    Set objGroupList = Nothing
End If
Set objADUser =  Nothing

Dim strReferral
If Request.QueryString("eDesx") = 1 Then
strDestination = "/eDesx/"
End If


If NOT Request.QueryString("test") = 1 Then

  If Request.QueryString("mobile") = 1 Then
   Response.Redirect "/edesx/report_card.asp"
  Else
   Response.Redirect strDestination
  End If
Else
  Response.Write "<br>" & chr(34) & strSQL & chr(34) & "<br>"
  Response.Write "<a href='/eDesx/showCookies.asp'>Show Cookies</a>"
End If


Function IsMember(ByVal objADObject, ByVal strGroupNTName)
    ' Function to test for group membership.
    ' objADObject is a user or computer object.
    ' strGroupNTName is the NT name (sAMAccountName) of the group to test.
    ' objGroupList is a dictionary object, with global scope.
    ' Returns True if the user or computer is a member of the group.
    ' Subroutine LoadGroups is called once for each different objADObject.

    Dim objRootDSE, strDNSDomain

    ' The first time IsMember is called, setup the dictionary object
    ' and objects required for ADO.
    If (IsEmpty(objGroupList) = True) Then
        Set objGroupList = CreateObject("Scripting.Dictionary")
        objGroupList.CompareMode = vbTextCompare

        Set adoCommand = CreateObject("ADODB.Command")
        Set adoConnection = CreateObject("ADODB.Connection")
        adoConnection.Provider = "ADsDSOObject"
        adoConnection.Open "Active Directory Provider"
        adoCommand.ActiveConnection = adoConnection

        Set objRootDSE = GetObject("LDAP://RootDSE")
        strDNSDomain = objRootDSE.Get("defaultNamingContext")

        adoCommand.Properties("Page Size") = 100
        adoCommand.Properties("Timeout") = 30
        adoCommand.Properties("Cache Results") = False

        ' Search entire domain.
        strBase = "<LDAP://" & strDNSDomain & ">"
        ' Retrieve NT name of each group.
        strAttributes = "sAMAccountName"

        ' Load group memberships for this user or computer into dictionary
        ' object.
        Call LoadGroups(objADObject)
        Set objRootDSE = Nothing
    End If
    If (objGroupList.Exists(objADObject.sAMAccountName & "\") = False) Then
        ' Dictionary object established, but group memberships for this
        ' user or computer must be added.
        Call LoadGroups(objADObject)
    End If
    ' Return True if this user or computer is a member of the group.
    IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
        & strGroupNTName)
End Function

Sub LoadGroups(ByVal objADObject)
    ' Subroutine to populate dictionary object with group memberships.
    ' objGroupList is a dictionary object, with global scope. It keeps track
    ' of group memberships for each user or computer separately. ADO is used
    ' to retrieve the name of the group corresponding to each objectSid in
    ' the tokenGroup array. Based on an idea by Joe Kaplan.

    Dim arrbytGroups, k, strFilter, adoRecordset, strGroupName, strQuery

    ' Add user name to dictionary object, so LoadGroups need only be
    ' called once for each user or computer.
    objGroupList.Add objADObject.sAMAccountName & "\", True

    ' Retrieve tokenGroups array, a calculated attribute.
    objADObject.GetInfoEx Array("tokenGroups"), 0
    arrbytGroups = objADObject.Get("tokenGroups")

    ' Create a filter to search for groups with objectSid equal to each
    ' value in tokenGroups array.
    strFilter = "(|"
    If (TypeName(arrbytGroups) = "Byte()") Then
        ' tokenGroups has one entry.
        strFilter = strFilter & "(objectSid=" _
            & OctetToHexStr(arrbytGroups) & ")"
    ElseIf (UBound(arrbytGroups) > -1) Then
        ' TokenGroups is an array of two or more objectSid's.
        For k = 0 To UBound(arrbytGroups)
            strFilter = strFilter & "(objectSid=" _
                & OctetToHexStr(arrbytGroups(k)) & ")"
        Next
    Else
        ' tokenGroups has no objectSid's.
        Exit Sub
    End If
    strFilter = strFilter & ")"

    ' Use ADO to search for groups whose objectSid matches any of the
    ' tokenGroups values for this user or computer.
    strQuery = strBase & ";" & strFilter & ";" _
        & strAttributes & ";subtree"
    adoCommand.CommandText = strQuery
    Set adoRecordset = adoCommand.Execute

    ' Enumerate groups and add NT name to dictionary object.
    Do Until adoRecordset.EOF
        strGroupName = adoRecordset.Fields("sAMAccountName").Value
        objGroupList.Add objADObject.sAMAccountName & "\" _
            & strGroupName, True
        adoRecordset.MoveNext
    Loop
    adoRecordset.Close

    Set adoRecordset = Nothing
End Sub

Function OctetToHexStr(ByVal arrbytOctet)
    ' Function to convert OctetString (byte array) to Hex string,
    ' with bytes delimited by \ for an ADO filter.

    Dim k
    OctetToHexStr = ""
    For k = 1 To Lenb(arrbytOctet)
        OctetToHexStr = OctetToHexStr & "\" _
            & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
    Next
End Function

'obtained from: http://www.cb-net.co.uk/index.php?option=com_content&view=article&id=31:vbscript-find-user-group-memberships-nested-roups&catid=10:vbscript&Itemid=8
 'Funtion to find DistinguishedName of User Object using sAMAccountName

Function findDN

  Set adoConnection = CreateObject("ADODB.Connection")
  adoConnection.Open "Provider=ADsDSOObject;"

  Set adoCommand = CreateObject("ADODB.Command")
  adoCommand.ActiveConnection = adoConnection
  
  Set oRoot = GetObject("LDAP://rootDSE")
  Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))
  fqDomain = oRoot.Get("defaultNamingContext")

  strSQL = "<LDAP://" & fqDomain & ">;(&(objectCategory=" & "User" & ")" & _
   "(samAccountName=" & strCurrentUser & "));samAccountName,distinguishedName;subtree"
 
  adoCommand.CommandText = strSQL

   Set objRecordSet = adoCommand.Execute

   If objRecordset.RecordCount = 0 Then
     Response.End
   Else
     findDN = objRecordSet.Fields("distinguishedName").Value
     adoConnection.Close
   End If
End Function

%>
</body>
</html>