안녕하세요? Openldap을 JSP에서 Entry 추가, 삭제, 변경하는 코드를 여기서 도움을 받아 어렵게 어렵게 하고 있습니다.
비밀번호 변경을 하는 코드를 작성하고 싶은데요...
modifyattributes 라는 걸로 하는 것 같더군요. 그런데 javadocs 찾아서 해봐도 잘 안되거든요... 도움부탁드립니다. 사용자가 자신의 암호를 변경하고자 할때 LDAP Server의 해당 Object에서 password를 변경하도록 하고 싶습니다.
코드는 아래와 같습니다.
-----------------
Hashtable env = new Hashtable(11);
// LDAP 서버 설정
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://isir.kaist.ac.kr:389/");
env.put(Context.SECURITY_PRINCIPAL, "cn=Manager,dc=kms,dc=kaist,dc=ac,dc=kr");
env.put(Context.SECURITY_CREDENTIALS, "kms123");
// request로 넘어온 값을 변수에 할당하여 LDAP Entry Attribute에 할당할 수 있도록 준비
String password= new String();
password= "1111";
//password= request.getParameter("password");
try {
DirContext ctx = new InitialDirContext(env);
Attributes attrs = new BasicAttributes(true);
//Attribute objclass = new BasicAttribute("objectclass");
Attribute passwd = new BasicAttribute("userPassword");
//objclass.add("uidObject");
passwd.add( password );
String ldapDN = new String();
ldapDN = "cn=" + userid + ",dc=kms,dc=kaist,dc=ac,dc=kr";
//Context result = ctx.createSubcontext (ldapDN, attrs);
ctx.modifyAttributes (ldapDN, REPLACE_ATTRIBUTE, attrs);
//ctx.modifyAttributes (ldapDN, 1, attrs);
//ctx.modifyAttributes ("userPassword", "cn=" + userid + ",dc=kms,dc=kaist,dc=ac,dc=kr");
//result.close();
ctx.close();
//response.sendRedirect( "member_insert_confirm.jsp" );
} catch (Exception e) {
out.println("에러 메시지: " + e);
}
------------------------------------
어디가 틀렸는지 모르겠습니다.
그럼 부탁드립니다. 꾸벅...
좋은 하루되세요...
simpact....
|