Açıklaması şöyle.
constructor
Elimizde application.yml dosyası olsun.
Şöyle yaparız.
Şöyle yaparız.
ContextSource is used for creating the LdapTemplate.
Maven
Şu satırı dahil ederiz
<dependency><groupId>org.springframework.ldap</groupId><artifactId>spring-ldap-core</artifactId></dependency>
Elimizde application.yml dosyası olsun.
ldap:
 contextSource:
   url: ldap://192.168.113:389 #Local
   base: dc=test,dc=test
   userDn: cn=admin,dc=test,dc=test
   password: test2019!@@Configuration
public class LdapConfiguration {
  @Bean
  @ConfigurationProperties(prefix="ldap.context-source")
  public LdapContextSource contextSource() {
    return new LdapContextSource();
  }
 @Bean
 public ContextSource poolingLdapContextSource() {
   PoolingContextSource pcs = new PoolingContextSource();
   pcs.setDirContextValidator(new DefaultDirContextValidator());
   pcs.setContextSource(contextSource());
  TransactionAwareContextSourceProxy proxy = new TransactionAwareContextSourceProxy(pcs);
   return proxy;
  }
  // other configs like ldaptemplate
}Şöyle yaparız.
@Bean
public ContextSource contextSource() {
  LdapContextSource contextSource = new LdapContextSource();
  contextSource.setUrl("ldap://...");
  contextSource.setBase("dc=test,dc=test");
  contextSource.setUserDn("cn=admin,dc=test,dc=test");
  contextSource.setPassword("test2019!@");
  contextSource.afterPropertiesSet();
  PoolingContextSource pcs = new PoolingContextSource();
  pcs.setDirContextValidator(new DefaultDirContextValidator());
  pcs.setContextSource(contextSource);
  TransactionAwareContextSourceProxy proxy = new TransactionAwareContextSourceProxy(pcs);
  return proxy;
}Şöyle yaparız.
contextSource.setUrl("ldap://192.168.113.12:389"); 
Hiç yorum yok:
Yorum Gönder