i use 2 differents ldap configuration in application. file application.yml :
management: context-path: /management health: mail: enabled: false # when using mailservice, configure smtp server , set true spring: application: name: matrice2 profiles: # commented value `active` can replaced valid spring profiles load. # otherwise, filled in maven when building war file # either way, can overridden `--spring.profiles.active` value passed in commandline or `-dspring.profiles.active` set in `java_opts` active: #spring.profiles.active# jpa: open-in-view: false hibernate: ddl-auto: none naming-strategy: org.springframework.boot.orm.jpa.hibernate.springnamingstrategy messages: basename: i18n/messages mvc: favicon: enabled: false thymeleaf: mode: xhtml security: basic: enabled: false jhipster: async: corepoolsize: 2 maxpoolsize: 50 queuecapacity: 10000 mail: from: matrice2@localhost swagger: title: matrice2 api description: matrice2 api documentation version: 0.0.1 termsofserviceurl: contactname: contacturl: contactemail: license: licenseurl: ldap: url: ldap://ldap.east.app.company.com:389 base: dc=west,dc=app,dc=company,dc=com manager: dn: cn=toto,ou=cds,ou=company_commun,dc=west,dc=app,dc=company,dc=com password: toto grpadmin : grp_project_admin grpuser : grp_project_admin ldap: url: ldap://ba-dc1.app.company.com:389 base: dc=app,dc=company,dc=com manager: dn: cn=ad_c_s,ou=c_d_s,dc=app,dc=company,dc=com password: toto!service grpadmin : grp_project_admin grpuser : grp_project_admin
and mistakes :
exception in thread "restartedmain" java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ org.springframework.boot.devtools.restart.restartlauncher.run(restartlauncher.java:49) caused by: while parsing mappingnode in 'reader', line 14, column 1: management: duplicate key : ldap in 'reader', line 97, column 1.
is there way have multiple configuration ldap ?? have idea ??
thanks
we had similar problem. you'll have enroll own websecurityconfig
make work own @configproperies
. approach not ideal cause needs code change if change amount of ldap servers want authenticate against shouldn't big problem. since our systems credentials same have 1 ldap settings, maybe you'll have tweak this. should give hint.
application.yaml
ldap: amurl: ldaps://us-server emeaurl: ldaps://eu-server bindcn: cn=blah,ou=blah,dc=blah,dc=local bindpass: my-secret-password
securityconfigproperties
@data @configurationproperties(prefix = "ldap") public class securityconfigproperties { private string emealdapurl; private string amldapurl; private int ldapport; private string bindcn; private string bindpass; }
securityconfig
@configuration public class securityconfig extends websecurityconfigureradapter { // don't hit me oli! @autowired private securityconfigproperties conf; @autowired public void configureglobal(authenticationmanagerbuilder authbuilder) throws exception { authbuilder .ldapauthentication() .usersearchfilter("(samaccountname={0})") .usersearchbase("dc=am,dc=blah,dc=local") .groupsearchbase("ou=groups,dc=am,dc=blah,dc=local") .groupsearchfilter("member={0}") .contextsource() .url(conf.getamldapurl()) .managerdn(conf.getbindcn()) .managerpassword(conf.getbindpass()) .and() .and() .ldapauthentication() .usersearchfilter("(samaccountname={0})") .usersearchbase("dc=emea,dc=blah,dc=local") .groupsearchbase("ou=groups,dc=emea,dc=blah,dc=local") .groupsearchfilter("member={0}") .contextsource() .url(conf.getemealdapurl()) .managerdn(conf.getbindcn()) .managerpassword(conf.getbindpass()) ; } }
hope helps!
Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog.
ReplyDeleteIt is very nicely explained. Your article adds best knowledge to our Java Online Training from India.
or learn thru Java Online Training from India Students.