1: …… 2: public void f() { 3: Hashtable env = new Hashtable(); 4: env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); 5: env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=rootDir"); 6: try { 7: javax.naming.directory.DirContext ctx = new InitialDirContext(env); 8: // 프로퍼티를 만들고 외부 파일을 로드한다. 9: Properties props = new Properties(); 10: String fileName = "ldap.properties"; 11: FileInputStream in = new FileInputStream(fileName); 12: props.load(in); 13: // LDAP Search를 하기 위해 name을 읽는다 14: String name = props.getProperty("name" ); 15: String filter = "(name =" + name + ")"; 16: // LDAP search가 name값에 대한 여과없이 그대로 통과되어 검색이 되어진다. 17: NamingEnumeration answer = ctx.search("ou=NewHires" , filter, new SearchControls()); 18: printSearchEnumeration(answer); 19: ctx.close(); 20: } catch (NamingException e) { …… } 21: ……