[Minor] if no LDAP data for userPrincipalName, then try with sAMAccountName
This commit is contained in:
parent
8516233943
commit
4f73506215
|
@ -87,9 +87,16 @@ public class LdapPrivilegeHandler extends DefaultPrivilegeHandler {
|
||||||
// Search for objects using the filter
|
// Search for objects using the filter
|
||||||
NamingEnumeration<SearchResult> answer = ctx.search(this.searchBase, searchFilter, searchCtls);
|
NamingEnumeration<SearchResult> answer = ctx.search(this.searchBase, searchFilter, searchCtls);
|
||||||
|
|
||||||
if (!answer.hasMore())
|
if (!answer.hasMore()) {
|
||||||
throw new AccessDeniedException(
|
|
||||||
"Could not login with user: " + username + this.domain + " on Ldap: no LDAP Data");
|
logger.warn("No LDAP data retrieved using userPrincipalName, trying with sAMAccountName...");
|
||||||
|
searchFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=" + username + "))";
|
||||||
|
answer = ctx.search(this.searchBase, searchFilter, searchCtls);
|
||||||
|
|
||||||
|
if (!answer.hasMore())
|
||||||
|
throw new AccessDeniedException("Could not login with user: " + username + this.domain
|
||||||
|
+ " on Ldap: no LDAP Data, for either userPrincipalName or sAMAccountName");
|
||||||
|
}
|
||||||
|
|
||||||
SearchResult sr = (SearchResult) answer.next();
|
SearchResult sr = (SearchResult) answer.next();
|
||||||
if (answer.hasMore())
|
if (answer.hasMore())
|
||||||
|
|
Loading…
Reference in New Issue