diff --git a/src/de/superx/servlet/LdapPasswordChecker.java b/src/de/superx/servlet/LdapPasswordChecker.java index de85b72..3c371e6 100644 --- a/src/de/superx/servlet/LdapPasswordChecker.java +++ b/src/de/superx/servlet/LdapPasswordChecker.java @@ -151,7 +151,17 @@ public class LdapPasswordChecker { sc.setSearchScope(SearchControls.SUBTREE_SCOPE); // use a search filter to find only the user we want to authenticate - String searchFilter = "(" + props.getProperty("LdapIdentifyingAttribute") + "=" + username + ")"; + String searchFilter = ""; + if (props.getProperty("LdapSearchFilter")!=null) + { + searchFilter=StringUtils.replace(props.getProperty("LdapSearchFilter"),"${0}", username ); + } + else + { + searchFilter="(" + props.getProperty("LdapIdentifyingAttribute") + "=" + username + ")"; + } + //searchFilter="(&(uid="+username+")(mail=boyle@ldap.forumsys.com))"; + return serviceCtx.search(props.getProperty("LdapBase"), searchFilter, sc); } @@ -187,7 +197,7 @@ public class LdapPasswordChecker { System.out.println("Authentifizierung erfolgreich"); } } else { - throw new IllegalStateException(" Kein LDAP Eintrag für User " + username + " gefunden"); + throw new IllegalStateException(" Kein gültiger LDAP Eintrag für User " + username + " gefunden"); } } diff --git a/superx/WEB-INF/superx_standalone_ldap.properties.sam b/superx/WEB-INF/superx_standalone_ldap.properties.sam index 22443d9..87ece7b 100644 --- a/superx/WEB-INF/superx_standalone_ldap.properties.sam +++ b/superx/WEB-INF/superx_standalone_ldap.properties.sam @@ -17,5 +17,6 @@ LdapBase=dc=example,dc=com # # Identifiying Attribute mit dem ein User mittels seiner Kennung gefunden wird (z.B. uid) # z.B. bei Suchstring uid={0} einfach nur uid -# (ein komplexer Suchstring ist derzeit nicht möglich, passen Sie ggfs. die LdapBase-Definition an oder kontaktieren Sie uns unter support@superx-projekt.de LdapIdentifyingAttribute=uid +# optional können Sie bei Bedarf zusätzlich einen komplexeren Searchfilter definieren,z.B. +#LdapSearchFilter=(&(uid=${0})(status=aktiv))