這裡主要記載我在安裝測試機器時,所做的API存取嘗試。 Search Base Hashtable < String , Object > env = new Hashtable < String , Object > ( ) ; env. put ( Context . INITIAL_CONTEXT_FACTORY , "com.sun.jndi.ldap.LdapCtxFactory" ) ; env. put ( Context . PROVIDER_URL , "ldap://192.168.1.13:389/dc=testldap,dc=org" ) ; env. put ( Context . SECURITY_AUTHENTICATION , "simple" ) ; env. put ( Context . SECURITY_PRINCIPAL , "cn=admin,dc=testldap,dc=org" ) ; env. put ( Context . SECURITY_CREDENTIALS , "123456" ) ; DirContext ctx = null ; try { ctx = new InitialDirContext ( env ) ; NamingEnumeration < SearchResult > srs = ctx. search ( "" , null ) ; while ( srs. hasMore ( ) ) { SearchResult sr = srs. next ( ) ; System . out . println ( sr ) ; } } catch ( NamingException e ) { throw new RuntimeException ( e ) ; } finally { closeDirContext ( ctx ) ; } Output: cn=admin: null:null:{userpassw...