首页 > 数据库技术 > 详细

使用组策略记数数据库用户登入终端

时间:2019-03-17 23:06:44      阅读:181      评论:0      收藏:0      [点我收藏+]
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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!