Skip to content

Getting Groovy with SPML

March 31, 2006





Getting Groovy with SPML






For those of you interested in Groovy
and Identity
Manager
(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.setIdentifier("spmltest${i}");
req.setObjectClass("userview");
req.setAttributes( ["password.password":"xyzzy",
"global.email":"spmltest@acme.com",
"global.firstname": "Spml",
"global.lastname":"Test${i}",
"global.manager":"warren",
"waveset.roles":["Basic Employee"],
"waveset.organization":"Top:Employees" ] );
client.throwErrors(client.request(req))
}
// delete a user .
def deleteUser(i,throwErrors) {
req = new DeleteRequest();
req.setIdentifier("spmltest${i}");
response = client.request(req)
if(throwErrors)
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.










Advertisements

Comments are closed.

%d bloggers like this: