Bonjour,
J'ai un fichier spring security avec cette configuration :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    <beans:bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
    	<beans:constructor-arg value="ldap://***.**.**.**:389/DC=**,DC=**"/>
    	<beans:property name="userDn" value="cn=**,cn=Users,dc=**,dc=**"/>
		<beans:property name="password" value="****"/>
    </beans:bean>
    <beans:bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
    	<beans:constructor-arg index="0" value=""/>
     	<beans:constructor-arg index="1" value="(sAMAccountName={0})"/>
     	<beans:constructor-arg index="2" ref="contextSource" />
    </beans:bean>
     <beans:bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
	     <beans:constructor-arg>
	       <beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
	         <beans:constructor-arg ref="contextSource"/>
	         <beans:property name="userSearch" ref="userSearch" />
	       </beans:bean>
	     </beans:constructor-arg>
     <beans:constructor-arg>
       <beans:bean class="**.**.****.LoginService" />
     </beans:constructor-arg>
   </beans:bean>
    <authentication-manager>
     <authentication-provider ref="ldapAuthProvider" />
   </authentication-manager>
et je cherche à simuler le comportement de "like %%" de sql.
je m'explique :
Dans une page j'ai un champ texte et un bouton "rechercher".
en cliquant sur rechercher, mon code doit retourner tous les utilisateurs avec un "cn" contenant le mot saisie.

Le code suivant cherche exactement pattern sur AD:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
@Autowired
private FilterBasedLdapUserSearch ldapUserSearch;
......
 DirContextOperations dctx= ldapUserSearch.searchForUser(pattern);
si il existe dctx est non null sinon un exception se produit.

Comment je peux faire avoir le comportement de like de sql ?

Merci.