Using VBScript

In most cases, you can use VBScript to write scripts that call the Centrify Windows API.

The following steps illustrate how to create and run a VBScript script that uses the Centrify Windows API. This sample script opens a zone and lists all the users in it.

  1. Verify that the computer you are using has Access Manager console or the Centrify Windows API Runtime environment from the Centrify SDK installed.
  2. Verify that the computer you are using is a member of the Active Directory domain you want to work with.
  3. Log in as a domain user with permission to read the zone data for the zone you will be listing.

    If you can list the users in the zone using the Access Manager console with the credentials provided, you have the correct permissions. For information about configuring a user’s rights to read zone data, see the Planning and Deployment Guide.

  4. Use a text editor to create a file called zone-list.vbs.
  5. Add the following text to zone-list.vbs, replacing the domain_name and the path to the zone with a domain name and zone location appropriate for your environment.

    set cims = CreateObject("Centrify.DirectControl.Cims3")
    set zone = cims.GetZone("domain_name/zone_path/zone_name")
    set users = zone.GetUserUnixProfiles()

    for each user in users
    if (user.IsNameDefined) then
    name = user.Name
    else
    name = "<Empty>"
    end if

    if (user.IsUidDefined) then
    uid = user.Uid
    else
    uid = "<Empty>"
    end if

    wscript.echo name & " | " & uid
    next

    For example if you are using the domain test.acme.com and want to list users in the “default” zone in its default container location:

    set zone = cims.getzone("test.acme.com/program data/centrify/zones/default")
    for each user in users
    wscript.echo user.name, user.Uid
    next
  6. Click Start > Run, then type cmd to open a command window.
  7. Change directory to the location of the VBScript file and type:

    cscript zone-list.vbs

    You should see output similar to the following:

    C:\>cscript zone-list.vbs
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    jane 10000
    jim.smit 10002
    jimsmith 10003
    joe 10004
    paul 10006
    rachel 10016