码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-03-17 22:56:10      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:creat   where   脚本   cond   exe   min   work   计算机   exec   

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()

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

标签:creat   where   脚本   cond   exe   min   work   计算机   exec   

原文地址:https://blog.51cto.com/13804335/2364345

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!