IDEMPIERE-3861 Switch LDAP type by System Configuration / based on suggestion from Ray Lee

This commit is contained in:
Carlos Ruiz 2019-03-25 16:27:43 -03:00
parent ca2c67999d
commit 8641a1540f
2 changed files with 11 additions and 7 deletions

View File

@ -26,6 +26,7 @@ import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.ldap.InitialLdapContext;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger;
@ -52,10 +53,12 @@ public class LDAP
// ldap://dc.compiere.org
env.put(Context.PROVIDER_URL, ldapURL);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
// jjanke@compiere.org
// For OpenLDAP uncomment the next line
// StringBuffer principal = new StringBuffer("uid=").append(userName).append(",").append(domain);
StringBuffer principal = new StringBuffer(userName).append("@").append(domain);
StringBuffer principal;
if ("openldap".equals(MSysConfig.getValue(MSysConfig.LDAP_TYPE))) {
principal = new StringBuffer("uid=").append(userName).append(",").append(domain);
} else {
principal = new StringBuffer(userName).append("@").append(domain);
}
env.put(Context.SECURITY_PRINCIPAL, principal.toString());
env.put(Context.SECURITY_CREDENTIALS, password);
//

View File

@ -39,12 +39,12 @@ import org.compiere.util.DisplayType;
*/
public class MSysConfig extends X_AD_SysConfig
{
/**
/**
*
*/
private static final long serialVersionUID = 8922763368373540965L;
private static final long serialVersionUID = -3144528502974306817L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
public static final String ALLOCATION_DESCRIPTION = "ALLOCATION_DESCRIPTION";
public static final String ALLOW_APPLY_PAYMENT_TO_CREDITMEMO = "ALLOW_APPLY_PAYMENT_TO_CREDITMEMO";
@ -104,6 +104,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber";
public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES";
public static final String LASTRUN_RECORD_COUNT = "LASTRUN_RECORD_COUNT";
public static final String LDAP_TYPE = "LDAP_TYPE";
public static final String LOCATION_MAPS_DESTINATION_ADDRESS = "LOCATION_MAPS_DESTINATION_ADDRESS";
public static final String LOCATION_MAPS_ROUTE_PREFIX = "LOCATION_MAPS_ROUTE_PREFIX";
public static final String LOCATION_MAPS_SOURCE_ADDRESS = "LOCATION_MAPS_SOURCE_ADDRESS";