Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Const ForAppending = 8
Set WSHNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
UserName = WSHNetwork.UserName
ComputerName = WSHNetwork.ComputerName
Set LogInfo = objFSO.OpenTextFile ("LoginTracking.txt", ForAppending)
LogInfo.WriteLine UserName & " logged into computer: " & ComputerName & " at " & Now
LogInfo.Close
'* FileName: LastLogon.vbs
'*=============================================================================
'* Script Name: [LastLogon]
'* Created: [4/06/05]
'* Author: Jesse Hamrick
'* Company: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
'* Email: JHmarick@whokilledkenny.net
'* Web: [URL unfurl="true"]http://www.whokilledkenny.net[/URL]
'* Reqrmnts:
'* Keywords:
'*=============================================================================
'* Purpose: Verifies a users last domain logon time.
'*
'*
'*=============================================================================
'*=============================================================================
'* DECLARE VARIABLES
'*=============================================================================
'* Use sAMAccountName to get user DN
Dim strUser, strSAM, StrDN
'*=============================================================================
'* Code
'*=============================================================================
'* Use sAMAccountName to get user DN
strUser = InputBox("Enter user logon name.")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=yourdomain,dc=com>;" & _
"(&(&(objectCategory=person)(objectClass=user))(sAMAccountName="& strUser & "));" & _
"sAMAccountName, distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
WScript.Echo "The User Account " & Chr(34) & strUser & Chr(34) & _
" does not exits in the Domain"
Else
While Not objRecordset.EOF
strSam = objRecordset.Fields("sAMAccountName")
strDN = "/" & objRecordset.Fields("distinguishedName")
objRecordset.MoveNext
WScript.Echo "Logon Account: " & strSAM
WScript.Echo "AD Object Path: " & StrDN
Wend
End If
objConnection.Close
'End If
'CODE to query all Domain Controllers for last logon.
On Error Resume Next
dtmLatestLogon = #1/1/1601#
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colTimeZone = objWMIService.ExecQuery("Select * From Win32_TimeZone")
For Each objTimeZone In colTimeZone
intTimeZoneBias = objTimeZone.Bias
intDaylightBias = objTimeZone.DaylightBias
Next
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("ConfigurationNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT ADsPath FROM 'LDAP://" & strConfigurationNC & "'WHERE objectClass ='nTDSDSA'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Set objParent = GetObject(GetObject(objRecordSet.Fields("ADsPath")).Parent)
strDCName = objParent.dnsHostName
Set objUser = GetObject("LDAP://" & strDCName & strDN)
Set objLastLogon = objUser.Get("lastlogon")
intLastLogonTime = objLastLogon.HighPart * (2^32) + objLastLogon.LowPart
intLastLogonTime = intLastLogonTime / (60 * 10000000)
intLastLogonTime = intLastLogonTime / 1440
dtmLastLogon = intLastLogonTime + #1/1/1601#
dtmLastLogon = DateAdd("n", intTimeZoneBias, dtmLastLogon)
dtmLastLogon = DateAdd("n", intDaylightBias, dtmLastLogon)
If dtmLastLogon > dtmLatestLogon Then
dtmLatestLogon = dtmLastLogon
WScript.Echo "Last Logon: " & dtmLatestLogon
End If
objRecordSet.MoveNext
Loop
objConnection.Close
'*=============================================================================
'* END OF SCRIPT:
'*=============================================================================