You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2013/11/11 06:56:28 UTC
svn commit: r1540614 - in /openmeetings:
branches/2.x/src/org/apache/openmeetings/ldap/LdapLoginManagement.java
trunk/singlewebapp/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
Author: solomax
Date: Mon Nov 11 05:56:27 2013
New Revision: 1540614
URL: http://svn.apache.org/r1540614
Log:
[OPENMEETINGS-491] ability to add custom filter is added to LDAP
Modified:
openmeetings/branches/2.x/src/org/apache/openmeetings/ldap/LdapLoginManagement.java
openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
Modified: openmeetings/branches/2.x/src/org/apache/openmeetings/ldap/LdapLoginManagement.java
URL: http://svn.apache.org/viewvc/openmeetings/branches/2.x/src/org/apache/openmeetings/ldap/LdapLoginManagement.java?rev=1540614&r1=1540613&r2=1540614&view=diff
==============================================================================
--- openmeetings/branches/2.x/src/org/apache/openmeetings/ldap/LdapLoginManagement.java (original)
+++ openmeetings/branches/2.x/src/org/apache/openmeetings/ldap/LdapLoginManagement.java Mon Nov 11 05:56:27 2013
@@ -85,32 +85,26 @@ public class LdapLoginManagement {
public static final String CONFIGKEY_LDAP_ADMIN_DN = "ldap_admin_dn";
public static final String CONFIGKEY_LDAP_ADMIN_PASSWD = "ldap_passwd";
public static final String CONFIGKEY_LDAP_SEARCH_SCOPE = "ldap_search_base";
- public static final String CONFIGKEY_LDAP_SERVER_TYPE = "ldap_server_type"; // for
- // OpenLDAP
- // use
- // only
+ public static final String CONFIGKEY_LDAP_SERVER_TYPE = "ldap_server_type"; // for OpenLDAP use only
public static final String CONFIGKEY_LDAP_AUTH_TYPE = "ldap_auth_type";
public static final String CONFIGKEY_LDAP_FIELDNAME_USER_PRINCIPAL = "field_user_principal";
- public static final String CONFIGKEY_LDAP_SYNC_PASSWD_OM = "ldap_sync_password_to_om"; // 'yes'
- // or
- // 'no'
+ public static final String CONFIGKEY_LDAP_SYNC_PASSWD_OM = "ldap_sync_password_to_om"; // 'yes' or 'no'
public static final String CONFIGKEY_LDAP_USE_LOWER_CASE = "ldap_use_lower_case";
public static final String CONFIGKEY_LDAP_TIMEZONE_NAME = "ldap_user_timezone";
- /***
- * for future use (lemeur) public static final String
- * CONFIGKEY_LDAP_USER_EXTRAFILTER = "ldap_user_extrafilter"; public static
- * final String CONFIGKEY_LDAP_GROUP_FILTER_NUM = "ldap_group_filter_num";
- * public static final String CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX =
- * "ldap_group_filter_name_"; public static final String
- * CONFIGKEY_LDAP_GROUP_FILTER_BASE_PREFIX = "ldap_group_filter_base_";
- * public static final String CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX =
- * "ldap_group_filter_type_"; public static final String
- * CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX = "ldap_group_filter_text_";
- ***/
+ /*
+ //for future use (lemeur)
+ public static final String CONFIGKEY_LDAP_USER_EXTRAFILTER = "ldap_user_extrafilter";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_NUM = "ldap_group_filter_num";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX = "ldap_group_filter_name_";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_BASE_PREFIX = "ldap_group_filter_base_";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX = "ldap_group_filter_type_";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX = "ldap_group_filter_text_";
+ */
+ public static final String CONFIGKEY_LDAP_FILTER_ADD = "ldap_filter_add";
// LDAP default attributes mapping
public static final String LDAP_KEY_LASTNAME = "sn";
@@ -282,30 +276,26 @@ public class LdapLoginManagement {
// Wether or not we'll store Ldap passwd into OM db
boolean ldap_sync_passwd_to_om = "no".equals(configData.get(CONFIGKEY_LDAP_SYNC_PASSWD_OM));
- /***
- * for future use (lemeur) // Ldap user filter to refine the search
- * String ldap_user_extrafilter =
- * configData.get(CONFIGKEY_LDAP_USER_EXTRAFILTER);
- *
- * // Count of Ldap group filters String ldap_group_filter_num =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NUM);
- *
- * // Prefix name of Ldap group filter name String
- * ldap_group_filter_name_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
- *
- * // Prefix name of Ldap group filter base String
- * ldap_group_filter_base_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
- *
- * // Prefix name of Ldap group filter type String
- * ldap_group_filter_type_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX);
- *
- * // Prefix name of Ldap group filter text String
- * ldap_group_filter_text_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX);
- ***/
+ /*
+ //for future use (lemeur)
+ // Ldap user filter to refine the search
+ String ldap_user_extrafilter = configData.get(CONFIGKEY_LDAP_USER_EXTRAFILTER);
+
+ // Count of Ldap group filters
+ String ldap_group_filter_num = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NUM);
+
+ // Prefix name of Ldap group filter name
+ String ldap_group_filter_name_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
+
+ // Prefix name of Ldap group filter base
+ String ldap_group_filter_base_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
+
+ // Prefix name of Ldap group filter type
+ String ldap_group_filter_type_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX);
+
+ // Prefix name of Ldap group filter text
+ String ldap_group_filter_text_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX);
+ */
// Get custom Ldap attributes mapping
String ldap_user_attr_lastname = configData.get(CONFIGKEY_LDAP_KEY_LASTNAME);
@@ -321,7 +311,8 @@ public class LdapLoginManagement {
String ldap_user_attr_timezone = configData.get(CONFIGKEY_LDAP_TIMEZONE_NAME);
String ldap_user_picture_uri = configData.get(CONFIGKEY_LDAP_PICTURE_URI);
String ldap_use_lower_case = configData.get(CONFIGKEY_LDAP_USE_LOWER_CASE);
-
+ String ldap_auth_type = configData.get(CONFIGKEY_LDAP_AUTH_TYPE);
+ String ldap_filter_add = configData.get(CONFIGKEY_LDAP_FILTER_ADD);
if (ldap_use_lower_case != null && ldap_use_lower_case.equals("true")) {
user = user.toLowerCase();
@@ -360,14 +351,13 @@ public class LdapLoginManagement {
if (ldap_user_attr_timezone == null) {
ldap_user_attr_timezone = LDAP_KEY_TIMEZONE;
}
-
- // Auth Type
- String ldap_auth_type = configData.get(CONFIGKEY_LDAP_AUTH_TYPE);
-
if (ldap_auth_type == null) {
ldap_auth_type = "";
}
-
+ if (ldap_filter_add == null) {
+ ldap_filter_add = "";
+ }
+
if (!isValidAuthType(ldap_auth_type)) {
log.error("ConfigKey in Ldap Config contains invalid auth type : '"
+ ldap_auth_type + "' -> Defaulting to "
@@ -377,7 +367,10 @@ public class LdapLoginManagement {
// Filter for Search of UserData
String ldap_search_filter = "(" + ldap_fieldname_user_principal + "=" + user + ")";
-
+ if (!"".equals(ldap_filter_add)) {
+ ldap_filter_add = ldap_filter_add.replaceAll(":", "=");
+ ldap_search_filter = "(&(" + ldap_filter_add + ")(" + ldap_fieldname_user_principal + "=" + user + "))";
+ }
log.debug("Searching userdata with LDAP Search Filter :" + ldap_search_filter);
// replace : -> in config = are replaced by : to be able to build valid
Modified: openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java?rev=1540614&r1=1540613&r2=1540614&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java (original)
+++ openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java Mon Nov 11 05:56:27 2013
@@ -81,32 +81,26 @@ public class LdapLoginManagement impleme
public static final String CONFIGKEY_LDAP_ADMIN_DN = "ldap_admin_dn";
public static final String CONFIGKEY_LDAP_ADMIN_PASSWD = "ldap_passwd";
public static final String CONFIGKEY_LDAP_SEARCH_SCOPE = "ldap_search_base";
- public static final String CONFIGKEY_LDAP_SERVER_TYPE = "ldap_server_type"; // for
- // OpenLDAP
- // use
- // only
+ public static final String CONFIGKEY_LDAP_SERVER_TYPE = "ldap_server_type"; // for OpenLDAP use only
public static final String CONFIGKEY_LDAP_AUTH_TYPE = "ldap_auth_type";
public static final String CONFIGKEY_LDAP_FIELDNAME_USER_PRINCIPAL = "field_user_principal";
- public static final String CONFIGKEY_LDAP_SYNC_PASSWD_OM = "ldap_sync_password_to_om"; // 'yes'
- // or
- // 'no'
+ public static final String CONFIGKEY_LDAP_SYNC_PASSWD_OM = "ldap_sync_password_to_om"; // 'yes' or 'no'
public static final String CONFIGKEY_LDAP_USE_LOWER_CASE = "ldap_use_lower_case";
public static final String CONFIGKEY_LDAP_TIMEZONE_NAME = "ldap_user_timezone";
- /***
- * for future use (lemeur) public static final String
- * CONFIGKEY_LDAP_USER_EXTRAFILTER = "ldap_user_extrafilter"; public static
- * final String CONFIGKEY_LDAP_GROUP_FILTER_NUM = "ldap_group_filter_num";
- * public static final String CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX =
- * "ldap_group_filter_name_"; public static final String
- * CONFIGKEY_LDAP_GROUP_FILTER_BASE_PREFIX = "ldap_group_filter_base_";
- * public static final String CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX =
- * "ldap_group_filter_type_"; public static final String
- * CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX = "ldap_group_filter_text_";
- ***/
+ /*
+ //for future use (lemeur)
+ public static final String CONFIGKEY_LDAP_USER_EXTRAFILTER = "ldap_user_extrafilter";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_NUM = "ldap_group_filter_num";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX = "ldap_group_filter_name_";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_BASE_PREFIX = "ldap_group_filter_base_";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX = "ldap_group_filter_type_";
+ public static final String CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX = "ldap_group_filter_text_";
+ */
+ public static final String CONFIGKEY_LDAP_FILTER_ADD = "ldap_filter_add";
// LDAP default attributes mapping
public static final String LDAP_KEY_LASTNAME = "sn";
@@ -278,30 +272,26 @@ public class LdapLoginManagement impleme
// Wether or not we'll store Ldap passwd into OM db
boolean ldap_sync_passwd_to_om = "no".equals(configData.get(CONFIGKEY_LDAP_SYNC_PASSWD_OM));
- /***
- * for future use (lemeur) // Ldap user filter to refine the search
- * String ldap_user_extrafilter =
- * configData.get(CONFIGKEY_LDAP_USER_EXTRAFILTER);
- *
- * // Count of Ldap group filters String ldap_group_filter_num =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NUM);
- *
- * // Prefix name of Ldap group filter name String
- * ldap_group_filter_name_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
- *
- * // Prefix name of Ldap group filter base String
- * ldap_group_filter_base_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
- *
- * // Prefix name of Ldap group filter type String
- * ldap_group_filter_type_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX);
- *
- * // Prefix name of Ldap group filter text String
- * ldap_group_filter_text_prefix =
- * configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX);
- ***/
+ /*
+ //for future use (lemeur)
+ // Ldap user filter to refine the search
+ String ldap_user_extrafilter = configData.get(CONFIGKEY_LDAP_USER_EXTRAFILTER);
+
+ // Count of Ldap group filters
+ String ldap_group_filter_num = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NUM);
+
+ // Prefix name of Ldap group filter name
+ String ldap_group_filter_name_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
+
+ // Prefix name of Ldap group filter base
+ String ldap_group_filter_base_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_NAME_PREFIX);
+
+ // Prefix name of Ldap group filter type
+ String ldap_group_filter_type_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TYPE_PREFIX);
+
+ // Prefix name of Ldap group filter text
+ String ldap_group_filter_text_prefix = configData.get(CONFIGKEY_LDAP_GROUP_FILTER_TEXT_PREFIX);
+ */
// Get custom Ldap attributes mapping
String ldap_user_attr_lastname = configData.get(CONFIGKEY_LDAP_KEY_LASTNAME);
@@ -317,7 +307,8 @@ public class LdapLoginManagement impleme
String ldap_user_attr_timezone = configData.get(CONFIGKEY_LDAP_TIMEZONE_NAME);
String ldap_user_picture_uri = configData.get(CONFIGKEY_LDAP_PICTURE_URI);
String ldap_use_lower_case = configData.get(CONFIGKEY_LDAP_USE_LOWER_CASE);
-
+ String ldap_auth_type = configData.get(CONFIGKEY_LDAP_AUTH_TYPE);
+ String ldap_filter_add = configData.get(CONFIGKEY_LDAP_FILTER_ADD);
if (ldap_use_lower_case != null && ldap_use_lower_case.equals("true")) {
user = user.toLowerCase();
@@ -356,14 +347,13 @@ public class LdapLoginManagement impleme
if (ldap_user_attr_timezone == null) {
ldap_user_attr_timezone = LDAP_KEY_TIMEZONE;
}
-
- // Auth Type
- String ldap_auth_type = configData.get(CONFIGKEY_LDAP_AUTH_TYPE);
-
if (ldap_auth_type == null) {
ldap_auth_type = "";
}
-
+ if (ldap_filter_add == null) {
+ ldap_filter_add = "";
+ }
+
if (!isValidAuthType(ldap_auth_type)) {
log.error("ConfigKey in Ldap Config contains invalid auth type : '"
+ ldap_auth_type + "' -> Defaulting to "
@@ -373,6 +363,10 @@ public class LdapLoginManagement impleme
// Filter for Search of UserData
String ldap_search_filter = "(" + ldap_fieldname_user_principal + "=" + user + ")";
+ if (!"".equals(ldap_filter_add)) {
+ ldap_filter_add = ldap_filter_add.replaceAll(":", "=");
+ ldap_search_filter = "(&(" + ldap_filter_add + ")(" + ldap_fieldname_user_principal + "=" + user + "))";
+ }
log.debug("Searching userdata with LDAP Search Filter :" + ldap_search_filter);