0
我正在解析有关Windows系统上用户帐户更改的日志消息。 我想通知用户有关更改,因此我需要从Active Directory检索其个人 信息(First,Last,E-Mail)。使用VBScript和Active Directory通过SID查找用户电子邮件
我已经找到了一种方法来获取用户名,但是,这只是通过WMI,而不是ADSI:
Function FindUser(Message)
Dim objWMIService
Dim strAccountRegex
Dim objRegex
Dim objMatch
Dim strComputer
Dim objUser
Dim objShell
strAccountRegex = "(\%\{[A-Z,0-9,\-]*\})"
strComputer = "."
Wscript.StdOut.writeLine "Querying WMI to retrieve user-data"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objShell = WScript.CreateObject("WScript.Shell")
Set objRegex = new RegExp
objRegex.Pattern= strAccountRegex
for each objMatch in objRegex.Execute(Message)
REM Wscript.StdOut.writeLine "Found an Account ID: " & objMatch.value
Dim strSID
strSID=NormalizeSID(objMatch.value)
REM Wscript.Echo "SID after escaping: " & strSID
Set objUser = objWMIService.Get _
("Win32_SID.SID='" & strSID & "'")
next
FindUser=objUser.ReferencedDomainName & "\" & objUser.AccountName
End Function
它工作正常,但我想通过Active Directory,而不是通过WMI打算这样做。 你能帮我吗?
我如何得到这个工作?我需要导出Eventlog吗?如果是这样,我怎么让脚本运行通过出口。对不起,我不是程序员。我只是试图将事件中的SID与其用户进行匹配。 – 2010-10-06 08:43:05
我使用这个: http://www.sql-und-xml.de/freeware-tools/index.html#evt-Watch 不幸的是,它是由德国开发人员编写的,但使用谷歌翻译可能是幸运的; - ) – er4z0r 2010-10-22 08:26:08