/*---------------------------------------------------------------------------*\
|   Check Password replication                (C) Alain Rykaert - DEC97-APR98 |
\*---------------------------------------------------------------------------*/
         /* it's hard to say, but thanks to jacques from morgan euroclear */
    Version = '1.01'
    Say '* CHKPWD Version' Version

    Call Init                                 /* init dll's and other stuff*/
    Call SysCls

    OutFile = 'CHKPWD.LOG'                               /* Output filename*/

    TempFile = LSRDrive'\ibmlan\chkpwd.txt'               /* temporary file*/
    Say '* Temporary file:' TempFile

/*===================================*/
    DCName = 'JD0F0101'
    UserID = '$pol'
/*===================================*/

    RC = NetGetInfo(340, 'Server', '\\'DCName, 'Servers')
    If RC = 0
      Then Do
             Say '* Total Defined servers:' Server.0
             Say '* Scanning active servers...'
             Call SysCurState Off
             Parse Value SysCurPos() With Row Col
             j = 0
             Do i = 1 to Server.0
               Call SysCurPos Row, 0
               Color = Random(41,46)
               Say ' ' i
               If Stream('\\'Server.i'\ibmlan$\ibmlan.ini', 'C','Query Exists') <> ''
                 Then Do
                        j = j + 1
                        ServerName.j = Server.i
                      End
                 Else Nop
             End
           End
      Else Call ChkError RC

    ServerName.0 = j

    Do i = 1 to ServerName.0                   /* Reset all status counters*/
      Status.i = ''
    End

    OutText = '* Total active servers:' ServerName.0
    Say OutText
    Call LineOut OutFile, OutText
    Call Stream  OutFile, 'C', 'Close'

   'if not exist \\'DCName'\ibmlan$\netprog\pwdexp.exe copy pwdexp.exe \\'DCName'\ibmlan$\netprog\pwdexp.exe'
   'net admin \\'DCName '/c pwdexp' UserID '>' TempFile
    DCPassword = LineIn(TempFile)
    Call Stream TempFile, 'C', 'Close'

    Call LineOut OutFile, Time() DCName
    Call Stream  OutFile, 'C', 'Close'

    Say '* Total active servers:' ServerName.0

    LoopCounter = 0
    Call Time('R')
    Found = 0
    Do While Found <> ServerName.0
      LoopCounter = LoopCounter + 1
      Say Left('*', 40, '-') 'Loop:' LoopCounter
      Do i = 1 to ServerName.0
        If Status.i <> 'OK'
          Then Do
                 Say '* ServerName:' i ServerName.i Status.i
                'if not exist \\'ServerName.i'\ibmlan$\netprog\pwdexp.exe copy pwdexp.exe \\'ServerName.i'\ibmlan$\netprog\pwdexp.exe'
                'net admin \\'ServerName.i '/c pwdexp' UserID '>' TempFile
                 ServerPassword = LineIn(TempFile)
                 Call Stream TempFile, 'C', 'Close'
                 If DCPassword = ServerPassword
                   Then Do
                          Status.i = 'OK'
                          Found = Found + 1
                          Say '  Found:' Found
                          Call Beep 2000,50
                          Call LineOut OutFile, Time() ServerName.i
                          Call Stream  OutFile, 'C', 'Close'
                        End
                   Else Nop
               End
          Else Nop
      End
    End
    Say '* Total Time:' Trunc(Time('E'),2)

    Exit

 INIT:/* --------------------------------------------------------------------*/

   '@echo off'
    BootDrive = Left(Value('Comspec',,'OS2Environment'),2)

    If RxFuncQuery('SysLoadFuncs')
      Then Do
             Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
             Call SysLoadFuncs
           End
      Else Nop

    LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
    PPath = Translate(Value('DPATH',,'OS2Environment'))
    x = Pos('\IBMLAN\NETPROG;', PPath) -2
    If x > 0
      Then Do
             LSRDrive = SubStr(PPath, x, 2)
             Say '* LanServer Drive:' LSRDrive
           End
      Else Do
             Say '* Could not determine the Lan Requester path'
             Exit
           End

    Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
    If RxFuncQuery('LoadLSRXUTFuncs')
      Then Do
             Call RxFuncAdd LoadLsRxutFuncs, LSRXUT, LoadLsRxutFuncs
             Call LoadLsRxutFuncs
           End
      Else Nop

    Return

 CHKERROR:/* ----------------------------------------------------------------*/

    Parse Arg RCode

    Say '* Error:' RCode
    Exit X2D('1600')

    Return

 CHKFILE:/* -----------------------------------------------------------------*/

    Parse Arg File_To_Check

    If Stream(File_To_Check, 'C', 'Query Exists') = ''
      Then Do
             Say '! File not found:' File_To_Check
             Exit
           End
      Else Nop

    Return

