eborisow
Feb 21st, 2007, 01:09 PM
Hi,
I am trying to connect to an Active Directory Global Catalog with Spring-LDAP that has the following configuration:
Global Catalog Server (catalogserver.company.com)
--> domain1.company.com
--> domain2.company.com
If I look at the Global Catalog using LDAPBrowser it shows the main server and referrals to the other domain servers.
If I perform a search on one of the domain servers, I receive results properly. If I start the search at the Global Catalog, then I get a PartialResultException. I try to skip over it by setting setIgnorePartialResultException to true which does skip over the error, but I cannot seem to get any results back. Here is my code (no Spring Beans):
Thanks,
Eric
try
{
LdapContextSource contextSource = new LdapContextSource();
contextSource.setAnonymousReadOnly(false);
contextSource.setBase("dc=company,dc=com");
contextSource.setUserName("admin_account@company.com");
contextSource.setPassword("password");
contextSource.setUrl("ldap://catalogserver.company.com:389");
contextSource.setPooled(false);
contextSource.setDirObjectFactory(DefaultDirObject Factory.class);
contextSource.setBaseEnvironmentProperties(new HashMap());
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setIgnorePartialResultException(true) ;
ldapTemplate.afterPropertiesSet();
SearchControls controls = new SearchControls();
controls.setTimeLimit(0);
controls.setCountLimit(0);
controls.setSearchScope(SearchControls.SUBTREE_SCO PE);
List returnList = ldapTemplate.search("",
"(cn=*)", controls, new AttributesMapper()
{
public Object mapFromAttributes(Attributes attrs)
throws NamingException {
System.out.println(attrs.get("cn").get());
return attrs.get("cn").get();
}
});
}
catch (Exception e)
{
e.printStackTrace();
}
I am trying to connect to an Active Directory Global Catalog with Spring-LDAP that has the following configuration:
Global Catalog Server (catalogserver.company.com)
--> domain1.company.com
--> domain2.company.com
If I look at the Global Catalog using LDAPBrowser it shows the main server and referrals to the other domain servers.
If I perform a search on one of the domain servers, I receive results properly. If I start the search at the Global Catalog, then I get a PartialResultException. I try to skip over it by setting setIgnorePartialResultException to true which does skip over the error, but I cannot seem to get any results back. Here is my code (no Spring Beans):
Thanks,
Eric
try
{
LdapContextSource contextSource = new LdapContextSource();
contextSource.setAnonymousReadOnly(false);
contextSource.setBase("dc=company,dc=com");
contextSource.setUserName("admin_account@company.com");
contextSource.setPassword("password");
contextSource.setUrl("ldap://catalogserver.company.com:389");
contextSource.setPooled(false);
contextSource.setDirObjectFactory(DefaultDirObject Factory.class);
contextSource.setBaseEnvironmentProperties(new HashMap());
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setIgnorePartialResultException(true) ;
ldapTemplate.afterPropertiesSet();
SearchControls controls = new SearchControls();
controls.setTimeLimit(0);
controls.setCountLimit(0);
controls.setSearchScope(SearchControls.SUBTREE_SCO PE);
List returnList = ldapTemplate.search("",
"(cn=*)", controls, new AttributesMapper()
{
public Object mapFromAttributes(Attributes attrs)
throws NamingException {
System.out.println(attrs.get("cn").get());
return attrs.get("cn").get();
}
});
}
catch (Exception e)
{
e.printStackTrace();
}