问题描述
我正在尝试使用 squid 代理连接到 ldap
服务器。
如何通过squid代理连接ldap
服务器?
如何设置代理服务器信息?
spring boot 代码如下。
@Bean
public LdapContextSource ldapContextSource() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl);
contextSource.setUserDn(ldapUsername);
contextSource.setPassword(ldapPassword);
return contextSource;
}
.......
public boolean getLdapBindAuthentication(String userName,String userPassword) {
boolean authed = false;
try {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl);
contextSource.setBase(ldapBasedn);
contextSource.setUserDn(ldapUsername);
contextSource.setPassword(ldapPassword);
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.afterPropertiesSet();
// Perform the authentication.
Filter filter = new EqualsFilter("sAMAccountName",userName);
authed = ldapTemplate.authenticate("",filter.encode(),userPassword);
} catch (Exception e) {
throw new InternalAuthenticationServiceException("login Failed",e);
}
return authed;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)