Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populate LDAP with DB records

 
Chris Loschen
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm setting up some performance testing, and to do so, I need to set up a lot of dummy users and user groups. I've got a SQL script that does this quite well in our database, but our system checks against a SunOne LDAP server and when something is in the database but not in LDAP, it automatically disables it. My tests won't work if the user is not able to log in because they've been disabled... (sigh)

So I'm trying to figure out how to get these user and user groups from my database into the LDAP system. I was trying to just read the database and write each entry to LDAP if it doesn't already exist, and that might still work, but I've been having trouble getting the JDBC connection running properly outside of our usual container and so on.

An idea came up today that might be useful: if I could write an ldif file either from my database tables or maybe even while running the inital SQL script, I could then import the ldif file and get my entries that way.

My question(s): are there any tools or guidance for accomplishing writing that ldif file? Would I be better served by keeping with my initial path? Any suggestions for a better approach to my problem?

Thanks in advance!

Chris
 
Chris Loschen
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bounced... any ideas? Thanks.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What container are you using?
I'm using Weblogic and it has a script tool called WLST which can be used for all kinds of tasks, exporting and importing users from/to LDAP included.
 
Chris Loschen
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion!

I'm using WebLogic 9.2 and 10 -- eventually JBoss too.

I'm already using WLST to automate domain creation, but I hadn't thought it would have any use here. I've got users and groups in my Oracle database tables (the results of my SQL scripts), but not in LDAP. In WebLogic, I see the users and groups that are in LDAP (or any other authenticators I have set up), but I don't see anything from my database there, or at least I don't think I do. So how would WebLogic import the data if it can't see it?

Chris
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WLST is a Python shell, and it has Jython so whatever Python and Java can do (i.e. database access), WLST can do.
Unfortunately, I don't know of a shortcut to get an LDIF out of the database. Once you do, it's pretty simple to import it to the database using the authenticator importData method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic