You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ja...@apache.org on 2013/10/28 18:10:12 UTC
svn commit: r1536421 -
/karaf/trunk/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
Author: janstey
Date: Mon Oct 28 17:10:12 2013
New Revision: 1536421
URL: http://svn.apache.org/r1536421
Log:
KARAF-2529 - Use connection credentials when searching for roles in LDAP
Modified:
karaf/trunk/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
Modified: karaf/trunk/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
URL: http://svn.apache.org/viewvc/karaf/trunk/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java?rev=1536421&r1=1536420&r2=1536421&view=diff
==============================================================================
--- karaf/trunk/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java (original)
+++ karaf/trunk/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java Mon Oct 28 17:10:12 2013
@@ -225,6 +225,7 @@ public class LDAPLoginModule extends Abs
// step 2: bind the user using the DN
context = null;
try {
+ // switch the credentials to the Karaf login user so that we can verify his password is correct
logger.debug("Bind user (authentication).");
env.put(Context.SECURITY_AUTHENTICATION, authentication);
logger.debug("Set the security principal for " + userDN + "," + userBaseDN);
@@ -251,6 +252,12 @@ public class LDAPLoginModule extends Abs
context = null;
try {
logger.debug("Get user roles.");
+ // switch back to the connection credentials for the role search like we did for the user search in step 1
+ if (connectionUsername != null && connectionUsername.trim().length() > 0) {
+ env.put(Context.SECURITY_AUTHENTICATION, authentication);
+ env.put(Context.SECURITY_PRINCIPAL, connectionUsername);
+ env.put(Context.SECURITY_CREDENTIALS, connectionPassword);
+ }
context = new InitialDirContext(env);
SearchControls controls = new SearchControls();
if (roleSearchSubtree) {