JAVA 초보 개발자 입니다. LDAP에 대해서는 거의 모르는 상태라고 보셔두 되구요
LDAP 이용해서(?)지금 JAVA로 AD에 있는 사용자 정보를 가져오려고 하는데요
샘플코드를 받아서 제가 저의 컴퓨터 서버에 맞게 살짝 수정하였습니다.
server 컴퓨터는 window 2008 서버 이구요 거기에 AD를 설치해 놓았습니다.
코드는 다음과 같습니다.
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
public class aa{
public static void main(String[] args) {
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"LDAP://125.7.235.123:389"); //replace with your server URL/IP
//only DIGEST-MD5 works with our Windows Active Directory
env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5");
//No other SALS worked with me
env.put(Context.SECURITY_PRINCIPAL, "cn=dev");
// specify the username ONLY to let Microsoft Happy
env.put(Context.SECURITY_CREDENTIALS, "test12#");
//the password
DirContext ctx = new InitialDirContext(env);
ctx.close();
} catch(NamingException ne) {
System.out.println("Error authenticating user:");
System.out.println(ne.getMessage());
return;
}
//if no exception, the user is already authenticated.
System.out.println("OK, successfully authenticating user");
}
}
이 코드인데요 자꾸만 에러가 나는데요
Error authenticating user:
[LDAP: error code 49 - 8009030C: LdapErr: DSID-0C0904D1, comment: AcceptSecurityContext error, data 52e, v1771
이 에러가 납니다. 왜 그러는지 알 수 있나요?
제가 LDAP을 처음 해봐서 그러는데 AD에 제가 어떤 설정을 안해줘서 그런건지
혹은 제가 가져오려는 client에 JAR파일 말고 다른 어떤게 필요한지 알고 싶습니다.
LDAP 에서 JAVA로 사용자 정보를 가져올 수 있는 방법과 사용자 게정 정보를 추가 삭제 할 수 있는 방법도
함께 알려 주실 수 있다면 더 감사하겠습니다.
도메인은 ssotest.com 이고 아이디는 dev 비번은 test12#입니다.
-
Error: Error in bind from LDAP source: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C09030F, comment: AcceptSecurityContext error, data 52e, vece ] javax.naming.AuthenticationException
Cause: Could not authenticate the user trying to login. This can be the result of an incorrect username or password, or an incorrect prefix and/or suffix specified in the Settings tab, depending on the type of LDAP/AD system. Could also mean the authentication type is incorrect. Also an incorrect username attribute or incorrect name attribute can cause this. Common cause of this error is a user trying to login with DOMAIN\login instead of just login.
제가 인터넷에서 찾아 보았더니 인증 관련 문제라고는 하는데 더이상 어떻게 고쳐야하는지는 모르겠습니다.
|