1:在域管理服务器上,打开组策略
2:新建一个组策略,名为GetUserInfo
3:打开组策略,用户登入时执处GetuserInfo.vbs脚本在域模式下,记录用户登入计算机数据库
Option Explicit
Dim con
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
userName = objUser.sAMAccountName
displayName = objUser.displayName
telephone = objUser.telephoneNumber
Set WshNetwork = WScript.CreateObject("WScript.Network")
computerName = WshNetwork.ComputerName
serverIP = Wscript.Arguments(0)
serverDB = Wscript.Arguments(1)
serverUSer = Wscript.Arguments(2)
serverPW = Wscript.Arguments(3)
CurrentTime=Year(Now)&"-"&Month(Now)&"-"&day(Now)&" "&Hour(Now)&":"&Minute(Now)&":"&Second(Now)
set con = wscript.CreateObject("ADODB.Connection")
ConStr = "driver={sql server};Server=" + serverIP + ";Database=" + serverDB + ";uid=" + serverUSer + ";pwd=" + serverPW +";"
con.Open ConStr
‘ 删 除在同一终端机上的登入记录,只保留最新登入记录
command = "delete from username where computername = ‘" + computername + "‘ and username = ‘" + userName + "‘"
con.Execute(command)
command = "insert into username (username,computername,logintime,displayName,telephone) values (‘"
command = command + userName + "‘,‘" + computerName + "‘,‘" + CurrentTime + "‘,‘" + displayName + "‘,‘" + telephone + "‘)"
con.Execute(command)
con.Close()
原文地址:https://blog.51cto.com/13804335/2364345