は、私はそれは私が私達のLDAP管理者が文句を言わないところ、私は必要なLDIFを見つけることを教えているので、私の要件には適用されないと思うLDIFのアプローチを使用しているSpringBoot hereSpringBoot、ldifを使用せずにLDAPで認証する方法は?
でLDAP認証の例をしようとしています。 springbootの前は、ldifを使用しない独自のLDAP実装を使用していました。 SECURITY_AUTHENTICATION.simpleだけでldifを使用しないことを検証する方法はありますか? 以下は、基本的なJavaでldapのセキュリティをどのように行うかです。基本的なユーザー名パスワードだけでldifを使わずに、春にどのようにすればいいですか?
boolean isLdapRegistred(String username, String password) {
boolean result = false;
try {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://10.x.x.x:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "OUR-DOMAIN\\" + username);
env.put(Context.SECURITY_CREDENTIALS, password);
// Create the initial context
DirContext ctx = new InitialDirContext(env);
result = ctx != null;
if (ctx != null)
ctx.close();
System.out.println(result);
return result;
} catch (Exception e) {
System.out.println("oops");
return result;
}
}
以下は、SpringBootsの例で、ldifの代わりに自分の資格情報を使用する必要があります。
LDIFなし@Configuration
protected static class AuthenticationConfiguration extends
GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource().ldif("classpath:test-server.ldif");
}
}
'.contextSource()。url(" ldap://10.xxx ").porを試したことがありますか? .contextSource()。ldif( "classpath:test-server.ldif"); '?の代わりにt(" 389 " – jny
FYI、@jny、 'port()'メソッドの入力パラメータは、Stringではなくintです。 –