![]() ![]() |
Oct 30 2007, 04:54 PM
Post
#1
|
|
|
INM wizard ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Root Admin Posts: 2,282 Joined: 24-August 04 From: Intellipool AB, Härnösand, Sweden Member No.: 3 |
CODE -----------------------------------------------------------------
-- Name: SQLNewUserDetected.lua -- Author: Kevin Prestage -- Required INM version: 3.3 -- Version: 1.0 -- Date: 2007-09-21 -- Description: This script will check the master database -- for a list of all logins and go into alarm state if there is -- a user set up for the server that was not there in the last -- check. -- -- Arguments: -- 1) Server Name ----------------------------------------------------------------- --grab the parameters servername = GetArgument(0); --create a TLuaDB object and connect to the database. db = TLuaDB(); con = servername .. "@master"; x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER); --set the sql statement to run against the db sql = "select '[' + name + ']' from master..syslogins"; --create variables to store results. result = ""; count = 0; newstring = ""; --get the stored value from the last check. s = TLuaStorage(); i = s:FindItem("syslogins","syslogins"); if (i == nil) then b = s:CreateItem("syslogins","syslogins"); i = s:FindItem("syslogins","syslogins"); end laststring = i.m_pData; if (laststring == nil) then laststring = ""; end print(laststring); --if the db connection succeeded we can now execute our sql statement. if (x == true) then x = db:Execute(sql); --read the results of the statement. if (db:ResultAvilable() == true) then while (db:NextRow() == true) do count = count + 1; current = db:GetCol(1); found = string.find(laststring,current ); if (found == nill) then x = false; result = result .. "User " .. current .. " appears to be new.\n"; end newstring = newstring..current; end end else result = db:GetErrorDescription(); end s:UpdateItem("syslogins","syslogins",newstring,string.len(newstring)); StoreStatisticalData(0,count,0,"Users"); if (result == "") then result = "No New Users Found!"; end SetExitStatus(result, x) -------------------- |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 31st July 2010 - 05:57 PM |