home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / ls4adm.zip / DiscUser.cmd < prev    next >
OS/2 REXX Batch file  |  1994-07-14  |  2KB  |  63 lines

  1. /* Force a Single User off the Domain */
  2. arg UserID
  3.  
  4. if UserID = "" then do
  5.    say "You must supply a current UserID as a parameter"
  6.    return
  7. end
  8.  
  9. '@rxqueue /clear'
  10.  
  11. /* Make sure we're running on the right machine */
  12. '@net accounts | rxqueue'
  13. do while queued() > 0
  14.    pull line
  15.    if word(line,1) = "SERVER" & word(line,2) = "ROLE:" then do
  16.       role = word(line,3)
  17.       if role <> "PRIMARY" then do
  18.          say "This utility may only be run on the domain controller"
  19.          return
  20.       end
  21.    end
  22. end
  23.  
  24. /* Disable the user's account */
  25. '@NET USER' UserID '/ACTIVE:NO >\DEV\NUL 2>&1'
  26.  
  27. /* Disconnect the user from all resource in the domain */
  28.  
  29. /* Get all server names */
  30. n = 0
  31. '@net view | rxqueue'
  32. do while queued() > 0
  33.    pull machine .
  34.    if left(machine,2) = '\\' then do
  35.       n = n + 1
  36.       s.n = machine
  37.    end
  38. end
  39.  
  40. /* Tell each server to disconnect the user, if connected */
  41. do i=1 to n
  42.    '@net admin' s.n '/c net session | rxqueue'
  43.    do while queued() > 0
  44.      pull machine user .
  45.      if left(machine,2) = '\\' & user = UserID then do
  46.        say "Disconnecting" user
  47.        '@net admin' s.n '/c net session' machine '/delete /y'
  48.      end
  49.    end
  50. end
  51.  
  52. drop s
  53.  
  54. say
  55. say "User" UserID "has been disconnected and disabled."
  56. say
  57. say "To allow" UserID "to log on in the future, you will need to"
  58. say "re-enable the account using:"
  59. say
  60. say "    NET USER" UserID "/ACTIVE:YES"
  61. say
  62. say "or by using User Profile Management Services."
  63.