ldap/src/main/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearch.java
@Override
	public DirContextOperations searchForUser(String username) {
		if (logger.isDebugEnabled()) {
			logger.debug("Searching for user '" + username + "', with user search "
					+ this);
		}

		SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate(
				contextSource);

		template.setSearchControls(searchControls);

		try {

			return template.searchForSingleEntry(searchBase, searchFilter,
					new String[] { username });

		}
		catch (IncorrectResultSizeDataAccessException notFound) {
			if (notFound.getActualSize() == 0) {
				throw new UsernameNotFoundException("User " + username
						+ " not found in directory.");
			}
			// Search should never return multiple results if properly configured, so just
			// rethrow
			throw notFound;
		}
	}
@Override
	public DirContextOperations searchForUser(String username) {
		if (logger.isDebugEnabled()) {
			logger.debug("Searching for user '" + username + "', with user search "
					+ this);
		}

		SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate(
				contextSource);

		template.setSearchControls(searchControls);

		try {

			return template.searchForSingleEntry(searchBase, searchFilter,
					new String[] { username });

		}
		catch (IncorrectResultSizeDataAccessException notFound) {
			if (notFound.getActualSize() == 0) {
				throw new UsernameNotFoundException("User " + username
						+ " not found in directory.");
			}
			// Search should never return multiple results if properly configured, so just
			// rethrow
			throw notFound;
		}
	}
@ Override public DirContextOperations searchForUser ( String username ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Searching for user '" + username + "', with user search " + this ) ; } SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate ( contextSource ) ; template . setSearchControls ( searchControls ) ; try { return template . searchForSingleEntry ( searchBase , searchFilter , new String [ ] { username } ) ; } catch ( IncorrectResultSizeDataAccessException notFound ) { if ( notFound . getActualSize ( ) == 0 ) { throw new UsernameNotFoundException ( "User " + username + " not found in directory." ) ; } // Search should never return multiple results if properly configured, so just // rethrow throw notFound ; } }
Return the LdapUserDetails containing the user's information

@param username the username to search for.

@return An LdapUserDetails object containing the details of the located user's
directory entry

@throws UsernameNotFoundException if no matching entry is found.
Return the LdapUserDetails containing the user s information