Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to include LDAP updates and database access in one transaction?  RSS feed

Robert Strong
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm using BEA Weblogic8.1, I'm coding a Stateless Session Bean, used for Signup, there a user's account should be created in both LDAP and Oracle Database. XA JDBC driver used, with <trans-attribute>Required</trans-attribute> specified in ejb-jar.xml.

if that account already exists in database table, the transaction would rollback, but an entry still created in LDAP. so, it seems LDAP operations and database access cannot be grouped into one distributed transaction?

my code is like below:
ht.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
ht.put(Context.PROVIDER_URL, "ldap://tiger:7001");
ht.put(Context.SECURITY_AUTHENTICATION, "simple");
ht.put(Context.SECURITY_PRINCIPAL, "cn=Admin");
ht.put(Context.SECURITY_CREDENTIALS, "xxxxx");
dirCtx = new InitialDirContext(ht);

Attributes attrNew = new BasicAttributes(true);
Attribute oc = new BasicAttribute("objectclass");
Attribute ouSet = new BasicAttribute("ou");


attrNew.put("wlsMemberOf", "cn=bigrez_staffs,ou=groups,ou=myrealm,dc=bigrezdomain");
attrNew.put("sn", staffVO.getName());
attrNew.put("uid", staffVO.getEmail());
attrNew.put("cn", staffVO.getEmail());
String pwd = "test";
attrNew.put("userpassword", pwd.getBytes());

///add new entry
dirCtx.createSubcontext("cn=" + staffVO.getEmail() + ",ou=people,ou=myrealm,dc=bigrezdomain", attrNew);

StaffEntityHomeLocal staffEntityHomeLocal = (StaffEntityHomeLocal)Locator.getHome("StaffEntity");

Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no such thing as transactions in the LDAP world, so you're pretty much on your own here. E.g. you could try creating the entity bean first and then only create the LDAP entry if the previous operation was successful.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!