voiçi les srcipts : Login
LIMIT_LOGIN_SHARE = "\\testdc\log"
'//
'// Set the event server for log viewer
'//
EventServer = ""
On Error Resume Next
'//
'// Create the SOAP client object
'//
set soapclient = CreateObject("MSSOAP.SoapClient30" )
if err <> 0 then
Wscript.echo "SOAP object creation failed. Have you run the LimitLogin client setup? Here are the details: " + err.description
Wscript.quit
end if
'//
'// Create the TS object
'//
Set wshWTS = CreateObject("WTSApiAx.TSServer" )
if err <> 0 then
Wscript.echo "TS object creation failed. Have you run the LimitLogin client setup? Here are the details: " + err.description
Wscript.quit
end if
'//
'// Create the WSH Shell object
'//
Set WshShell = WScript.CreateObject("WScript.Shell" )
Set WshSysEnv = WshShell.Environment("PROCESS" )
if err <> 0 then
Wscript.echo "WSH Shell Object creation failed. Here are the details: " + err.description
Wscript.quit
end if
Set objNet = WScript.CreateObject("WScript.Network" )
if err <> 0 then
Wscript.echo "Network object creation failed. Here are the details: " + err.description
Wscript.quit
end if
'//
'// init the SOAP xlient object with the WSDL info
'//
Call soapclient.mssoapinit(LIMIT_LOGIN_SHARE & "\LimitLogin.wsdl", "LimitLogin", "" )
if err <> 0 then
Wscript.echo "SOAP initialization failed. Here are the details: " + err.description
Wscript.quit
end if
'//
'// Get the IP Address
'//
set objLocator = WScript.CreateObject("WbemScripting.SWbemLocator" )
set objService = objLocator.ConnectServer
strQuery = "Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE"
set objEnumerator = objService.ExecQuery(strQuery)
for each obj in objEnumerator
if Not IsNull(obj.IPAddress) then
for i=LBound(obj.IPAddress) to UBound(obj.IPAddress)
IPAddr = obj.IPAddress(i)
next
end if
next
'//
'// Get the current computer information
'//
SSID = wshWTS.GetWTSSessionID
CompName = ObjNet.Computername
UserName = ObjNet.UserName
DC = WshSysEnv("LOGONSERVER" )
if EventServer = "" then
EventServer = CompName
end if
'//
'// Call the web service for login verification
'//
loginok = soapclient.VerifyLogin(CompName ,DC, IPAddr, SSID)
Wscript.echo loginok
' NOTE: By default, if the Web Service is not responding (e.g. IIS Server down),
' the user is allowed to log on, regardless of its logins quota information.
' To prevent users from logging on when the Web Service is down, uncomment the following line
' (Important: Uncommenting this line will deny all users from loggin on until the Web Service is functioning)
'If IsNull(loginok) or loginok = "" then WshWTS.LogoffCurrentSession ' DENY LOGON WHEN Web Service is Down
If IsNull(loginok) or loginok = "" then Wscript.Quit ' ALLOW LOGON regardless of quota when Web Service is Down
If loginok <> "1" then
' NOTE: The user exceeded the logins quota. by default, the session logs off immediately.
' If you want to display the list of previously logged-on computers to the user before logging off, please remove the comment mark on the 2 remarked lines below.
' (Note: 10000 means 10 seconds delay before the user is logged off;
' you can modify this number to reflect the number seconds that the list of computers will be displayed to the user before the session is logged off).
'
' ==============BEGINNING OF CODE TO REMOVE REMARK==============
' wshShell.run "lloginsessions " & loginok
' wscript.sleep 10000
' ==============END OF CODE TO REMOVE REMARK==============
'
WshWTS.LogoffCurrentSession
End if