diff --git a/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java b/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java index fba2960eb0..66a8b0e5fd 100755 --- a/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java @@ -397,10 +397,19 @@ public class LDAPHierarchicalAuthentication env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(javax.naming.Context.PROVIDER_URL, ldap_provider_url); - // Authenticate - env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "simple"); - env.put(javax.naming.Context.SECURITY_PRINCIPAL, adminUser); - env.put(javax.naming.Context.SECURITY_CREDENTIALS, adminPassword); + if ((adminUser != null) && (!adminUser.trim().equals("")) && + (adminPassword != null) && (!adminPassword.trim().equals(""))) + { + // Use admin credencials for search// Authenticate + env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "simple"); + env.put(javax.naming.Context.SECURITY_PRINCIPAL, adminUser); + env.put(javax.naming.Context.SECURITY_CREDENTIALS, adminPassword); + } + else + { + // Use anonymous authentication + env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "none"); + } DirContext ctx = null; try diff --git a/dspace/CHANGES b/dspace/CHANGES index b452c68d71..1c7caab0a9 100644 --- a/dspace/CHANGES +++ b/dspace/CHANGES @@ -18,7 +18,7 @@ - Fix for SF bug [2086481] xmlui Administrative log in as another eperson - Fix for SF bug [2155479] Submission verify page handles dc.identifier.* incorrectly -(Stuart Lewis / Chris Yates / Flavio Botelho / Alex Barbieri / Reuben Pasquini) +(Stuart Lewis / Chris Yates / Flavio Botelho / Alex Barbieri / Reuben Pasquini / Paulo Matos) - [2057378] Hierarchical LDAP support (Paul Needham / Jon Bell / Stuart Lewis) diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index a4bb1cc6ac..1cdec8f8ad 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -466,7 +466,8 @@ webui.ldap.autoregister = true #ldap.search_scope = 2 # The full DN and password of a user allowed to connect to the LDAP server -# and search for the DN of the user trying to log in. +# and search for the DN of the user trying to log in. If these are not specified, +# the initial bind will be performed anonymously. #ldap.search.user = cn=admin,ou=people,o=myu.edu #ldap.search.password = password