/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Get LAN Server Information. GETINFO v1.30 */ /* Written and modified by Steven Grim. Last date: 05 Mar 99 */ /* Email address: reaper@mindspring.com (Personal) */ /* */ /* Run GETINFO without parameters, for a LONG list of options. You might */ /* want to sent it to a file or printer. I didn't have an easy way of */ /* displaying the help screen. I use MODE CO80,100 for my OS/2 windows and */ /* this is perfect for this utility. Contact me if you need further info. */ /* */ /* This utility works for me. You may find some use for it. Or you can */ /* borrow the code for your own REXX programs/utilities. */ /* */ /* Thanks for looking at this utility. */ /* */ /* Program requirements: LSRXUT.DLL - LAN Server REXX Utility DLL */ /* RXUTILS.DLL - REXX Utilities DLL */ /* OS2PING.EXE - IBM OS/2 DLC/NETBIOS Ping Program */ /* (If you want/need to ping 4033's.) */ /* */ /* Also, you need to have an ADMINISTRATOR UserID and */ /* be logged on for this utility to work properly. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Disclamer: */ /* */ /* This product is provided to you "AS IS", without warranty of any kind. */ /* In no way, shall I be liable for any damages arising out of your use */ /* of this program. */ /* */ /* This program is freeware, it can be used and distributed freely. */ /* There are no fee or payment required. And do not hesitate to send me */ /* any comments that you may have about the program. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* NOTE: */ /* This utility was writted for the OS/2 servers at XXXX and their naming */ /* convention. You may need to make some changes, if your naming convention */ /* is different. Generally, it should work for you. But YMMV. :{)> */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* History */ /* */ /* v1.30 Added code to display open files, when you select specific */ /* 05 Mar shares. Then I added the parameter /CLOSE, so you can close */ /* 1999 the open files for that share. This is handy when you need to */ /* stop a share and users have open files. Tested and it works. */ /* */ /* v1.29 Added a small section of code, so that if you select a print */ /* 03 Mar queue to look at, the new section will display the total number */ /* 1999 of print jobs spooled, since the start or boot date. */ /* */ /* v1.28 Added a module to locate and display the open files on a server. */ /* 10 Feb Looks pretty good. I set it so if the numl_locks on the file */ /* 1999 are greater than 0, then it is displayed in red. It works. */ /* I also added a module to find and display active sessions on a */ /* server. Looks good. */ /* */ /* v1.27 Added a module to locate and display the User Groups on a */ /* 09 Feb domain. It is also sorted alphabetically. */ /* 1999 Also added a module to locate and display the userID's that are */ /* logged onto a server. It uses /LOGON parameter. */ /* */ /* v1.26 Added a module of code to locate and display info about the */ /* 08 Feb server services that are running on a particular server. It */ /* 1999 uses the commandline arg /SERVICES. */ /* */ /* v1.25 Added new code to figure out the Domain Name, that the selected */ /* 04 Feb server resides in. I initially used the NETSERVERMODALS, but */ /* 1999 the WORKSTATIONINFO actually lists out the Domain Name, and not */ /* the Domain Controller server. It works. */ /* */ /* v1.24 Added code for 2 new functions: (1) /USERS parameter to list the */ /* 25 Nov UserID's in a domain, and (2) /NUM to just give the number of */ /* 1998 UserID's in a domain. */ /* */ /* v1.23 Added code to do (1) hightlight all non-OS/2 print servers in */ /* 11 Sep red, and (2) count the number of OS/2 and NT print servers and */ /* 1998 display the totals at the end, with the total counts. Then I */ /* added additional code that searched for retired print servers */ /* and showed them as Yellow, with a "Server Retired" entry at the */ /* end of the line. Tweaked the code on 14 September to not change */ /* the color of the SSTAF and SCLMS server entries. Looks good. */ /* */ /* v1.22 Add a module that will search a domain for UserID accounts that */ /* 03 Sep have changed or are inactive. You add /INACTIVE with a server */ /* 1998 name and it will access all user accounts and locate the ones */ /* that are inactive, count them and display them. */ /* */ /* v1.21 Cleaned up the code, a bit, and moved some of the code into */ /* 01 Sep modules, for easier troubleshooting and reading. Looks a little */ /* 1998 better. May move more of the code into other modules, which will */ /* make it easier to use that code later, in a different program. */ /* */ /* v1.20 Added code to search for printer aliases in the selected domain. */ /* 27 Aug If you put in any server in that domain, the program will still */ /* 1998 search that domain only. The parameter is /PRINT. It will list */ /* the printer name, the server it points to (highlights in red, if */ /* it is not an OS/2 Print Server), and the printer remark. */ /* */ /* v1.19 Added code to search for Aliases, along with the shares, when */ /* 18 Aug you enter the name of a server by itself. Also, changed share */ /* 1998 and alias listings to be 4 across, instead of 2 across. */ /* */ /* v1.18 Added code to allow the /DIR parameter to search the drive, */ /* 17 Aug even when the share has been stopped/deleted. Now, it checks */ /* 1998 the ALIASINFO.TYPE for Files, and then it will start the count. */ /* */ /* v1.17 Added code to check total directory size, if the share is a */ /* 12 Aug Disk Drive. Uses commandline parameter /DIR. See help. Also */ /* 1998 added /PING to initiate the OS2PING of a 4033. */ /* */ /* v1.16 Added code to include the print drivers associated with the */ /* the print queue. Dick Luett would like this. */ /* */ /* v1.15 Starting maintaining the history of changes. v1.15 is a starting */ /* point for version numbers. :{)> */ /* */ /* Before Made lots of small changes, as the program grew. Not sure # of */ /* changes it was. Using 15, for version 1.15, as a starting point. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* This program will check for input, and then it displays Share, Alias, */ /* Print Queue, and Net Access information. It also has an option of pinging */ /* an 4033 with OS2PING. See help for more information. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ PingTest = '' ARG srvr shareIn pingTest /* Setup program. */ CALL COLORINIT CALL INIT IF SRVR = '' | SRVR = '?' | SRVR = '/?' THEN SIGNAL help SrvName = '\\'|| srvr testFile = srvName || '\c$\os2' CALL ServerTest CALL Domain /* MAIN */ /*************************************************************************/ /* This sections checks to see if only a server name and a */ /* parameter are the only entries. It will then display all the info */ /* according to the parameter. The program exits after it completes */ /* each section. */ /*************************************************************************/ if shareIn = '/ALL' | shareIn = '/SERVERS' then call FindServers if shareIn = '/PRINT' then call FindPrinters if shareIn = '/INACTIVE' then call FindInactives if shareIn = '/NUM' then call FindNumUsers if shareIn = '/USERS' then call FindUsers if shareIn = '/SERVICES' then call FindServices if shareIn = '/SESSIONS' then call FindSessions if shareIn = '/LOGON' then call FindLogon if shareIn = '/GROUP' then call FindGroup if shareIn = '/FILES' then call FindFiles if shareIn = '' then call FindSharesAliases NUMERIC DIGITS 15 /* Locates and displays the share info. */ /* Also, displays the users connected. */ say hgreen || Copies('*',75) hcyan myRc = NetGetInfo(NETSHARE, 'shareInfo', SrvName, ShareIn) if myRc <> '0' then DO if pos('2310', myRC) then say '1B'x || '[33;40m'"No Share found" ELSE say '1B'x || '[33;40m''Error from NetGetInfo(NetShare) ' myRc END /* DO */ ELSE DO say 'Network Name =' shareInfo.netname say 'Share Type =' shareInfo.type say 'Share Path =' shareInfo.path say 'Share Remark =' shareInfo.remark /* Check for number of users connected. If ZERO, then leave as is. If */ /* greater than ZERO, then format the display and color the userID's */ /* white. Put into 4 columns. */ if shareInfo.current_uses > 0 then shareInfo.current_uses = hwhite || shareInfo.current_uses say 'Current Users =' shareInfo.current_uses if shareInfo.current_uses > 0 then say lineT = 0 myRC = NetEnumerate(NETCONNECTION, 'connInfo', SrvName, ShareIn) if myRc = '0' & connInfo.0 > '0' then DO s = 1 to connInfo.0 userID = strip(connInfo.s.userName) if userID = '' then userID = 'UNKNOWN' Select When lineT = 0 then DO line0 = hcyan 'UserID' hwhite right(userID,13) lineT = 1 if s = conninfo.0 then say line0 END When lineT = 1 then do line0 = line0 ' ' hwhite || right(userID,13) lineT = 2 if s = conninfo.0 then say line0 END When lineT = 2 then do line0 = line0 ' ' hWhite || right(userID,13) lineT= 3 if s = conninfo.0 then say line0 end When lineT = 3 then do line0 = line0 ' ' hWhite || right(userID,13) lineT= 0 say line0 end OtherWise NOP END /* Select */ END /* DO S */ END /* ELSE DO */ say hgreen || Copies('*',75) hcyan /**********************************************/ /* Locates and displays the Alias info. */ /**********************************************/ myRc = NetGetInfo(NETALIAS, 'aliasInfo', DomName, ShareIn) if myRc <> '0' then do if pos('2783', myRC) then say '1B'x || '[33;40m'"No Alias Info found" ELSE say '1B'x || '[33;40m''Error from NetGetInfo(NetAlias)' myRc end ELSE DO say 'Alias Name =' aliasInfo.name say 'Alias Remark =' aliasInfo.remark say 'Alias Server =' aliasInfo.server say 'Alias Mode =' aliasInfo.mode say 'Alias Type =' aliasInfo.type say 'Alias Queue =' aliasInfo.queue say 'Alias Path =' aliasInfo.path say 'Alias Loc =' aliasInfo.location if pos("Files", aliasInfo.type) = 1 & pingTest = '/DIR' then call FindDirSize END say hgreen || Copies('*',75) hcyan /**********************************************/ /* Locates and displays the Print Queue info. */ /**********************************************/ qRc = NetGetInfo(NETPRINTDEST, 'destInfo', srvName, shareIn) /* Search for print queues. */ myRc = NetGetInfo(NETPRINTQUEUE, 'queueInfo', SrvName, ShareIn) if myRc <> '0' then do if pos('124', myRC) | pos('215', myRC) then say '1B'x || '[33;40m'"No Print Queue found" else say '1B'x || '[33;40m''Error from NetGetInfo(NetPrintQueue)' myRc end ELSE DO qComm = Translate(queueInfo.comment,"",'0D'X) q2 = Translate(qComm,"",'0A'X) say 'Queue Name =' queueInfo.DeviceName say 'Queue Remark =' q2 say 'Queue Printers=' queueInfo.printers say 'Queue Driver =' queueinfo.DriverName /* Display the printer drivers associated with the print queue. */ drvr = destInfo.drivers PARSE VAR drvr PRTR1 ',' PRTR2 ',' PRTR3 ',' PRTR4 ',' PRTR5 ',' PRTR6 ',' PRTR7 if pos('DESTINFO', prtr1) > 0 then prtr1 = 'No drivers associated' if pos('PRTR', prtr1) = 1 | prtr1 = '' then nop else say 'Driver Assoc''d=' prtr1 if pos('PRTR', prtr2) = 1 | prtr2 = '' then nop else say 'Driver Assoc''d=' prtr2 if pos('PRTR', prtr3) = 1 | prtr3 = '' then nop else say 'Driver Assoc''d=' prtr3 if pos('PRTR', prtr4) = 1 | prtr4 = '' then nop else say 'Driver Assoc''d=' prtr4 if pos('PRTR', prtr5) = 1 | prtr5 = '' then nop else say 'Driver Assoc''d=' prtr5 if pos('PRTR', prtr6) = 1 | prtr6 = '' then nop else say 'Driver Assoc''d=' prtr6 if pos('PRTR', prtr7) = 1 | prtr7 = '' then nop else say 'Driver Assoc''d=' prtr7 /* Display total number of print jobs in print queue. If there is one, then */ /* display the UserName, Status and Time in queue. */ if queueInfo.jobs > 0 then say 'Jobs in Queue =' hwhite || queueInfo.jobs else say 'Jobs in Queue =' queueInfo.jobs if queueInfo.jobs > 0 then do pRC = NetGetInfo(100, 'prtDest', srvName, queueInfo.printers) say say hYellow || 'Current User =' hWhite || prtDest.UserName say hYellow || 'Job Comment =' hWhite || prtDest.StatusComment say hYellow || 'Time printing =' hWhite || prtDest.Time 'minutes' say END /* Checks the Queue alias and tests for Ping Test. If the conditions */ /* are correct, then it will ping the 4033. */ prt = Translate(shareIn) if pingTest = '/PING' then call PrintPing END say hgreen || Copies('*',75) hcyan /* Checks and displays the Net Access info. */ SELECT WHEN AliasInfo.type = 'Printer' then chkShare = '\PRINT\' || shareIn WHEN ALiasInfo.type = 'Files' then chkshare = AliasInfo.path OTHERWISE chkShare = shareIn END myRc = NetGetInfo(NETACCESS,"accInfo", SrvName, chkShare) if myRc <> '0' then do if pos('2222', myRC) then say '1B'x || '[33;40m'"No Net Access Info found" ELSE say '1B'x || '[33;40m''Error from NetGetInfo(NetAccess)' myRc end ELSE DO SELECT WHEN accInfo.audit = 'A' then accInfo.audit = 'A - Audit all' WHEN accInfo.audit = 'O' then accInfo.audit = 'O - Audit successful file opens' WHEN accInfo.audit = 'W' then accInfo.audit = 'W - Audit successful file/dir writes/creates' WHEN accInfo.audit = 'D' then accInfo.audit = 'D - Audit successful file/dir deletes' WHEN accInfo.audit = 'P' then accInfo.audit = 'P - Audit successful file/dir profile changes' WHEN accInfo.audit = 'o' then accInfo.audit = 'o - Audit failed file opens' WHEN accInfo.audit = 'w' then accInfo.audit = 'w - Audit failed file/dir writes/creates' WHEN accInfo.audit = 'd' then accInfo.audit = 'd - Audit failed file/dir deletes' WHEN accInfo.audit = 'p' then accInfo.audit = 'p - Audit failed file/dir profile changes' WHEN accInfo.audit = 'N' then accInfo.audit = 'N - No auditing performed' WHEN accInfo.audit = '-none-' then accInfo.audit = 'N - No auditing performed' WHEN length(accInfo.audit) > 1 then accInfo.audit = accInfo.audit '- Multiple audits enabled' OTHERWISE NOP END /* Displays the Net Access settings for the target share, if it is audited. */ say 'Access Audit =' accInfo.audit say 'Access Count =' accInfo.count do x = 1 to accInfo.count say hwhite right(accInfo.x.ugname, 10) accInfo.x.access end END say hgreen || Copies('*',75) hcyan if ALiasInfo.type = 'Printer' then do rc = NetGetInfo(195, 'pstatInfo', srvName, 1) if rc = 0 | pstatinfo.0 > 0 then do say 'Print Jobs spooled on' hyellow || srvr || hcyan '=' hwhite || pstatInfo.jobsqueued || hcyan 'since' left(pstatinfo.start,24) say hgreen || Copies('*',75) hcyan end end If AliasInfo.type = 'Files' then do fClose = 0 if pingTest = '/CLOSE' then fClose = 1 fPath = aliasInfo.path netFile.frkbuffer = 65535 rc = NetEnumerate(60, 'netfile', srvName, aliasinfo.path) say hwhite || 'Alias Path =' fPath if rc = 0 | netFile.0 > 0 then do f = 1 to netFile.0 say hgreen || 'File ID' || hcyan right(netFile.f.id,7) hgreen || left(netFile.f.pathname,45) hyellow || right(netFile.f.username,10) if fClose = 1 then do fRC = NetDelete(220, srvName, netFile.f.id) if fRC <> 0 then say hred ||' Received error' fRC else say hgreen || 'File ID' || hred right(netFile.f.id,7) hwhite || 'successfully closed' end end say say hgreen || 'Found' || hyellow netFile.0 hgreen || 'open files for' || hwhite ShareIn say hgreen || Copies('*',75) hcyan end say normal if srvName = domName then '@net use' srvName || '\IPC$ /del >NUL >NUL' else do '@net use' srvName || '\IPC$ /del >NUL >NUL' '@net use' domName || '\IPC$ /del >NUL >NUL' end exit INIT: /*********************************************************/ /* Initialization Routine. */ /*********************************************************/ call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs' call LoadLsRxutFuncs call rxFuncAdd 'RxLoadFuncs','RxUtils','RxLoadFuncs' ver = RxLoadFuncs('QUIET') NUMERIC DIGITS 15 say '1B'x || '[36;40m' do while queued()>0 pull dummy end NETACCESS = 10 NETALIAS = 20 NETCONNECTION = 40 NETLOGON = 50 NETFILE = 60 NETGROUP = 70 NETPRINTDEST = 100 NETPRINTQUEUE = 120 NETSERVER = 160 NETSERVICE = 170 NETSESSION = 180 NETSHARE = 190 NETSTATISTICS = 195 NETUSER = 280 NETGROUPUSERS = 340 NETSERVERMODALS = 370 RETURN COLORINIT: /* Sets up the colors, for the program. */ /********************************************************************/ /*------------------------------------------------------------------*/ /* Foreground colors, not highlighted */ /*------------------------------------------------------------------*/ black ='' red ='' green ='' yellow ='' blue ='' magenta ='' cyan ='' white ='' /*------------------------------------------------------------------*/ /* Foreground colors, highlighted */ /*------------------------------------------------------------------*/ hred ='' hgreen ='' hyellow ='' hblue ='' hmagenta ='' hcyan ='' hwhite ='' /*------------------------------------------------------------------*/ /* Changing foreground and background colors sample: */ /* white foreground, blue background */ /* white foreground, red background */ /*------------------------------------------------------------------*/ white_o_blue ='' white_o_red ='' /*------------------------------------------------------------------*/ /* Cursor position samples. */ /* Must be concatenated with SAY text arguments. */ /*------------------------------------------------------------------*/ cursor_up ='' /* Cursor up 1 line */ cursor_up2 ='' /* Cursor up 2 lines */ cursor_down ='' /* Cursor down 1 line */ cursor_right ='' /* Cursor right 1 space */ cursor_right5 ='' /* Cursor right 5 spaces */ cursor_left ='' /* Cursor left 1 space */ cursor_18_1 ='' /* Move cursor to row 18 column 1 */ /*------------------------------------------------------------------*/ /* Miscellaneous */ /*------------------------------------------------------------------*/ normal ='' /* Restore default attrib. and color */ reverse ='' /* Reverse video */ blinking ='' /* Blinking */ highlight ='' /* Highlight */ invisible ='' /* Invisible */ clearscreen ='' /* Clear screen */ erase_EOL ='' /* Erase to end of line */ beep ='' /* Bell character and cursor up */ /********************************************************************/ RETURN PutC: /*************************************************************/ /* Format the total size of all the files, by adding commas. */ /*************************************************************/ fmtSize = '' IF Length(fSize) >= 10 THEN /* Billions */ DO leadSize = Length(fSize) - 9 fmtSize = fmtSize || Left(fSize, leadSize)',' fSize = Right(fSize, 9) END IF Length(fSize) >= 7 THEN /* Millions */ DO leadSize = Length(fSize) - 6 fmtSize = fmtSize || Left(fSize, leadSize)',' fSize = Right(fSize, 6) END IF Length(fSize) >= 4 THEN /* Thousands */ DO leadSize = Length(fSize) - 3 fmtSize = fmtSize || Left(fSize, leadSize)',' fSize = Right(fSize, 3) END fmtSize = fmtSize || fSize RETURN ServerTest: /**********************************************************************/ /* Tests for the existance of a DIR on the target server and exits if */ /* the DIR does not exist. */ /**********************************************************************/ sRc = RxDirExist(testFile) if sRc = '0' then do say hYellow || 'Server' || hcyan srvr hyellow || 'does not exist' say 'Retry with a known server' || normal exit end /* DO */ '@net use' srvName || '\C$ /del >NUL >NUL' RETURN Domain: /*********************************************************/ /* Locates the Domain Controller for the server entered. */ /*********************************************************/ wRC = NetGetInfo(350, 'wkstaInfo', srvName) DomainName = wkstaInfo.langroup say 'Domain name is' DomainName tRC = NetGetInfo(NETSERVERMODALS, 'srvModals', srvName) Domain = srvModals.primary DomName = '\\' || srvModals.primary RETURN PrintPing: if pos('P', prt) = 1 | pos('S', prt) = 1 | pos('Q', prt) = 1 then do part1 = substr(prt, 2, 2) part2 = substr(prt, 4) tPart = '4000' || part1 || '0' || part2 say hGreen || '************************** Pinging' || hyellow tpart hgreen || '***************************' '1B'x || '[36;40m' '@os2ping /a=' || tPart '/r t w=2 2>&1 | RXQUEUE' do while queued()>0 pull pingLine select WHEN pos("ADDR", pingLine) > 0 THEN say pingLine WHEN pos("->", pingLine) > 0 THEN say pingLine WHEN pos("FIRST", pingLine) > 0 THEN say pingLine WHEN pos("OS2PING:", pingLine) = 1 THEN say pingLine OTHERWISE NOP end /* select */ end /* Queued */ end if pos('P', prt) = 8 | pos('L', prt) = 8 then do part1 = substr(prt, 1, 2) part2 = substr(prt, 3, 5) tPart = '4000' || part1 || '0' || part2 say hGreen || '*************************** Pinging' || hyellow tpart hgreen || '**************************' '1B'x || '[36;40m' '@os2ping /a=' || tPart '/r t w=1 2>&1 | RXQUEUE' do while queued()>0 pull pingLine select WHEN pos("ADDR", pingLine) > 0 THEN say pingLine WHEN pos("->", pingLine) > 0 THEN say pingLine WHEN pos("FIRST", pingLine) > 0 THEN say pingLine WHEN pos("OS2PING:", pingLine) = 1 THEN say pingLine OTHERWISE NOP end /* select */ end /* Queued */ end RETURN FindServers: /****************************************************************************/ /* Locates all the servers in the domain, whether the Domain Controller was */ /* entered, or a BackUp or Additional server. */ /****************************************************************************/ say hgreen || Copies('*',75) hcyan srvType = '-1' srvRc = NetEnumerate(NETSERVER, 'serverList', srvname, srvType, domainName) say ' ' hwhite serverList.0 hgreen || 'servers located'; say if srvRc <> 0 then do say 'No servers found' srvRc || normal exit end /* DO */ else do call rxstemsort serverlist. do w = 1 to serverList.0 bRc = NetGetInfo(NETSERVER, 'serverInfo', '\\' || serverList.w) say hcyan || 'Found' hWhite || serverList.w hyellow || serverInfo.comment '@net use \\' || serverList.w || '\IPC$ /del >NUL >NUL' end /* DO W */ end /* ELSE DO */ say hgreen || Copies('*',75) hcyan say normal EXIT RETURN FindPrinters: /*************************************************************************/ /* This sections checks to see if /PRINT is after the server name. It */ /* will then search the domain for printer aliases only. This section */ /* will exit the program, after it completes. */ /*************************************************************************/ say hgreen || Copies('*',75) hcyan myRc = NetEnumerate(NETALIAS, 'aliasInfo', domName) call RxStemSort aliasInfo. aCount = 0 os2Count = 0 ntCount = 0 if myRc <> '0' then DO if pos('2310', myRC) then say '1B'x || '[33;40m'"No Aliases found" ELSE say '1B'x || '[33;40m''Error from NetEnumerate(NetAlias) ' myRc END ELSE DO T = 1 to aliasInfo.0 inAlias = aliasInfo.t alRC = NetGetInfo(NETALIAS, 'alInfo', domName, inAlias) if alRC <> '0' then do say '1B'x || '[33;40m''Error from NetGetInfo(NetAlias) ' alRc end ELSE DO if alInfo.type \= "Printer" then iterate T aCount = aCount + 1 /************************************************************************************/ /* This section checks each server, and will change the color of the server name, */ /* if it is an NT print server (RED), a retired OS/2 print server (YELLOW), or */ /* a normal OS/2 print server (CYAN). */ /************************************************************************************/ say hcyan || Left(alInfo.name,8) ' ' hyellow || Left(alInfo.Server,8) ' ' || hcyan || left(alInfo.remark,40) END /* DO */ END /* DO T */ say; say ' ' hgreen || 'Domain' hyellow || domName hgreen || 'info' say; say ' ' hgreen || 'Found' hyellow || aCount hgreen || 'printer aliases, out of' hyellow || aliasInfo.0 hgreen || 'total aliases' say hgreen || Copies('*',75) hcyan say normal '@net use' srvName || '\IPC$ /del >NUL >NUL' EXIT RETURN FindSharesAliases: /*****************************************************************************/ /* Locates and displays the Share and Aliases for one server, the ServerName */ /* entered on the commandline. */ /*****************************************************************************/ myRc = NetEnumerate(NETSHARE, 'shareInfo', SrvName) lineT = 0 sCount = 0 line0 = '' say hgreen || Copies('*',75) hcyan call RxStemSort shareInfo. if myRc <> '0' then DO if pos('2310', myRC) then say '1B'x || '[33;40m'"No Shares found" ELSE say '1B'x || '[33;40m''Error from NetGetInfo(NetShare) ' myRc END ELSE DO T = 1 to shareInfo.0 inShare = shareInfo.t if pos('$', inShare) > 0 | inShare = "NETLOGON" then iterate t sCount = sCount + 1 SELECT WHEN lineT = 0 then do line0 = hcyan 'Share Name =' hwhite || right(inShare,10) lineT = 1 if t = shareInfo.0 then do say line0 line0 = '' end end When lineT = 1 then do line0 = line0 ' ' hWhite || right(inShare,10) lineT= 2 if t = shareInfo.0 then do say line0 line0 = '' end end When lineT = 2 then do line0 = line0 ' ' hWhite || right(inShare,10) lineT= 3 if t = shareInfo.0 then do say line0 line0 = '' end end When lineT = 3 then do line0 = line0 ' ' hWhite || right(inShare,10) lineT= 0 say line0; line0 = '' end OTHERWISE say line0 END /* SELECT */ end /* DO T */ if length(line0) > 1 then say line0 say; say ' ' hgreen || 'Found' hyellow || sCount hgreen || 'shares, out of' hyellow || shareInfo.0 hgreen || 'total shares' say hgreen || Copies('*',75) hcyan myRc = NetEnumerate(NETALIAS, 'aliasInfo', domName) lineT = 0 call RxStemSort aliasInfo. lineT = 0 aCount = 0 if myRc <> '0' then DO if pos('2310', myRC) then say '1B'x || '[33;40m'"No Aliases found" ELSE say '1B'x || '[33;40m''Error from NetEnumerate(NetAlias) ' myRc END ELSE DO T = 1 to aliasInfo.0 inAlias = aliasInfo.t alRC = NetGetInfo(NETALIAS, 'alInfo', domName, inAlias) if alRC <> '0' then do say '1B'x || '[33;40m''Error from NetGetInfo(NetAlias) ' alRc end ELSE DO if alInfo.server \= srvr then iterate T aCount = aCount + 1 SELECT WHEN lineT = 0 then do line0 = hcyan 'Alias Name =' hwhite || right(alInfo.name,10) lineT = 1 if t = aliasInfo.0 then do say line0 line0 = '' end end When lineT = 1 then do line0 = line0 ' ' hWhite || right(alInfo.name,10) lineT= 2 if t = aliasInfo.0 then do say line0 line0 = '' end end When lineT = 2 then do line0 = line0 ' ' hWhite || right(alInfo.name,10) lineT= 3 if t = aliasInfo.0 then do say line0 line0 = '' end end When lineT = 3 then do line0 = line0 ' ' hWhite || right(alInfo.name,10) lineT= 0 say line0; line0 = '' end OTHERWISE NOP END /* SELECT */ END /* DO */ END /* DO T */ if length(line0) > 1 then say line0 say; say ' ' hgreen || 'Found' hyellow || aCount hgreen || 'aliases, out of' hyellow || aliasInfo.0 hgreen || 'total aliases' say hgreen || Copies('*',75) hcyan say normal '@net use' srvName || '\IPC$ /del >NUL >NUL' EXIT RETURN FindDirSize: /**********************************************************************/ /* Break out the path info and build the total UNC pathname to search */ /**********************************************************************/ sDrv = substr(aliasInfo.path, 1,1) sPath = substr(aliasInfo.path, 3) sPath = Strip(sPath) if lastPos('\', sPath) < length(sPath) then sPath = sPath || '\' tPath = srvName || '\' || sDrv || '$' || sPath || '*.*' uPath = srvName || '\' || sDrv || '$' say; say 'Target Path =' tPath dirCount = 0 fileCount = 0 dCount = 0 /* Take UNC pathname and search for all files. Count filesize, number of */ /* files and total number of directories. Then format the total filesize */ /* and sent it to PUTC: to have it formatted with commas. */ sRc = SysFileTree(tPath, 'fileSiz.', 'BST') if sRc = 0 & fileSiz.0 > 0 then do s = 1 to fileSiz.0 parse var fileSiz.s date size attb scth if pos('D', attb) > 0 then do dCount = dCount + 1 iterate s end dirCount = Format(dirCount, 13,0) dirCount = dirCount + size fileCount = fileCount + 1 end dirCount = strip(dirCount) fSize = strip(dirCount) call PutC fCount = fmtSize say 'Total Dir Size=' fCount 'bytes in' fileCount 'files and' dCount 'dirs' '@net use' uPath '/del >NUL >NUL' RETURN FindInactives: /**********************************************************************/ /* Locates INACTIVE user ID's and displays them. */ /**********************************************************************/ say hgreen || Copies('*',75) hcyan myRc = NetEnumerate(NETUSER, 'UserIn', DomName) if myRc <> '0' then DO say '1B'x || '[33;40m''Error from NetEnumerate(NetUser) ' myRc END call rxstemsort userin. iCount = 0 say; say hcyan || 'Located' hyellow || userIn.0 hcyan || 'total users'; say say hgreen || Copies('*',75) hcyan do i = 1 to UserIn.0 UserId = UserIn.i myRc = NetGetInfo(NETUSER, 'UserInfo', DomName, UserID) if myRc <> '0' then do say '1B'x || '[33;40m''Error from NetGetInfo(NetUser)' myRc end ELSE DO if pos('D',userInfo.flags) > 0 then do userComment = strip(userInfo.usr_comment) say 'Inactive account' hyellow || left(userInfo.name,12) hcyan || left(userInfo.comment,45) say 'On Server ' hyellow || srvr || hwhite ' ' left(userComment,45) say ' ' hcyan || left(userInfo.full_name,45) iCount = iCount + 1 end else iterate i END say hgreen || Copies('*',75) hcyan end say; say 'Located' hyellow || iCount || hcyan 'inactive users out of' hyellow || userIn.0 || hcyan 'users on server' hwhite || srvr pct = format((iCount / userIn.0) * 100, 2,2) say hYellow || pct || hCyan '% inactive' say say hgreen || Copies('*',75) || normal EXIT RETURN FindNumUsers: /*********************************************************************/ /* Find the number of users in a domain. */ /*********************************************************************/ say hgreen || Copies('*',75) hcyan myRc = NetEnumerate(NETUSER, 'UserIn', DomName) if myRc <> '0' then DO say '1B'x || '[33;40m''Error from NetEnumerate(NetUser) ' myRc END call rxstemsort userin. iCount = 0 say; say hcyan || 'Located' hyellow || userIn.0 hcyan || 'total users'; say say hgreen || Copies('*',75) hcyan EXIT RETURN FindUsers: /*********************************************************************/ /* Find Users and list them. */ /*********************************************************************/ say hgreen || Copies('*',75) hcyan myRc = NetEnumerate(NETUSER, 'UserIn', DomName) if myRc <> '0' then DO say '1B'x || '[33;40m''Error from NetEnumerate(NetUser) ' myRc END call rxstemsort userin. iCount = 0 say; say hcyan || 'Located' hyellow || userIn.0 hcyan || 'total users'; say say hgreen || Copies('*',75) hcyan do i = 1 to UserIn.0 UserId = UserIn.i myRc = NetGetInfo(NETUSER, 'UserInfo', DomName, UserID) if myRc <> '0' then do say '1B'x || '[33;40m''Error from NetGetInfo(NetUser)' myRc end ELSE DO if pos('D',userInfo.flags) > 0 then INV = 'InAct' ELSE INV = 'Act' userComment = strip(userInfo.usr_comment) say cyan || left(userInfo.name,12) yellow || left(INV,6) white || left(userComment,45) END end say hgreen || Copies('*',75) hcyan say; say 'Located' hyellow || userIn.0 || hcyan 'users on server' hwhite || srvr say say hgreen || Copies('*',75) || normal EXIT RETURN FindServices: /*********************************************************************/ /* Locates the running services on a server and displays them */ /*********************************************************************/ say hgreen || Copies('*',75) hcyan say 'Locating services on' hyellow || SrvName say myRC = NetEnumerate(NETSERVICE, 'serviceInfo', SrvName) call rxstemsort serviceInfo. if myRC <> 0 then do say '1B'x || '[33;40m''Error from NetEnumerate(NetService)' myRc end ELSE DO s = 1 to serviceInfo.0 tRC = NetGetInfo(NETSERVICE, 'servInfo', SrvName, serviceInfo.s) say hwhite || right(servInfo.name,12) hcyan || 'running and the PID is' || hwhite right(servInfo.pid, 5) end say say hgreen || Copies('*',75) hcyan EXIT RETURN FindLogon: /*********************************************************************/ /* Locates users logged onto the server and displays them */ /*********************************************************************/ /* say hgreen || Copies('*',75) hcyan say 'Locating Logons on' hyellow || SrvName say myRC = NetEnumerate(NETLOGON, 'logonInfo', SrvName) if myRC <> 0 then do say '1B'x || '[33;40m''Error from NetEnumerate(NetLogon)' myRc end ELSE DO call rxstemsort logonInfo. if logonInfo.0 = 0 then say hyellow || 'No user accounts logged on.' else do s = 1 to logonInfo.0 say hcyan || 'User logged on' ||hwhite LogonInfo.s end end say say hyellow || ' ' logonInfo.0 hgreen || 'total users logged on' say hgreen || Copies('*',75) hcyan EXIT RETURN */ say hgreen || Copies('*',75) hcyan say 'Locating Logons on' hyellow || SrvName say myRC = NetGetInfo(NETLOGON, 'logonInfo', SrvName) if myRC <> 0 then do say '1B'x || '[33;40m''Error from NetGetInfo(NetLogon)' myRc end ELSE DO if logonInfo.num_entries = 0 then say hyellow || 'No user accounts logged on.' else do s = 1 to logonInfo.num_entries say hwhite || right(LogonInfo.s.eff_name,12) hcyan || right(logonInfo.s.computer,12) hgreen || 'User logged on' || hyellow substr(logonINfo.s.logon_time,1,24) end end say say hyellow || ' ' logonInfo.num_entries hgreen || 'total users logged on' say hgreen || Copies('*',75) hcyan EXIT RETURN FindGroup: /*********************************************************************/ /* Locates the Groups on a server and displays them */ /*********************************************************************/ say hgreen || Copies('*',75) hcyan say 'Locating groups on' hyellow || DomName say myRC = NetEnumerate(NETGROUP, 'groupInfo', DomName) call rxstemsort groupInfo. say hcyan || 'Total groups located =' || hyellow groupInfo.totalentries say if myRC <> 0 then do say '1B'x || '[33;40m''Error from NetEnumerate(NetGroup)' myRc end ELSE DO g = 1 to groupInfo.totalentries gName = strip(groupInfo.g) tRC = NetGetInfo(NETGROUP, 'grpInfo', DomName, gName) gRC = NetGetInfo(NETGROUPUSERS, 'grpuInfo', domName, gName) /* say groupinfo.g "and" grpInfo.name */ gComm = grpInfo.comment if gComm = '' then gComm = '-None-' select when gName = 'ADMINS' then gComm = '** Special ** ADMINISTRATORS' when gName = 'GUESTS' then gComm = '** Special ** GUEST IDs' when gName = 'SERVERS' then gComm = '** Special ** SERVER IDs' when gName = 'USERS' then gComm = '** Special ** USER IDs' otherwise nop end /* select */ say hwhite || right(gName,10) hcyan || right(grpuinfo.0,4) hgreen || 'users,' || hcyan gComm end say say hcyan || 'Total groups located =' || hyellow groupInfo.totalentries say hgreen || Copies('*',75) hcyan EXIT RETURN FindFiles: /*********************************************************************/ /* Locates the open files on a server and displays them */ /*********************************************************************/ say hgreen || Copies('*',75) hcyan say 'Locating open files on' hyellow || SrvName say fileInfo.frkBuffer = 65535 myRC = NetEnumerate(NETFILE, 'fileInfo', SrvName) if myRC <> 0 then do say '1B'x || '[33;40m''Error from NetEnumerate(NetFile)' myRc end ELSE do f = 1 to fileInfo.0 if fileInfo.f.username = '' then uName = 'UNKNOWN' else uName = fileInfo.f.username if fileInfo.f.num_locks > 0 then say hwhite || right(uname,10) hred || right(fileInfo.f.num_locks, 3) hgreen || fileInfo.f.pathname else say hwhite || right(uname,10) hcyan || right(fileInfo.f.num_locks, 3) hgreen || fileInfo.f.pathname end say say hcyan || 'Total open files located =' || hyellow fileInfo.0 say hgreen || Copies('*',75) hcyan EXIT RETURN FindSessions: /*********************************************************************/ /* Locates the sessions on a server and displays them */ /*********************************************************************/ say hgreen || Copies('*',75) hcyan say 'Locating sessions on' hyellow || SrvName say myRC = NetEnumerate(NETSESSION, 'sessionInfo', SrvName) if myRC <> 0 then do say '1B'x || '[33;40m''Error from NetEnumerate(NetSession)' myRc say hgreen || Copies('*',75) || normal exit end say hgreen || 'Total sessions found' || hyellow sessionInfo.0 say if sessionInfo.0 = 0 then do say hgreen || Copies('*',75) || normal exit end /* call rxstemsort sessioninfo. */ say ' UserName Conn Open Client Active Idle' say '------------------------------------------------------' conCount = 0 do s = 1 to sessionInfo.totalentries if sessioninfo.s.username = '' then uName = 'UNKNOWN' else uName = sessioninfo.s.username say hwhite || right(uName,10) hgreen || right(sessionInfo.s.num_conns,4) hred || right(sessionInfo.s.num_opens,4) ' ' || hcyan right(sessionInfo.s.cltype_name,12) hwhite || right(sessionInfo.s.time,7) hgreen || right(sessionInfo.s.idle_time,7) if s // 24 = 0 then do say say hyellow || ' UserName Conn Open Client Active Idle' say '------------------------------------------------------' say end conCount=conCount+sessionInfo.s.num_conns end say say hgreen || 'Total sessions found' || hyellow sessionInfo.totalentries hgreen || 'and total connections' ||hyellow conCount say hgreen || Copies('*',75) hcyan EXIT RETURN help: /**********************************************************************/ /* Help section. */ /**********************************************************************/ Say hyellow || center('GetInfo v1.30 by Steven Grim',79) Say hcyan Say "Enter a server name to get all shares and aliases (new function) on that" Say "server: " hgreen || "Example: GETINFO SERVER010" Say hcyan Say "Enter server, and share to get connection information:" Say " " hgreen || "Example: GETINFO SERVER010 AUDIT" Say hcyan Say "Enter server, share and /CLOSE to close all open files for that share" Say " " hgreen || "Example: GETINFO SERVER010 AUDIT /CLOSE" Say hcyan Say "Enter server, share and /DIR to get connection information and total directory" Say "tree size: (Using the /DIR on large directory trees may take some time.)" Say " " hgreen || "Example: GETINFO SERVER010 AUDIT /DIR" Say hcyan Say "Enter a server and parameter /ALL or /SERVERS to see all servers in the domain:" Say " " hgreen || "Example: GETINFO SERVER010 /ALL" Say hcyan Say "Enter a server name and /SERVICES to see all services running on a server:" Say " " hgreen || "Example: GETINFO SERVER010 /SERVICES" Say hcyan Say "Enter a server name and /SESSIONS to see all sessions running on a server:" Say " " hgreen || "Example: GETINFO SERVER010 /SESSIONS" Say hcyan Say "Enter a server name and /USERS to see all UserIDs in the domain:" Say " " hgreen || "Example: GETINFO SERVER010 /USERS" Say hcyan Say "Enter a server name and /NUM to see the number of UserIDs in the domain:" Say " " hgreen || "Example: GETINFO SERVER010 /NUM" Say hcyan Say "Enter a server name and /INACTIVE to see all inactive UserIDs in the domain:" Say " " hgreen || "Example: GETINFO SERVER010 /INACTIVE" Say hcyan Say "Enter a server name and /LOGON to see all UserIDs logged onto a server:" Say " " hgreen || "Example: GETINFO SERVER010 /LOGON" Say hcyan Say "Enter a server name and /GROUP to see all user groups on a server:" Say " " hgreen || "Example: GETINFO SERVER010 /GROUP" Say hcyan Say "Enter a server name and /FILES to see all open files on a server:" Say " " hgreen || "Example: GETINFO SERVER010 /FILES" Say hcyan Say "Enter a server name and /PRINT to see all printer aliases in the domain:" Say " " hgreen || "Example: GETINFO SERVER010 /PRINT" Say hcyan Say "Also, you can have the program OS2PING a 4033, by putting in a third parameter," Say "/PING: " hgreen || "Example: GETINFO SERVER010 P5114963 /PING" normal EXIT RETURN /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* End of Program */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */