ip, mac et description passés en array json

This commit is contained in:
jbousquie 2016-11-24 09:53:39 +01:00
parent 9d93572249
commit c66e63e891

View File

@ -3,7 +3,7 @@ On error resume next
'audit des déconnexions active directory 'audit des déconnexions active directory
'on émet un POST HTTP, sans passer par le proxy, sur le serveur de log des connexions 'on émet un POST HTTP, sans passer par le proxy, sur le serveur de log des connexions
Dim o, n, data, secopt, strComputer, objWMIService, colItems, objItem Dim o, n, data, secopt, strComputer, objWMIService, colItems, objItem
Dim manufacturer, model, systemType, mac, ip, description Dim manufacturer, model, systemType, mac, ip, description, ipItem
Set o = CreateObject("WinHttp.WinHttpRequest.5.1") Set o = CreateObject("WinHttp.WinHttpRequest.5.1")
strComputer = "localhost" strComputer = "localhost"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
@ -18,13 +18,21 @@ next
' collecte mac address ' collecte mac address
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration") Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
mac = "["
ip = "["
description = "["
For Each objItem in colItems For Each objItem in colItems
if Not IsNull(objItem.IPAddress) then if Not IsNull(objItem.IPAddress) then
mac = objItem.MACAddress For Each ipItem in objItem.IPAddress
ip = objItem.IPAddress(0) mac = mac & chr(34) & objItem.MACAddress & chr(34) & ","
description = objItem.Description ip = ip & chr(34) & ipItem & chr(34) & ","
description = description & chr(34) & objItem.Description & chr(34) & ","
next
end if end if
next next
mac = mac & "]"
ip = ip & "]"
description = description & "]"
' emission requête ' emission requête
Set n = CreateObject("wscript.network") Set n = CreateObject("wscript.network")
@ -32,8 +40,8 @@ o.setproxy 1
o.Option(4) = 13056 'pour forcer à ignorer toutes les erreurs de certificats o.Option(4) = 13056 'pour forcer à ignorer toutes les erreurs de certificats
o.open "POST", "https://winlog.iut.local/", False o.open "POST", "https://winlog.iut.local/", False
o.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" o.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
data = "code=HK9!-uu&action=D&username=" + LCase(n.Username) + "&computer=" +n.ComputerName data = "code=HK9!-uu&action=D&username=" & LCase(n.Username) & "&computer=" & n.ComputerName
data = data + "&manufacturer=" + manufacturer + "&model=" + model + "&systemType=" + systemType data = data & "&manufacturer=" & manufacturer & "&model=" & model & "&systemType=" & systemType
data = data + "&mac=" + mac + "&ip=" + ip + "&descr=" + description data = data & "&mac=" & mac & "&ip=" & ip & "&descr=" & description
o.send data o.send data