Revision 46986
Added by Sofia Baltzi about 7 years ago
modules/uoa-user-management/trunk/src/main/java/eu/dnetlib/openaire/user/ldap/MUserActionsLDAP.java | ||
---|---|---|
7 | 7 |
import eu.dnetlib.openaire.user.dao.RoleDAO; |
8 | 8 |
import eu.dnetlib.openaire.user.dao.SQLMigrationUserDAO; |
9 | 9 |
import eu.dnetlib.openaire.user.store.LDAPConnector; |
10 |
import org.apache.log4j.Logger; |
|
10 | 11 |
import org.springframework.beans.factory.annotation.Autowired; |
11 | 12 |
|
12 | 13 |
import java.sql.SQLException; |
... | ... | |
19 | 20 |
@Autowired |
20 | 21 |
private LDAPConnector ldapConnector; |
21 | 22 |
|
23 |
private static final Logger logger = Logger.getLogger(MUserActionsLDAP.class); |
|
24 |
|
|
22 | 25 |
public boolean authenticate(String cn, String password) throws LDAPException { |
23 | 26 |
LDAPConnection connection = ldapConnector.getConnection(); |
24 | 27 |
String usersDN = ldapConnector.getUsersDN(); |
... | ... | |
119 | 122 |
try { |
120 | 123 |
|
121 | 124 |
System.out.println("getting user " + username + " from ldap"); |
122 |
|
|
123 |
Filter filter = Filter.create("cn=*");
|
|
125 |
logger.info("getting user " + username + " from ldap"); |
|
126 |
Filter filter = Filter.createEqualityFilter("cn",username);
|
|
124 | 127 |
SearchRequest searchRequest = |
125 | 128 |
new SearchRequest(usersDN, SearchScope.SUB, filter, "mail", "displayName", "cn"); |
126 | 129 |
|
... | ... | |
132 | 135 |
user.setEmail(entry.getAttributeValue("mail")); |
133 | 136 |
user.setDisplayName(entry.getAttributeValue("displayName")); |
134 | 137 |
} |
138 |
logger.info("Cn = " + user.getCn() + " mail = " + user.getEmail() + " displayName = " + user.getDisplayName()); |
|
135 | 139 |
return user; |
136 | 140 |
|
137 | 141 |
} finally { |
Also available in: Unified diff
Update MUserActionsLDAP, correct filter for username