差異處
這裏顯示兩個版本的差異處。
java:ldap:spring [2016/05/08 23:29] tony [Articles] |
java:ldap:spring [2023/06/25 09:48] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | {{tag>ldap spring spring-ldap spring-security}} | + | |
- | ====== LDAP with Spring API ====== | + | |
- | ===== Articles ===== | + | |
- | * [[java:ldap:spring:simpleAuthentication|Simple Authentication]] SSL and StartTLS | + | |
- | * [[java:ldap:spring:object-relation|Spring-Security with LDAP物件關係]](整理中) | + | |
- | * ActiveDirectoryLdapAuthenticationProvider | + | |
- | * [[java:ldap:spring:ActiveDirectoryLdapAuthenticationProvider:supportSAMOfADProvider|Support SAM-Account-Name]] | + | |
- | * [[java:ldap:spring:ActiveDirectoryLdapAuthenticationProvider:supportTLS|Support TLS]] | + | |
- | * LdapAuthenticationProvider | + | |
- | * [[java:ldap:spring:LdapAuthenticationProvider|如何透過LDAP做認證?]] | + | |
- | * [[java:ldap:spring:LdapAuthenticationProvider:tls|Support TLS]] | + | |
- | * [[java:ldap:spring:LdapAuthenticationProvider:anonymousWithTLS|Support TLS with anonymous login]] | + | |
- | ==== Search AD User and Groups ==== | + | |
- | <code java> | + | |
- | LdapContextSource contextSource = new DefaultSpringSecurityContextSource("ldap://10.134.15.138:389"); | + | |
- | contextSource.setBase("DC=TEST,DC=SSM"); | + | |
- | contextSource.setUserDn("test@TEST.SSM"); | + | |
- | contextSource.setPassword("123456"); | + | |
- | DirContextAuthenticationStrategy strategy = createTLSStrategy(); | + | |
- | contextSource.setAuthenticationStrategy(strategy); | + | |
- | contextSource.afterPropertiesSet(); | + | |
- | + | ||
- | LdapTemplate ldapTemplate = new LdapTemplate(contextSource); | + | |
- | ldapTemplate.afterPropertiesSet(); | + | |
- | + | ||
- | SearchControls sc = new SearchControls(); | + | |
- | sc.setSearchScope(SearchControls.SUBTREE_SCOPE); | + | |
- | + | ||
- | ldapTemplate.search("cn=Users", "(objectclass=group)", sc, new NameClassPairCallbackHandler() { | + | |
- | + | ||
- | @Override | + | |
- | public void handleNameClassPair(NameClassPair nameClassPair) { | + | |
- | System.out.println(nameClassPair.getName()); | + | |
- | } | + | |
- | }); | + | |
- | </code> | + | |
- | ===== To Do ===== | + | |
- | * Write: AD Provider支援TLS。 | + | |
- | * Write: LDAP Provider Login with anonymous支援TLS。 | + | |
- | * Write: SSL with HostVerifier。 | + | |
- | * Write: Login LDAP with FullDN。 | + | |
- | * Study: Connection Pool for TLS。 | + | |
- | ===== Resource ===== | + | |
- | * [[http://stackoverflow.com/questions/32501853/catch-communicationexception-from-spring-security|catch-communicationexception-from-spring-security]] | + | |
- | * [[http://docs.spring.io/spring-ldap/docs/current/reference/#introduction|spring-ldap docs]] | + |