cancel
Showing results for 
Search instead for 
Did you mean: 

LDAP query programmatically

guilhem
Champ in-the-making
Champ in-the-making
Hello,

I'm new in Alfresco and I would like to know if it is possible to import some users using an LDAP query but programmatically ? (the synchronization of Alfresco with the LDAP Server is already managed)
For example something like :
List<User> users = AnyAlfrescoService.getUsers(ldapServerId, "CN=Users,DC=myDomain,DC=…", "(objectClass=person)", …);


Thank you for your help
Regards
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
You are going to have to clarify.    Of corse you can write something that would do that query.    But what would be the use?

What you need is Person objects within alfresco.    Ldap sync can do that and in general the query language is capable of specifying most requirements.

guilhem
Champ in-the-making
Champ in-the-making
Actually I couldn't manage to do this with Alfresco.
I have added the Spring LDAP lib to do a simple LDAP search using an LdapTemplate and an AbstractContextMapper :

LdapTemplate ldapTemplate = new LdapTemplate();
ldapTemplate.setContextSource(contextSource);
List<Person> persons = ldapTemplate.search(DistinguishedName.EMPTY_PATH, "(objectclass=person)", getContextMapper());