Advertisement

用JAVA开发一个 LDAP 目录服务器

阅读量:

以下将以获取所有person objectclass对象为例,进行相应的代码编写工作。

通过JNDI访问LDAP目录服务器

复制代码
    public List<String> getAllPersonNames() {
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.PROVIDER_URL, "ldap://localhost:389/dc=example,dc=com");
    
      DirContext ctx;
      try {
         ctx = new InitialDirContext(env);
      } catch (NamingException e) {
         throw new RuntimeException(e);
      }
    
      List<String> list = new LinkedList<String>();
      NamingEnumeration results = null;
      try {

全部评论 (0)

还没有任何评论哟~