Не удается получить соединение с AD из Java
Я пытаюсь получить некоторую информацию из MS AD: члены конкретной ветви, названия отделов, должности,и т.д.
Я использовал много примеров, в том числеApache Directory LDAP API а такжеUnboundID, но я не могу получить соединение с AD.
RDNS:
C:\Users\Aleksey> whoami /fqdn
CN=my common name here,
OU=my organization unit here,
OU=organization unit 2 here,
OU=organization unit 1 here,
OU=main organization unit here,
DC=.my domain here,
DC=domain 2 here,
DC=main domain here
Для поиска я использую следующий фильтр:
public class LdapRetriever {
public static void main (String[] args) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://" +
"ip of domain controller here" + ":389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
// Also I try to use the following SECURITY_PRINCIPAL:
// my login only, my domain\ my login
env.put(Context.SECURITY_PRINCIPAL, "my login here" + "@" +
"my domain here.domain 2 here.main domain here");
env.put(Context.SECURITY_CREDENTIALS, "my password here");
try {
DirContext ctx = new InitialLdapContext(env,null);
String returnedAtts[]={"sn","title","department","givenName"};
SearchControls searchCtls = new SearchControls();
searchCtls.setReturningAttributes(returnedAtts);
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = "(&(objectClass=user)(cn=*))";
String searchBase =
"DC=my domain here,DC=domain 2 here,DC=main domain here";
NamingEnumeration answer = ctx.search(searchBase,
searchFilter, searchCtls);
...
Когда я создаю контекст каталога, используя данные изenv
Я получаю исключение:
Exception in thread "main" javax.naming.AuthenticationException:
[LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment:
AcceptSecurityContext error, data 531, vece
Если пароль не указан, я получаю следующее исключение:
Problem searching directory:
javax.naming.NamingException:[LDAP:error code 1 - 00000000:
LdapErr: DSID-0C090627, comment:
In order to perform this operation a successful bind must be completed
on the connection., data 0, vece]; remaining name
'DC=my domain here,DC=domain 2 here,DC=main domain here'
Я подтвердил, что мой аккаунт не заблокирован.
В соответствиисписок распространенных ошибок связывания с активным каталогом LDAP:
525 user not found
52e invalid credentials
530 not permitted to logon at this time
531 not permitted to logon at this workstation
532 password expired
533 account disabled
701 account expired
773 user must reset password
775 user account locked
В моем случае это означает: «не разрешено входить в систему на этой рабочей станции», но с теми же учетными данными я могу войти в домен.
Что может быть причиной?
Буду очень признателен за информацию. Спасибо всем.