我通过Spring读取LDAP reference docs,并且无法确定针对LDAP服务器的用户认证是否自动执行。春季LDAP认证(自动或不是?)
“自动化”我的意思是,如果您在您的ContextSource
中提供了userDn和密码,它会自动发生在bean实例化中。也就是说,程序员永远不需要拨打LdapTemplate.authenticate(...)
- 它发生在“幕后”。
所以我想知道
- 如果春天LDAP身份验证自动
- 如果有域,我可以设置为改变这种行为
感谢,
KTM
编辑:我问这个问题在我编写的一些代码的上下文中。以下ContextSource
是我的beans文件中的一个上下文源,用户可以选择使用它。它用于在运行时配置userDn和密码(出于安全原因)。我想知道LDAP应用程序是否实际使用我在验证中在运行时收集的userDn /密码。 (有没有认证之前我的代码的执行?是否忽略了我的代码配置的用户DN /密码字段?)
public class RuntimeContext extends LdapContextSource {
public RuntimeContext() {
super();
if (!resolveAuthInfo()) {
System.out.println("Failed to resolve auth info. Exiting...");
System.exit(1);
}
}
public boolean resolveAuthInfo()
{
String myUserDn, myPassword;
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
System.out.print("userDn: ");
myUserDn = br.readLine();
System.out.print("password: ");
myPassword = br.readLine();
} catch (IOException e) {
return false;
}
super.setUserDn(myUserDn);
super.setPassword(myPassword);
return true;
}
}
添加了一些相关的源代码 – ktm5124 2011-01-25 19:27:04