--- a/dspace-1.7.0-src-release/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java 2010-12-16 18:40:04.000000000 +0000
+++ b/dspace-1.7.0-src-release/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java 2011-02-25 19:03:23.000000000 +0000
@@ -228,11 +228,17 @@
                 log.info(LogManager.getHeader(context,
                                 "autoregister", "netid=" + netid));
 
-                               if ((ldap.ldapEmail!=null)&&(!ldap.ldapEmail.equals("")))
+                               String email=ldap.ldapEmail;
+                               if ( ((email==null) || (email.equals(""))) && 
+                                       (!ConfigurationManager.getProperty("ldap.netid_email_domain").equals(""))) {
+                                       email=netid + ConfigurationManager.getProperty("ldap.netid_email_domain");
+                               }
+
+                               if ((email!=null)&&(!email.equals("")))
                                {
                                        try
                                        {
-                                               eperson = EPerson.findByEmail(context, ldap.ldapEmail);
+                                               eperson = EPerson.findByEmail(context, email);
                                                if (eperson!=null)
                                                {
                                                        log.info(LogManager.getHeader(context,
@@ -254,13 +260,9 @@
                                                                {
                                                                        context.setIgnoreAuthorization(true);
                                                                        eperson = EPerson.create(context);
-                                                                       if ((ldap.ldapEmail != null) && (!ldap.ldapEmail.equals("")))
-                                                                       {
-                                                                               eperson.setEmail(ldap.ldapEmail);
-                                                                       }
-                                                                       else
+                                                                       if ((email != null) && (!email.equals("")))
                                                                        {
-                                                                               eperson.setEmail(netid + ConfigurationManager.getProperty("ldap.netid_email_domain"));
+                                                                               eperson.setEmail(email);
                                                                        }
                                                                        if ((ldap.ldapGivenName!=null) && (!ldap.ldapGivenName.equals("")))
                                                                        {
@@ -576,4 +578,4 @@
     {
         return "org.dspace.eperson.LDAPAuthentication.title";
     }
-}
\ No newline at end of file
+}

