こんにちは私はLdapで簡単なログインを作成する際に問題があります。私はspring.ioのWebサイトからプロジェクトを始めてダウンロードしました:linkこれはldifファイルと完全に連携していますが、ldapサーバーを実行しているものと置き換えたいと思います。私は何の進歩もなくそれを試しました。私は私が形式で良いユーザ名とパスワードでログインしようとした場合、「ユーザー名」(プロジェクトを開始したばかりのWebSecurityConfigに置き換え)コードのこの作品春のブートldapセキュリティ
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception {
authManagerBuilder.authenticationProvider(activeDirectoryLdapAuthenticationProvider()).userDetailsService(userDetailsService());
}
@Bean
public AuthenticationManager authenticationManager() {
return new ProviderManager(Arrays.asList(activeDirectoryLdapAuthenticationProvider()));
}
@Bean
public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(null, "ldap://ip:port/", "ou=GROUP,dc=domain,dc=com");
provider.setConvertSubErrorCodesToExceptions(true);
provider.setUseAuthenticationRequestCredentials(true);
return provider;
}
}
で最高の結果を得る「パスワード」コンソール出力:ActiveDirectoryLdapAuthenticationProvider:Active Directoryの認証に失敗しました:提供されたパスワードが無効です
"[email protected]"と良いパスワードを使用すると、ページはコンソールに出力されずにリロードされます。
私は、ランダムなユーザ名とパスワードのコンソールを使用する場合:指定されたパスワードは
無効でした誰かが助けることができます:Active Directory認証に失敗しましたか?
あなたがActiveDirectoryLdapAuthenticationProviderのコンストラクタでドメインの「ヌル」を使用するように、あなたが を認証するために「のuserPrincipalName」([email protected])を使用する必要がありますが、これは動作しない理由を見つけるためにログをオンにしたり、 LDAPSまたはStartTLS拡張操作を使用しない場合、ネットワークトレースはLDAP BIND要求が成功したかどうかを確認します –