• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

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

Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");

Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
    Bookmark Topic Watch Topic
  • New Topic