Skip to content

Getting Groovy with SPML

March 31, 2006

Getting Groovy with SPML

For those of you interested in Groovy
and Identity
(thousands of people, right?), here is an example of
using Groovy with the OpenSPML
toolkit to delete/create a batch of users (for example, you might
use this to create a bunch of accounts for students in a lab).

// Sample Groovy script to delete/add a batch of users using the OpenSPML toolkit
// client handle to the spml connection is passed in to us from the caller
import org.openspml.message.*;
numusers = 1 // number of test users to create
println "Deleting Old Users…"
for(i in 1..numusers) { deleteUser(i,false) }
println "Adding Users.."
for(i in 1..numusers) { addUser(i) }
// Add a bulk user
def addUser(i) {
req = new AddRequest();
req.setAttributes( ["password.password":"xyzzy",
"global.firstname": "Spml",
"waveset.roles":["Basic Employee"],
"waveset.organization":"Top:Employees" ] );
// delete a user .
def deleteUser(i,throwErrors) {
req = new DeleteRequest();
response = client.request(req)
client.throwErrors( res)

There is a small piece of Java
scaffolding code (not shown) that creates the SPML connection, and
then invokes the groovy script. If any one is interested in the
code please feel free to get in touch.

Comments are closed.

%d bloggers like this: