這是本文件的舊版!
Spring-Security with LDAP中,物件的關係
在透過spring-security將LDAP功能整到Web登入時,如果透過程式碼配置的方式,會去extend WebSecurityConfigurerAdapter。其中的configure的method,可以讓你配置AuthenticationProvider:
@Override protected void configure(AuthenticationManagerBuilder aAuth) throws Exception { // 相關配置 }AuthenticationManagerBuilder是用來建立你所需要的AuthenticationProvider,其中我有使用到的兩個builder:
- jdbcAuthentication(): 去透過資料庫做驗證。
- ldapAuthentication(): 透過Ldap做驗證。
如果要用AD做驗證:
- authenticationProvider(): 透過其它的AuthenticationProvider做驗證。
ActiveDirectoryLdapAuthenticationProvider adProvider = new ActiveDirectoryLdapAuthenticationProvider(domain, url); aAuth.authenticationProvider(adProvider);