Starting with a simple script

If you are new to scripting, Tcl, or both, you might want to experiment first with a few simple commands before trying to develop scripts that perform administrative tasks. The steps in this section are intended to help you get started.

If you are already familiar with scripting languages or with using Tcl, you might want to skip ahead to the discussion of the sample scripts or directly to the command reference.

To write a simple ADEdit script:

  1. Open a new file—for example, my_adedit_script—in a text editor.
  2. Type the following line to set up the adedit environment and include the ADedit Tcl library:
    #!/bin/env adedit
    package require ade_lib
    

    If your version of Linux or UNIX has the env command in a location other than the /bin directory, modify the first line to specify that directory. For example, another common location for the env command is /usr/bin. In this case, you would type:

    #!/usr/bin/env adedit
  3. Type an appropriate bind command to identify the Active Directory domain or domains to use.

    bind pistolas.org maya.garcia {$m1l3s88}

    Depending on whether you are going to run this script interactively or as an executable file, you might include or exclude authentication information.

  4. Type the appropriate commands to create and select a new zone.

    create_zone tree “cn=sample,cn=zones,ou=centrify,dc=acme,dc=com” std
    select_zone “cn=sample,cn=zones,ou=centrify,dc=acme,dc=com”
    
  5. Type the command to list the current zones to stdout to verify the new zone.

    list_zones pistolas.org
  6. Type the command to save the zone and quit.

    save_zone
    quit
    
  7. Save the text file and execute it using ADEdit or as an executable file.

    After you have tested the basic script, you edit it to create new zones, make a zone a child zone, add new zone computers, groups, or users. for example, you might add lines similar to these:

    new_zone_user AD_user_UPN
    set_zone_user_field field value
    save_zone_user
    list_zone_users
    

    If your sample script creates and selects a zone successfully, you should delete or rename the zone each time you iterate through the execution.

The following is a sample of what the simple script might look like:

#! /bin/env adeditpackage require ade_lib
bind pistolas.org maya.garcia {$m1l3s88}
create_zone tree "cn=test6,cn=zones,ou=centrify,dc=pistolas,dc=org" std
select_zone "cn=test6,cn=zones,ou=centrify,dc=pistolas,dc=org"
set_zone_field parent "cn=US-HQ,cn=zones,ou=centrify,dc=pistolas,dc=org"
list_zones pistolas.org
save_zone
new_zone_user tim@pistolas.org
set_zone_user_field uname tim
set_zone_user_field uid 81000
set_zone_user_field gid 81000
set_zone_user_field gecos "Tim Jackson, Accounting"
save_zone_user
list_zone_users
quit