home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / network / rexxlan / smples30 / apply.cmd < prev    next >
OS/2 REXX Batch file  |  1993-11-07  |  4KB  |  89 lines

  1. /* ********************************************************************* */
  2. /*                                                                       */
  3. /*   File:       APPLY.CMD                                               */
  4. /*   Version:    1.0                                                     */
  5. /*   Date:       1.7.1993                                                */
  6. /*                                                                       */
  7. /*   (c) EDV Beratung L. Braeuer, 1993                                   */
  8. /*                                                                       */
  9. /*   Purpose:    Apply access rights to all subdirectories               */
  10. /*                                                                       */
  11. /*               SYNTAX:   APPLY  \\{server}  {srvdir}:\{srvdir}\        */
  12. /*                                                                       */
  13. /* ********************************************************************* */
  14.  
  15. Server     = ""
  16. Resource   = ""
  17.  
  18. PARSE UPPER ARG Server Resource
  19.  
  20. IF Server = "" | Resource = "" THEN DO
  21.    SAY
  22.    SAY 'Invalid syntax: APPLY  \\{server}  {srvdir}:\{srvdir}\'
  23.    SAY
  24.    EXIT
  25.    END
  26.  
  27. /*                                                                       */
  28. /*  Initialize REXXLAN                                                   */
  29. /*                                                                       */
  30. call rxfuncadd NetLoadFuncs, RXLAN30, NetLoadFuncs
  31. CALL NetLoadFuncs
  32.  
  33. /*                                                                       */
  34. /*  Initialize SYSUTIL function SysFileTree                              */
  35. /*                                                                       */
  36. CALL RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'
  37.  
  38.  
  39. /*                                                                       */
  40. /*  Get Access Rights of BaseDirectory                                   */
  41. /*                                                                       */
  42. ret = NetAccessGetInfo( Server, Resource, 1, 'ACCINFO', '', '' )
  43.  
  44. IF ret <> 0 THEN DO
  45.    SIGNAL Error
  46.    END
  47.  
  48. /*                                                             */
  49. /* Translate a servers local path specification to an UNC name */
  50. /* e.g. server = \\ADMIN    and Resource= C:\IBMLAN            */
  51. /* UNCName = \\ADMIN\C$\IBMLAN\                                */
  52. /*                                                             */
  53. UNCName = Server || '\' || SUBSTR( Resource, 1, 1 ) || '$' || SUBSTR( Resource, 3 ) || '\'
  54. BasePathLen = LENGTH( UNCName )
  55.  
  56. CALL SysFileTree UNCName,'Files','DS'     /* Scan all subdirectories for directories */
  57.  
  58. DO i = 1 TO Files.0
  59.     LocalName = Resource || '\' || SUBSTR( WORD( Files.i, 5 ), BasePathLen+1 )
  60.     SAY 'Applying ACL to ' || LocalName
  61.     Accinfo.acc1_resource_name = LocalName
  62.  
  63. /* Try an NetAccessAdd to add a new ACL entry. If this fails, assume there */
  64. /* already was an ACL entry. Try to change this through NetAccessSetInfo   */
  65. /* if this fails, abort program.                                           */
  66.  
  67.     ret = NetAccessAdd( server, 1, 'ACCINFO', '' )
  68.     IF ret <> 0 THEN DO
  69.        ret = NetAccessSetInfo( server, LocalName, 1, 'ACCINFO', '', '0' )
  70.        IF ret <> 0 THEN DO
  71.           SIGNAL Error
  72.           END
  73.        END
  74.     END
  75.  
  76. SAY 'Apply successfully completed.'
  77.  
  78. ERROR:
  79. IF ret <> 0 THEN DO
  80.    SAY 'Apply aborted.'
  81.    SAY 'Reason: '
  82.    SAY NetRexxGetMessage( ret )
  83.    SAY
  84. /*                                                                       */
  85. /* free REXXLAN resources                                                */
  86. /*                                                                       */
  87. CALL Netdropfuncs
  88.  
  89.