Tags

We use this in a script to record username, computername and IP to a SQL database – call it with appropriate parameters 🙂

The logoff does the same sort of thing but updates the last record for that user/computer pair – I can find the code if you need it 🙂

sub RecordLogon(sUsername,sComputername,sIP)
dim sServer, sConn, oConn,oRS
sServer=”sqlservername”
sConn=”provider=sqloledb;data source=” & sServer & “;initial catalog=logoninfo”
Set oConn = CreateObject(“ADODB.Connection”)
oConn.Open sConn, “username”, “secretpassword”
Set oRS =CreateObject(“ADODB.Recordset”)
sSQL=”insert into logonoff(username,compname,ip,ontime) values(‘” & sUserName & “‘,'” & sComputerName & “‘,'” & sIP & “‘,getdate())”
ors.open sSQL, oconn
end sub

Advertisements