home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / lsnlchk.cmd < prev    next >
OS/2 REXX Batch file  |  1999-06-01  |  7KB  |  230 lines

  1. /*---------------------------------------------------------------------------*\
  2. |   Check LAN Server Netlogon Service         (C) Alain Rykaert - APR98-JUN99 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.02'
  5.     Say '* LSNLCHCK Version' Version
  6.  
  7.     Signal On Halt Name Quit
  8.  
  9.     Call Init                                 /* Init dll's and other stuff*/
  10.  
  11.     LogFileName = 'LSNLCHK.LOG'                          /* Output filename*/
  12.     Say '* Log Filename:' LogFileName
  13.  
  14.     TempFile = LSRDrive'\ibmlan\lsnlchk.tmp'              /* Temporary file*/
  15.  
  16.     Parse Upper Arg DCName UserID Option
  17.  
  18.     If DCName = '' | UserID = ''
  19.       Then Do
  20.              Say '*'
  21.              Say '* LAN Server Netlogon Check'
  22.              Say '*'
  23.              Say '* Usage: LSNLCHK DCName UserID {/PWD}'
  24.              Say '*'
  25.              Say '* Sample: LSNLCHK \\BEDDC01 USER001 /pwd'
  26.              Say '*'
  27.              Exit
  28.            End
  29.       Else Nop
  30.  
  31.     If Option = '/PWD'              /* check if the fix option is specified*/
  32.       Then PWD = 1
  33.       Else PWD = 0
  34.  
  35.     DCName = Strip(DCName,'L','\')
  36.  
  37.     Say '* Server Name:' '\\'DCName
  38.     Say '* UserID:' UserID
  39.  
  40.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)  /* Get server role*/
  41.     If RC = 0
  42.       Then Do
  43.              ServerRole = ServerModalInfo.Role
  44.              If WordPos('Primary', ServerRole) > 0
  45.                Then Nop
  46.                Else Do
  47.                       Say '! This is not a Primary Domain Controller' '07'x
  48.                       Exit
  49.                     End
  50.            End
  51.       Else Call ChkError RC
  52.  
  53.     If PWD = 1              /* if passwordcheck, get the password on the DC*/
  54.       Then Do
  55.             'if not exist \\'DCName'\ibmlan$\netprog\pwdexp.exe copy pwdexp.exe \\'DCName'\ibmlan$\netprog\pwdexp.exe'
  56.             'net admin \\'DCName '/c pwdexp' UserID '>' TempFile
  57.              DCPassword = LineIn(TempFile)
  58.              Call Stream TempFile, 'C', 'Close'
  59.              If Left(DCPassword,6) = 'Error:'
  60.                Then Do
  61.                       Say '!' DCPassword '07'x
  62.                       Exit
  63.                     End
  64.                Else Nop
  65.            End
  66.       Else Nop
  67.  
  68.     RC = NetGetInfo(340, 'Server', '\\'DCName, 'Servers')/* get all servers*/
  69.     If RC = 0
  70.       Then Do
  71.              Call RxStemSort 'Server'
  72.              Say '* Total defined servers:' Server.0
  73.              Say '* Scanning active servers...'
  74.              Call SysCurState Off
  75.              Parse Value SysCurPos() With Row Col
  76.              j = 0
  77.              Do i = 1 to Server.0           /* get only the 'alive' servers*/
  78.                Call SysCurPos Row -1, 28
  79.                Say ESC'[K' i Server.i
  80.            /*  If Stream('\\'Server.i'\ibmlan$\ibmlan.ini', 'C','Query Exists') <> '' */
  81.                If NetGetInfo(370, 'ServerModalInfo', '\\'Server.i) = 0
  82.                  Then Do
  83.                         j = j + 1
  84.                         ServerName.j = Server.i
  85.                       End
  86.                  Else Nop
  87.              End
  88.            End
  89.       Else Call ChkError RC
  90.  
  91.     ServerName.0 = j                             /* total of active servers*/
  92.  
  93.     Do i = 1 to ServerName.0                   /* Reset all status counters*/
  94.       Status.i = ''
  95.     End
  96.  
  97.     OutText = '* Total active servers:' ServerName.0
  98.     Say OutText
  99.     Call Logit OutText
  100.  
  101.  
  102.     Call Time('R')                                       /* reset the timer*/
  103.     UserFound = 0
  104.     PasswordFound = 0
  105.     Loop = 1
  106.  
  107.     Do While UserFound <> ServerName.0     /* if all servers ok, then leave*/
  108.       Call SysCls
  109.       Say Left('*', 40, '-') 'Loop:' Loop
  110.       Do i = 1 to ServerName.0
  111.         If Status.i = ''
  112.           Then Do
  113.                  If PWD = 1                               /* password check*/
  114.                    Then Do
  115.                          'if not exist \\'ServerName.i'\ibmlan$\netprog\pwdexp.exe copy pwdexp.exe \\'ServerName.i'\ibmlan$\netprog\pwdexp.exe'
  116.                          'net admin \\'ServerName.i '/c pwdexp' UserID '>' TempFile
  117.                           ServerPassword = LineIn(TempFile)
  118.                           Call Stream TempFile, 'C', 'Close'
  119.                           If DCPassword = ServerPassword
  120.                             Then Check = 1
  121.                             Else Check = 0
  122.                         End
  123.                    Else Do                                    /* user check*/
  124.                           If NetGetInfo(280, 'UserInfo', '\\'ServerName.i, UserID) = 0
  125.                             Then Check = 1
  126.                             Else Check = 0
  127.                         End
  128.  
  129.                  If Check = 1
  130.                    Then Do
  131.                           Status.i = 'OK'
  132.                           UserFound = UserFound + 1
  133.                           Call Beep 2000,50
  134.                           Call Logit Time() Left(ServerName.i,8) Trunc(Time('E'),2)
  135.                         End
  136.                    Else Nop
  137.  
  138.                  Say '* ServerName:' i Left(ServerName.i,9) Status.i
  139.                End
  140.           Else Nop
  141.       End
  142.       Loop = Loop + 1
  143.       Call SysSleep 1
  144.     End
  145.  
  146.     Say
  147.     Say '* Total Time:' Trunc(Time('E'),2)
  148.  
  149.     Exit
  150.  
  151.  INIT:/* --------------------------------------------------------------------*/
  152.  
  153.    '@echo off'
  154.  
  155.     ESC = '1B'x
  156.  
  157.     BootDrive = Left(Value('Comspec',,'OS2Environment'),2)
  158.  
  159.     If RxFuncQuery('SysLoadFuncs')
  160.       Then Do
  161.              Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  162.              Call SysLoadFuncs
  163.            End
  164.       Else Nop
  165.  
  166.     LSRDrive = Left(SysSearchPath('PATH', 'NET.EXE'), 2)    /* IBMLAN Drive*/
  167.     If LSRDrive <> ''
  168.       Then Nop
  169.       Else Do
  170.              Say '! Could not determine the Lan Requester path' '07'x
  171.              Exit
  172.            End
  173.  
  174.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  175.     If RxFuncQuery('LoadLSRXUTFuncs')
  176.       Then Do
  177.              Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  178.              Call LoadLsRxutFuncs
  179.            End
  180.       Else Nop
  181.  
  182.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  183.     If RxFuncQuery('RxLoadFuncs')
  184.       Then Do
  185.              Call RxFuncAdd 'RxLoadFuncs', 'RXUTILS', 'RxLoadFuncs'
  186.              Call RxLoadFuncs
  187.            End
  188.       Else Nop
  189.  
  190.     Return
  191.  
  192.  CHKERROR:/* ----------------------------------------------------------------*/
  193.  
  194.     Parse Arg RCode
  195.  
  196.     Say '* Error:' RCode
  197.     Exit
  198.  
  199.     Return
  200.  
  201.  CHKFILE:/* -----------------------------------------------------------------*/
  202.  
  203.     Parse Arg File_To_Check
  204.  
  205.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  206.       Then Do
  207.              Say '! File not found:' File_To_Check
  208.              Exit
  209.            End
  210.       Else Nop
  211.  
  212.     Return
  213.  
  214.  LOGIT:/* ------------------------------------------------------------------*/
  215.  
  216.     Parse Arg Log_Text
  217.  
  218.     If LineOut(LogFileName, Log_Text) = 0
  219.       Then Call Stream LogFileName, 'C', 'Close'
  220.       Else Say '! Error while writing:' LogFileName '07'x
  221.  
  222.     Return
  223.  
  224.  QUIT:/* --------------------------------------------------------------------*/
  225.  
  226.     Say '...Interupted by User...'
  227.  
  228.     Exit
  229.  
  230.