String strUserName = "";
String strPassWord = "";
strUserName = (String) httpservletrequest.getParameter("username");
strPassWord = (String) httpservletrequest.getParameter("password");
SysPara syspara = new SysPara();
syspara.initPara();
boolean islogin = false;
Hashtable env = new Hashtable(11);
env.put("java.naming.factory.initial","com.sun.jndi.ldap.LdapCtxFactory");
String strLDAP = (new StringBuilder("LDAP:").append("//")).append(
syspara.getLdap_host()).append(":").append(
syspara.getLdap_port()).append("/O=").append(syspara.getOrg()).toString();
env.put("java.naming.provider.url", strLDAP);
env.put("java.naming.security.authentication", "simple");
String strFullName = (new StringBuilder("CN=")).append(strUserName).append(",O=").append(syspara.getOrg()).toString();
env.put("java.naming.security.principal", strFullName);
env.put("java.naming.security.credentials", strPassWord);
try {
DirContext ctx = new InitialDirContext(env);
Session session = NotesFactory.createSession((new StringBuilder(String.valueOf(syspara.getLdap_host()))).append(":").append(String.valueOf(syspara.getDiiop_port())).toString(), strUserName, strPassWord);
ctx.close();
islogin = true;
if (session.getUserName() == null|| session.getUserName().equalsIgnoreCase("Anonymous"))
islogin = false;
usernamd = session.getUserName().toString();
httpsession.setAttribute("userid", strUserName);
if(httpsession.getAttribute("NFSession")==null){
httpsession.setAttribute("NFSession", session);
}
} catch (AuthenticationException e) {
System.err.println((new StringBuilder(
AuthenticationException验证失败:")).append(e).toString());
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}这段代码,我用中文名登录可以,用英文名登陆就报这个错,
AuthenticationException验证失败:javax.naming.AuthenticationException: [LDAP: error code 49 - Failed, invalid credentials for CN=xuhm,O=ldbzj] 但是我在控制台那边的人员信息,已经设置了中英文名字,即使我把所有用户名都改为英文,再用英文登录页不行,这是为什么啊,哪位高手帮忙下啊。
------解决方案--------------------
1. 设置服务器文档的安全性的选项:
Internet authentication: More name variations with lower security
2. restart task http
------解决方案--------------------