title: Spring LDAP - Creation of LdapTemplate in standalone java program - Using Spring LDAP as CDI Resource
body: <p>I am trying to construct a LdapTemplate object of using spring data. </p>
  
  <pre><code> public class LDAPTemplate {
  
          public static void main(String[] args) {
              LdapContextSource lcs = new LdapContextSource();
              lcs.setUrl("ldap://localhost:389/");
              lcs.setUserDn("cn=Manager, dc=example, dc=com");
              lcs.setPassword("secret1");
              lcs.setDirObjectFactory(DefaultDirObjectFactory.class);
              LdapTemplate ldap = new LdapTemplate(lcs);
              ldap.lookup("cn=aaa");
  
          }
  
      }
  </code></pre>
  
  <p>I wanted to know is that the right way to instantiate ldap template object. Because when I perform a lookup, it throws NPE. </p>
  
  <p>I am trying to use LDAP Spring in CDI context without using spring at all. If you have pointers on that would be nice. Does Spring LDAP is dependent on spring?</p>