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

  1. /*---------------------------------------------------------------------------*\
  2. |   Query DCDB Info from a Domain                                             |
  3. |                                               (C) Alain Rykaert AUG96-JAN99 |
  4. \*---------------------------------------------------------------------------*/
  5.     Version = '1.12'
  6.  
  7.  /*- Start of Variables -----------------------------------------------------*/
  8.  
  9.     Output.0  =  10            ; Ico.0  = Output.0
  10.     Output.1  = 'Servers.CSV'  ; Ico.1  = 'servers.ico'
  11.     Output.2  = 'Users.CSV'    ; Ico.2  = 'users.ico'
  12.     Output.3  = 'Groups1.CSV'  ; Ico.3  = 'groups1.ico'
  13.     Output.4  = 'Groups2.CSV'  ; Ico.4  = 'groups2.ico'
  14.     Output.5  = 'Alias.CSV'    ; Ico.5  = 'alias.ico'
  15.     Output.6  = 'Acl.CSV'      ; Ico.6  = 'acl.ico'
  16.     Output.7  = 'Assgn.CSV'    ; Ico.7  = 'assgn.ico'
  17.     Output.8  = 'Appl.CSV'     ; Ico.8  = 'appl.ico'
  18.     Output.9  = 'Selector.CSV' ; Ico.9  = 'selector.ico'
  19.     Output.10 = 'Users.PWD'    ; Ico.10 = 'userspw.ico'
  20.  
  21.  /*- End of Variables -------------------------------------------------------*/
  22.  
  23.     Parse Arg Option
  24.  
  25.     Call Init                    /* Initialisation of DLL's and other stuff*/
  26.     Call Chkopt                          /* Check Options & display Welcome*/
  27.     Call Main                                            /* do the main job*/
  28.     Exit
  29.  
  30.  MAIN:/* ----------------------------------------------------- MAIN: -------*/
  31.  
  32.     Call ChkServer DCName                /* Check if this is the Primary DC*/
  33.  
  34.  /* Get the Domain name from the DC-PR */
  35.  
  36.     Call SysFileSearch 'DOMAIN =', '\\'DCName'\ibmlan$\ibmlan.ini', 'File.'
  37.     If File.0 > 0
  38.       Then Do j = 1 to File.0
  39.              Parse Value File.j With Begin '=' Rest .
  40.              If Left(Begin,1) = ';'
  41.                Then Nop
  42.                Else DomainName = Rest
  43.            End
  44.       Else Do
  45.              Say '! Unable to determine the Domains name' '07'x
  46.              Say '! from the Primary Domain Controller' DCName
  47.              Say '* Press any key to continue'
  48.              Pull
  49.              Exit
  50.           End
  51.     Say '  The name of the Domain is:' DomainName
  52.     Say
  53.  
  54.  /* Check if a directory exist for this domain. If needed, create it */
  55.  
  56.     Call ChkDir Directory()'\'DomainName
  57.  
  58.     Call MakeObjects                           /* make a folder, GETALL, T2*/
  59.  
  60.     Call MakeOutputs                /* make shadows of existing *.CSV files*/
  61.  
  62.     Say
  63.     Say '* Done. Press any key to Exit'
  64.     Pull
  65.  
  66.     Return
  67.  
  68.  CHKOPT:/* ---------------------------------------------------- CHKOPT: -----*/
  69.  
  70.     DCName = ''
  71.  
  72.     Option = Translate(Option)
  73.     Do While Option <> ''
  74.        Parse Value Option With Argument ' ' Option
  75.        Select
  76.         When Left(Argument,5) = '/SRV:' Then DCName = Substr(Argument,6)
  77.         Otherwise Nop
  78.        End
  79.     End
  80.  
  81.     If DCName = ''
  82.       Then signal GetHelp
  83.       Else Nop
  84.  
  85.     Return
  86.  
  87.  INIT:/* ------------------------------------------------------ INIT: -------*/
  88.  
  89.     Call RgUtil   '/M'                                    /* Rexx Utilities*/
  90.     Call RgUtils  '/M'                                    /* Rexx Utilities*/
  91.     Call RgLSRXUT '/M'                             /* Lan Server Rexx Utils*/
  92.  
  93.     Parse Upper Source . . P_NAME
  94.     PRGN = Filespec('N', Left(P_NAME, Length(P_NAME) -4))
  95.  
  96.    '@echo off'
  97.     Redir = '>NUL 2>NUL'
  98.     TempFile = 'Temp.Tmp'             /* Temporary file used in the program*/
  99.  
  100.     ResourceFile = 'LSMT.RSC'                  /* Ansi Topics Resource File*/
  101.     Call Chkfile ResourceFile
  102.  
  103.     HW_File = 'HW.CSV'
  104.     SW_File = 'SW.CSV'
  105.  
  106.     Return
  107.  
  108.  GETANS:/* ---------------------------------------------------- GETANS: -----*/
  109.  
  110.     Vars_List = Ansi_Say(ResourceFile Topic_List)
  111.     Parse VALUE SysCurPos() With Old_R Old_C
  112.     Do While Vars_List <> ''
  113.       Parse Value Vars_List With Topic_Id ';' Var_Id ';' Row ';' Column ';' Color ';' Vars_List
  114.       Call SysCurPos Row, Column
  115.       Say x2c(Color) || Topic_String.Topic_Id.Var_Id || '1B'x || '[0m'
  116.     End
  117.     Call SysCurPos Old_R, Old_C
  118.  
  119.     Return
  120.  
  121.  GETHELP:/* --------------------------------------------------- GETHELP: ----*/
  122.  
  123.     Topic1 = 'Q_SERVERS_DCDB'
  124.     Topic_String.Topic1.1 = PRGN
  125.     Topic_List = Topic1
  126.  
  127.     Call GetAns
  128.  
  129.     Exit
  130.  
  131.  CHKFILE:/* --------------------------------------------------- CHKFILE: ----*/
  132.  
  133.     Parse Arg File
  134.  
  135.     RC = Stream(File, 'C', 'Query Exists')
  136.     If RC = ''
  137.       Then Do
  138.              Say '! File' File 'not found' '07'x
  139.              Exit
  140.            End
  141.       Else Nop
  142.     Call Stream File, 'C', 'Close'
  143.  
  144.     Return
  145.  
  146.  CHKSERVER:/* ------------------------------------------------- CHKSERVER: --*/
  147.  
  148.     Parse Arg Server
  149.  
  150.     Say
  151.     Say '* Check if' Server 'is a Primary Domain Controller ...'
  152.  
  153.     Parse Value SysCurPos() With Row Col
  154.     Call SysCurPos Row -1, 47 + Length(Server)
  155.  
  156.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'Server)
  157.  
  158.     If RC = 0 & ServerModalInfo.Role = 'Primary server in the domain'
  159.       Then Say 'OK'
  160.       Else Do
  161.              Say '! Not OK' '07'x
  162.              Say
  163.              Say '* Done. Press any key to Exit'
  164.              Pull
  165.              Exit
  166.            End
  167.  
  168.     Return
  169.  
  170.  MAKEOBJECTS:/* ----------------------------------------------- MAKEOBJECTS*/
  171.  
  172.     Class    = 'WPFolder'
  173.     Title    =  DomainName
  174.     Location = '<LSMT_DCDB>'
  175.     Setup    = 'OBJECTID=<LSMT_DCDB_'DomainName'>;'                ||,
  176.                'ICONVIEW=FLOWED;'                                  ||,
  177.                'ICONVIEWPOS=40,20,55,65;'                          ||,
  178.                'ICONFONT=10.System VIO;'                           ||,
  179.                'ICONFILE='Directory()'\domain.ico;'                ||,
  180.                'ALWAYSSORT=YES'
  181.     Update   = 'Update'
  182.     Call CreateObj
  183.  
  184.     Class    = 'WPShadow'
  185.     Title    = '*Get from DC'
  186.     Location = '<LSMT_DCDB_'DomainName'>'
  187.     Setup    = 'SHADOWID=<LSMT_GETCMD>'
  188.     Update   = 'Update'
  189.     Call CreateObj
  190.  
  191.     Class    = 'WPShadow'
  192.     Title    = '*Set to DC'
  193.     Location = '<LSMT_DCDB_'DomainName'>'
  194.     Setup    = 'SHADOWID=<LSMT_SETCMD>'
  195.     Update   = 'Update'
  196.     Call CreateObj
  197.  
  198.     Class    = 'WPShadow'
  199.     Title    = '*Get All definitions'
  200.     Location = '<LSMT_DCDB_'DomainName'>'
  201.     Setup    = 'SHADOWID=<LSMT_GETALL>'
  202.     Update   = 'Update'
  203.     Call CreateObj
  204.  
  205.     Class    = 'WPShadow'
  206.     Title    = '*T2 Editor'
  207.     Location = '<LSMT_DCDB_'DomainName'>'
  208.     Setup    = 'SHADOWID=<LSMT_T2>'
  209.     Update   = 'Update'
  210.     Call CreateObj
  211.  
  212.     Return
  213.  
  214.  MAKEOUTPUTS:/* -------------------------------------------------------------*/
  215.  
  216.     Location = '<LSMT_DCDB_'DomainName'>'
  217.  
  218.  /* prepare text in case the output file does not exist */
  219.  
  220.     Text = '0A'x ' Just Drag & Drop me on the "<Get> from DC" Object'
  221.  
  222.     Do i = 1 to OUTPUT.0
  223.       FileName = Directory()'\'DomainName'\'Output.i
  224.       If Stream(FileName, 'C', 'Query Exists') = ''
  225.         Then Do
  226.                Call LineOut FileName, Text
  227.                Call Stream  FileName, 'C', 'Close'
  228.              End
  229.         Else Nop
  230.       Call SysSetObjectData FileName, 'ICONFILE='Directory()'\'ICO.i
  231.     /* Make Shadow of OutputFiles */
  232.       Call MakeShadow Output.i FileName Location
  233.     End
  234.  
  235.     LogFile = Directory()'\'DomainName'\LSMT.LOG'
  236.     If Stream(LogFile, 'C', 'Query Exists') = ''
  237.       Then Do
  238.              Call LineOut LogFile, '*** LSMT Installed on' Date('E') Time()
  239.              Call Stream  LogFile, 'C', 'Close'
  240.            End
  241.       Else Nop
  242.  
  243.     Call SysSetObjectData LogFile, 'ICONFILE='Directory()'\LOG.ICO'
  244.  
  245.  /* Make Shadow of LSMT.LOG */
  246.     Call MakeShadow 'LSMT.LOG' LogFile Location
  247.  
  248.     Return
  249.  
  250.  CHKDIR:/* ---------------------------------------------------- CHKDIR: ---*/
  251.  
  252.     Parse Arg Dir_Name
  253.  
  254.     RCode = 0                                      /* Reset the Return Code*/
  255.  
  256.     If Stream(Dir_Name, 'C', 'Query Exists') <> ''      /* is this a file ?*/
  257.       Then RCode = 1   /* Bad RC, there already exist a file with this name*/
  258.       Else Do
  259.              Call SysFileTree Dir_Name, 'DirExist', 'DO'/* does this DIR exist ?*/
  260.              If DirExist.0 = 0
  261.                Then Do
  262.                       RC = SysMKDir(Dir_Name)
  263.                       If RC <> 0
  264.                         Then RCode = 1
  265.                         Else Nop
  266.                     End
  267.                Else Nop
  268.            End
  269.  
  270.     If RCode = 1
  271.       Then Do
  272.              Say '! Error while creating' Dir_Name '07'x
  273.              Pull
  274.              Exit
  275.            End
  276.       Else Nop
  277.  
  278.     Return
  279.  
  280.  MAKESHADOW:/* --------------------------------------------------------------*/
  281.  
  282.     Parse Arg Title FileName Location
  283.  
  284.     If Stream(FileName, 'C', 'Query Exists') = ''
  285.       Then Nop
  286.       Else Do
  287.              Class    = 'WPShadow'
  288.              Title    =  Title
  289.              Location =  Location
  290.              Setup    = 'SHADOWID='FileName
  291.              Update   = 'Update'
  292.              Call CreateObj
  293.           End
  294.  
  295.     Return
  296.  
  297.  CREATEOBJ:/* ------------------------------------------------- CREATEOBJ: --*/
  298.  
  299.     Say '* Creating ...' Title
  300.  /*
  301.     Say 'Class    =' Class
  302.     Say 'Title    =' Title
  303.     Say 'Location =' Location
  304.     Say 'Setup    =' Setup
  305.     Say 'Update   =' Update
  306.   */
  307.     RC = SysCreateObject(Class, Title, Location, Setup, Update)
  308.     If RC <> 1
  309.       Then '! ErrorCode' RC Title '07'x
  310.       Else Nop
  311.  
  312.     Return
  313.  
  314.