Announcement Announcement Module
Collapse
No announcement yet.
LDAP Transactions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LDAP Transactions

    Hi everybody.
    I'm new in LDAP, and I've been looking for information about LDAP Transactions but I have not been successful.
    I need to use transaction with Spring to LDAP, and just I have seen the mention of the ContextSourceTransactionManager and ContextSourceAndDataSourceTransactionManager classes but I have not seen how to use them. Could somebody help me please?
    Thanks

  • #2
    Have you checked the reference documentation?

    You might also want to have a look at the transaction chapter of the spring reference documentation.

    If you have any specific questions after this I'll try my best to help.

    Comment


    • #3
      Hi rasky

      Thanks for the url. I have already read previously the sites that you recommend.

      In the Reference Documentation I saw that the manner of update my configuration file, and my question is What are the changes that I have to do into my main class? I mean, the use of "commit" or "rollback" actions.

      Comment


      • #4
        I've not yet used this myself (although I am hoping to use it soon on a project), but I'd presume Mattias's point is thiat you are dealing with a transaction manager. You would therefore configure and use it in exactly the same way you would for JDBC via something like DataSourceTransactionManager.
        Last edited by karldmoore; Aug 29th, 2007, 11:25 AM.

        Comment


        • #5
          In fact, I'm a little confused. I'm following the Spring LDAP Reference Documentation, the Transaction Support topic for LDAP transactions, and I made the changes in my xml file (declarative), but my question is if I have to make changes in my code too (programatic).

          Comment


          • #6
            Provided you've configured it properly you shouldn't have to worry about this in your code - it all works automagically.

            Comment


            • #7
              Ok Mattias, thank you for all, I like that it all works automagically :-D, and How can I do tests with the rollback action? Must I handle some Exception in my code?

              Comment


              • #8
                You don't have to handle Exceptions specifically. The default behaviour is that the current transaction will be rolled back in the case of an Exception.

                Comment


                • #9
                  I did all necesary in my configuration file and didn't work, I don't know why, I forced my application to fail and the roll back didn't work. I will try to do the programmatic form, but I'm in the same situation, I don't find an sample about it.
                  Thanks Mattias and Karldmoore

                  Comment


                  • #10
                    Please post your configuration and we'll have a look. Use the [code][/code] tags.

                    Comment


                    • #11
                      Hi! Here is my configuration:

                      Code:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
                      
                      <beans>
                          <bean id="contextSourceTarget"
                              class="org.springframework.ldap.core.support.LdapContextSource">
                      		<property name="url" value="ldap://x.x.x:389" />
                              <property name="base" value="o=sigmatao,c=MX" />
                              <property name="userName" value="cn=xxxxx" />
                              <property name="password" value="xxxxx" />
                          </bean>
                          
                          <bean id="contextSource"
                              class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
                      		<constructor-arg ref="contextSourceTarget" />
                      	</bean>
                      
                          <bean id="ldapTemplate" 
                          	class="org.springframework.ldap.core.LdapTemplate">
                              <constructor-arg ref="contextSource" />
                          </bean>
                             
                         <bean id="transactionManager" 
                                  class="org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager">
                            <constructor-arg ref="contextSource" />
                         </bean>
                         
                         <bean id="myDataAccessObjectTarget" class="sigmatao.com.PerfilDaoImpl">
                            <property name="ldapTemplate" ref="ldapTemplate" />
                         </bean>
                         
                      
                      	<bean id="myDataAccessObject"
                      		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
                      		<property name="transactionManager" ref="transactionManager" />
                      		<property name="target" ref="myDataAccessObjectTarget" />
                         		<property name="transactionAttributes">
                      			<props>
                      				<prop key="create">PROPAGATION_SUPPORTS</prop>
                      				<prop key="delete">PROPAGATION_SUPPORTS</prop>
                      				<prop key="update">PROPAGATION_SUPPORTS</prop>
                      				<prop key="getAllPerfilCuentas">PROPAGATION_REQUIRED,readOnly</prop>
                      			</props>
                      		</property>
                      	</bean>
                      </beans>
                      Last edited by sacara; Jul 5th, 2007, 11:36 AM.

                      Comment


                      • #12
                        Is it possible to see the test code you are running as well?
                        Last edited by karldmoore; Aug 29th, 2007, 11:25 AM.

                        Comment


                        • #13
                          Yes, here is my code:

                          Code:
                          resource = new ClassPathResource("testContext.xml");
                          factory = new XmlBeanFactory(resource);
                          ldapContact = (ProfileDaoImpl)factory.getBean("myDataAccessObjectTarget");
                          
                          Profile p1 = new Profile();
                          p1.setCn("Alexis Moreno");
                          p1.setCt("1116");
                          p1.setMail("[email protected]");
                          p1.setSn("Alexis");
                          p1.setTelephoneNumber("22666666");
                          
                          ldapContact.create(p1, "tablename");
                          
                          In ProfileDaoImpl:
                          
                          public void create(Profile p, String clase){
                              private LdapTemplate ldapTemplate;
                              ldapTemplate.bind(construyeDn(p), null, profileAttributes);
                          }

                          Comment


                          • #14
                            I've been thinking about that the best manner of control my transactions is the programmatically manner, isn't it? well, I've been reading information about it and some examples aren't clear. I've been reading the Transaction Management Spring framework, and http://forum.springframework.org/arc...p/t-34112.html forum and I have not seen an concrete sample about the use of ContextSourceAndDataSourceTransactionManager class. I need to do transactions with LDAP and JDBC. Help me!
                            Thanks.

                            Comment


                            • #15
                              There is an integration test for transactions involving LDAP and JDBC. Perhaps that might be of some help to you. The context file is here and the test code is here.

                              You'll find the same code in the buildable distribution.

                              Comment

                              Working...
                              X