码迷,mamicode.com
首页 > 其他好文 > 详细

获取AD域用户登入信息

时间:2020-05-26 09:24:58      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:driver   dom   inf   logo   create   哪些   ldap   delete   nts   

获取AD用户登入信息
详细记录AD域用户登入过哪些终端电脑

1:

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")
ComputerID = WshNetwork.ComputerName

Set objArgs = WScript. Arguments
connStr = "driver={sql server};Server=" + objArgs(0) +";Database="+objArgs(1)+";uid="+objArgs(2)+"pwd="+objArgs(3)+";"

set con = wscript.CreateObject("ADODB.Connection")

con.Open connStr
command = "delete from switch_UserLogin where ComputerID = ‘" ?+ ComputerID + ?"‘ and UserName = ‘" + UserName + "‘"
con.Execute(command)

command = "insert into switch_UserLogin (UserName,displayName,Telephone,ComputerID) values (‘"
command = command + UserName + "‘,‘" + displayName ?+ "‘,‘" ?+ telephone + "‘,‘" + ComputerID +"‘)"

con.Execute(command)

con.Close()

2:脚本运行实例

? ? ?wscript.exe \domainserver\NETLOGON\getUserInfo.vbs ip db user pw

3:通过AD域服务器发布用户登入脚本

??

获取AD域用户登入信息

标签:driver   dom   inf   logo   create   哪些   ldap   delete   nts   

原文地址:https://blog.51cto.com/14825007/2498396

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