///////////////////////////////////////////////////////////////////////// // // This task file will search through the active connections and // compare the Logged In User name to a text list of User names. // // What it does if a match is found or a match is not found depends // upon which part of the example logic is used. // // This sample task assumes SYS:SYSTEM/CLRCONNS.TXT (text file) // exists with a list of valid LOGIN user names (each name is a // separate line/record in the text file). // // Note: The comparison is a case sensitive, substring search // (i.e., ADMIN matches ADMIN.ATI & ADMINISTRATOR.ATI). // // Results are logged in SYS:SYSTEM/CLRCONNS.LOG (text file). // ///////////////////////////////////////////////////////////////////////// // Open an output (text) file to record the results of this process OPEN_WRITE SYS:SYSTEM/CLRCONNS.LOG IF ERRORLEVEL // ECHO the error to the screen ECHO ERROR: Unable to open/create SYS:SYSTEM/CLRCONNS.LOG! ECHO ABORT: Task aborted before processing could begin... // Abort further processing of the task ABORT ENDIF // Echo and Write a header identifying this action ECHO_WRITE %TASK_NAME% started on %MONTH%/%DAY%/%YEAR% at %HOUR%:%MINUTE%%AM_PM% // Define variable %0 as the first connection DEFINE %0 0001 // First Disable Logins to prevent connections from re-attaching once cleared DISABLE LOGINS // Now loop through ALL active connections using a nested loop to check // against the allowed users list (maintained in CLRCONNS.TXT text file) WHILE %0<=%CONNS_PEAK% // Check for inactive or Not Logged In connections since // they cannot Login due to DISABLE LOGINS being issued IF "%CONN_NAME_%0%"=="INACTIVE" OR "%CONN_NAME_%0%"=="NOT-LOGGED-IN" // Either inactive or NLI connection so increment the // counter and continue through the connection loop DEFINE %0 %0+=1 CONTINUE ENDIF // Clear a temporary variable to use in retrieving allowed users from file DEFINE %1 "NULL" // Open/re-open the input (text) file containing the LOGIN names // of users allowed to remain logged in OPEN_READ SYS:SYSTEM/CLRCONNS.TXT // Check that the file could be opened otherwise ALL connections will // fail to match and will be cleared IF ERRORLEVEL // ECHO the error to the screen and WRITE it to the log ECHO_WRITE ERROR: Unable to access SYS:SYSTEM/CLRCONNS.TXT! ECHO_WRITE ABORT: Task aborted at connection %0... ECHO_WRITE. ECHO_WRITE. // All input/output files are automatically closed when re-opened // or the task ends. Good task design dictates that we make sure. CLOSE // Abort further processing of the task ABORT ENDIF // Loop through the text file of names searching for a match WHILE // Read the first/next entry in the OPEN_READ file // and store the result in the %1 variable // Note: %1 is set to NULL ("") and the ERRORLEVEL // flag is set if the End Of File is reached READ %1 // Break out of loop if ERRORLEVEL flag set (End Of File) IF ERRORLEVEL THEN BREAK // If current user matches this entry in list, break out of loop // Note: The comparison is a case sensitive, substring search IF SCAN_STRING "%1" "%CONN_NAME_%0%" THEN BREAK LOOP // NOTE: By default, this task will clear any connection whose // Logged In User name does not match any of the User // names in the SYS:SYSTEM\CLRCONNS.TSK file // (i.e., %1 is NULL ("") because the End Of File was reached) // // To change the logic so that the task will clear any // connection whose Logged In User name matches any of // User names in the SYS:SYSTEM\CLRCONNS.TSK file, // change the IF test to an IF NOT test // (i.e., %1 is NOT NULL if a match was found) IF "%1"=="" // Log the fact that we are clearing this connection ECHO_WRITE Clearing connection: %0 - %CONN_NAME_%0% // Use the standard NetWare Server Console command to // clear the station (substituting our connection number) CLEAR STATION %0 ENDIF // Increment the counter and continue the loop through active connections DEFINE %0 %0+=1 LOOP // Finished so add one last entry to the log and a couple of null lines ECHO_WRITE Finished checking/clearing connections... ECHO_WRITE. ECHO_WRITE. ECHO_WRITE Special processing started... // Add your special processing needs here (those which required // the connections to be cleared and logins disabled) ECHO_WRITE Special processing complete... // Now that everything is complete, DO NOT FORGET to Enable Logins ENABLE LOGINS // All input/output files are automatically closed when re-opened // or the task ends. Good task design dictates that we make sure. CLOSE