Получить всех пользователей и их роли из LDAP, используя Java
У меня есть веб-приложение. Для LDAP я используюApache Directive Studio. Я хочу, чтобы все пользователи и их роли были в моем приложении.
Я могу получить конкретную информацию, используя следующий код.
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class DirectorySample {
public DirectorySample() {
}
public void doLookup() {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.PROVIDER_URL, "ldap://localhost:10389");
try {
DirContext context = new InitialDirContext(properties);
Attributes attrs = context.getAttributes("dc=example,dc=com");
System.out.println("ALL Data: " + attrs.toString());
} catch (NamingException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
DirectorySample sample = new DirectorySample();
sample.doLookup();
}
}
Я хочу показать список всех пользователей и ролей, поэтому мне нужно изменить запрос или что-то еще. Заранее спасибо.