title: How to change spring security from ldap to ldap starttls
body: <p>How to change spring security  from ldap to ldap starttls.</p>
  
  <p>I am writing a project in Springs using Spring Security and LDAP.  I had everything working great and then the admin changed it to ldap with starttls.  Can someone please show me how to update my xml file to get my project working again.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jdbc="http://www.springframework.org/schema/jdbc"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
             http://www.springframework.org/schema/jdbc
             http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
             http://www.springframework.org/schema/security
             http://www.springframework.org/schema/security/spring-security-3.0.xsd"
      xmlns="http://www.springframework.org/schema/security" &gt;
  
      &lt;http
          auto-config="true"
          use-expressions="true" &gt;
  
          &lt;intercept-url
              access="hasRole('ROLE_MEMBER_INQUIRY')"
              pattern="/requests/**" /&gt;
  
      &lt;/http&gt;
  
      &lt;authentication-manager &gt;
  
          &lt;ldap-authentication-provider
              user-search-base="ou=webusers"
              user-search-filter="(uid={0})" &gt;
  
              &lt;password-compare &gt;
  
                  &lt;password-encoder ref="passwordEncoder" &gt;
                  &lt;/password-encoder&gt;
              &lt;/password-compare&gt;
          &lt;/ldap-authentication-provider&gt;
      &lt;/authentication-manager&gt;
  
      &lt;beans:bean
          id="passwordEncoder"
          class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" &gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean
          id="contextSource"
          class="org.springframework.security.ldap.DefaultSpringSecurityContextSource" &gt;
  
          &lt;beans:constructor-arg value="ldap://10.52.208.228:389/dc=xxxxx,dc=dev" /&gt;
  
          &lt;beans:property
              name="userDn"
              value="cn=Manager,dc=xxxxx,dc=dev" /&gt;
  
          &lt;beans:property
              name="password"
              value="secret" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean
          id="ldapAuthProvider"
          class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider" &gt;
  
          &lt;beans:constructor-arg &gt;
  
              &lt;beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator" &gt;
  
                  &lt;beans:constructor-arg ref="contextSource" /&gt;
  
                  &lt;beans:property name="userDnPatterns" &gt;
  
                      &lt;beans:list &gt;
  
                          &lt;beans:value &gt;
  
  uid={0},ou=webusers
  
                          &lt;/beans:value&gt;
                      &lt;/beans:list&gt;
                  &lt;/beans:property&gt;
              &lt;/beans:bean&gt;
          &lt;/beans:constructor-arg&gt;
  
          &lt;beans:constructor-arg &gt;
  
              &lt;beans:bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator" &gt;
  
                  &lt;beans:constructor-arg ref="contextSource" /&gt;
  
                  &lt;beans:constructor-arg value="ou=groups" /&gt;
  
                  &lt;beans:property
                      name="groupRoleAttribute"
                      value="ou" /&gt;
              &lt;/beans:bean&gt;
          &lt;/beans:constructor-arg&gt;
      &lt;/beans:bean&gt;
  
      &lt;ldap-server url="ldap://10.52.208.228:389/dc=xxxxx,dc=dev" /&gt;
  
      &lt;beans:bean
          id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" &gt;
  
          &lt;beans:property
              name="location"
              value="classpath:jdbc.properties" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean
          id="dataSource"
          class="org.apache.commons.dbcp.BasicDataSource" &gt;
  
          &lt;beans:property
              name="driverClassName"
              value="${database.driver}" /&gt;
  
          &lt;beans:property
              name="url"
              value="${database.url}" /&gt;
  
          &lt;beans:property
              name="username"
              value="${database.user}" /&gt;
  
          &lt;beans:property
              name="password"
              value="${database.password}" /&gt;
  
          &lt;beans:property
              name="initialSize"
              value="5" /&gt;
  
          &lt;beans:property
              name="maxActive"
              value="10" /&gt;
      &lt;/beans:bean&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>