Using Jython to create users

April 4, 2008 at 4:51 pm | Posted in Jython | 2 Comments

A while back Bex Huff posted about using Jython to script Documentum tasks. I referenced that post in one of the answers I gave on the forums however I had never used Jython at that point. I made a note to try it out and so this post represents the beginning of my investigation. Consider a journey, possibly once started that never finishes….

First up you should be able to install Jython on any platform that runs Documentum (well any platform that runs DFC which is more or less the same thing). You can get the low down on the JPython site but the quick install steps are:

1) Download the installation, typically a file like jython_installer-2.2.1.jar
2) Execute the jar (there are command line invocations if you need it check on the web for details) to install.
3) For convenience add the installation path (e.g. c:\jython2.2.1)

All the instructions are based on a windows platform for convenience. It should translate to *nix without too much bother; I may try this out on a handy copy of Red Hat to confirm (but don’t hold your breath for that post!).

You could now run the Jython command interpreter in the following way:

1) start a command prompt
2) type ‘jython’

The following code will create a user called inline_user (it assumes you have a JRE of 1.4.2 or greater and DFC installed):

from import DfClientX

clientx = DfClientX()
client  = clientx.getLocalClient()
li      = clientx.getLoginInfo()
li.setUser("dmadmin")            # login as installation owner
li.setPassword("dmadmin")         # insert install owner password here
s0      = client.newSession("fnet1",li)

print "Connected as dmadmin"

print "now creating user ..."

u = s0.newObject("dm_user")
# because we have to
u.setUserSourceAsString("inline password")
# IDfUser.setPassword seems to be missing from DFC5.3!!!

print "user inline_user has been created"

This code can either be typed directly into the Jython command line interface (a great way to test out dfc code snippets) or can be copied into a script file e.g. and called from the command line like this:


Hopefully the user has been created sucessfully and you should now be able to test the login from the command line:

li2 = clientx.getLoginInfo()
s1 = client.newSession("fnet1",li2)
print "connected as " + s1.connectionConfig.getLoginUserName()

OK so this is a very simple example. There is no use of command line parameters, no user input, no functions and so on. Hopefully I’ll get round to further posts that expand and show examples of this. In the meantime enjoy.



RSS feed for comments on this post. TrackBack URI

  1. I always look forward to your blogs. Its been a while since I saw a new entry, about 3 months. Good to see this post.

  2. Yes, I have been pretty busy over the last 3 or 4 months but I hope to get down to some serious blogging on a regular basis. In particular I’d like to find the time to expand on the jython theme. With D6 coming along and removing DMCL I think it is time to look for alternatives to iapi. Repoint is a useful tool but I really love the command line stuff as it is so quick for testing out different ideas; and jython allows you to try stuff that you might later do directly in java.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at
Entries and comments feeds.

%d bloggers like this: