Index: lib/metacat.properties
===================================================================
--- lib/metacat.properties	(revision 851)
+++ lib/metacat.properties	(revision 852)
@@ -23,9 +23,12 @@
 accessdoctype=-//NCEAS//eml-access-2.0//EN
 server=@server@
 authclass=edu.ucsb.nceas.metacat.AuthLdap
-ldapurl=ldap://ldap.nceas.ucsb.edu:389/
-ldapsurl=ldap://ldap.nceas.ucsb.edu:389/
-ldapbase=o=NCEAS,c=US
+ldapurl=ldap://ldap.ecoinformatics.org:389/
+ldapsurl=ldap://ldap.ecoinformatics.org:389/
+ldapbase=dc=ecoinformatics,dc=org
+#ldapurl=ldap://ldap.nceas.ucsb.edu:389/
+#ldapsurl=ldap://ldap.nceas.ucsb.edu:389/
+#ldapbase=o=NCEAS,c=US
 deltaT=60
 replicationpath=@replication-path@
 replicationlog=@replication-log@
Index: src/edu/ucsb/nceas/metacat/AuthLdap.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AuthLdap.java	(revision 851)
+++ src/edu/ucsb/nceas/metacat/AuthLdap.java	(revision 852)
@@ -75,8 +75,6 @@
     this.ldapUrl = MetaCatUtil.getOption("ldapurl");
     this.ldapsUrl = MetaCatUtil.getOption("ldapsurl");
     this.ldapBase = MetaCatUtil.getOption("ldapbase");
-    //this.ldapUrl = "ldap://dev.nceas.ucsb.edu:636/";
-    //this.ldapBase = "o=NCEAS,dc=ecoinformatics,dc=org";
   }
 
   /**
@@ -95,77 +93,18 @@
     String ldapBase = this.ldapBase;
     boolean authenticated = false;
     String identifier = user;
-    
-    // Identify service provider to use
-    Hashtable env = new Hashtable(11);
-    env.put(Context.INITIAL_CONTEXT_FACTORY, 
-            "com.sun.jndi.ldap.LdapCtxFactory");
 
     try {
    
-      try { 
-        this.ldapBase = identifier.substring(identifier.indexOf(",")+1);
-        identifier = identifier.substring(0,identifier.indexOf(","));
-      } catch (StringIndexOutOfBoundsException e) {}
+        // Check the usename as passed in
+        authenticated = ldapAuthenticate(identifier, password);
 
-      /*
-       * get all subtrees first in the current dir context 
-       * and then the dn for this uid or cn
-       */
-//      Hashtable subtrees = getSubtrees(user,password,ldapUrl,ldapBase);
-    
-//      Enumeration enum = subtrees.keys();
-//      while ( enum.hasMoreElements() ) {
-//        ldapBase = (String)enum.nextElement();
-//        ldapUrl = (String)subtrees.get(ldapBase);
-        identifier = getIdentifyingName(identifier,ldapUrl,ldapBase);
-System.out.println(ldapsUrl + identifier + "," + ldapBase); 
-
-        if (identifier != null && !password.equals("")) {
-          // Now that we have the dn, we can authenticate, so
-          // authenticate this time when opening the DirContext
-          env.put(Context.PROVIDER_URL, ldapsUrl + ldapBase);
-          if ( !ldapsUrl.equals(ldapUrl) ) {
-            // ldap is set on default port 389
-            // ldaps is set on second port - 636 by default
-            env.put(Context.SECURITY_PROTOCOL, "ssl");
-          }
-          env.put(Context.SECURITY_AUTHENTICATION, "simple");
-          env.put(Context.SECURITY_PRINCIPAL, identifier + "," + ldapBase);
-          env.put(Context.SECURITY_CREDENTIALS, password);
-          // If our auth credentials are invalid, an exception will be thrown
-          DirContext ctx = null;
-          try {
-            double startTime = System.currentTimeMillis();
-            ctx = new InitialDirContext(env);
-//            // StartTLS support from LDAPv3 with X.509 cert and with JSDKv1.4+
-//            LdapContext ctx = new InitialLdapContext(env, null);
-//            StartTlsResponse tls =
-//              (StartTlsResponse)ctx.extendedOperation(new StartTlsRequest());
-//            tls.negotiate();
-
-            double stopTime = System.currentTimeMillis();
-            System.out.println("Connection time thru " + ldapsUrl + " was: " +
-                               (stopTime-startTime)/1000 + " seconds.");
-            authenticated = true;
-//            tls.close();
-            ctx.close();
-            this.ldapUrl = ldapUrl;
-            this.ldapBase = ldapBase;
-         //   break;
-          } catch (AuthenticationException ae) {
-            authenticated = false;
-//            if ( tls != null ) {
-//              tls.close();
-//            }
-            if ( ctx != null ) {
-              ctx.close();
-            }
-          }
-        } else { 
-          util.debugMessage("User not found");
+        // if not found, try looking up a valid DN then auth again
+        if (!authenticated) {
+            identifier = getIdentifyingName(identifier,ldapUrl,ldapBase);
+            System.out.println(ldapsUrl + identifier + "," + ldapBase); 
+            authenticated = ldapAuthenticate(identifier+","+ldapBase, password);
         }
-//      } /* while ( enum.hasMore() ) */
 
     } catch (NullPointerException e) {
       util.debugMessage("NullPointerException b' password is null");
@@ -177,10 +116,7 @@
     } catch (NamingException e) {
       util.debugMessage("Naming exception while authenticating in " + 
                         "AuthLdap.authenticate: " + e);
-      //throw new ConnectException(
-      //"Naming exception while authenticating in " + 
-      //                  "AuthLdap.authenticate: " + e);
-       e.printStackTrace();
+      e.printStackTrace();
     } catch (Exception e) {
       System.out.println(e.getMessage());
     }
@@ -189,6 +125,73 @@
   }
 
   /**
+   * Connect to the LDAP directory and do the authentication using the
+   * username and password as passed into the routine.
+   *
+   * @param identifier the distinguished name to check against LDAP
+   * @param password the password for authentication
+   */
+  private boolean ldapAuthenticate(String identifier, String password)
+            throws ConnectException, NamingException, NullPointerException
+  {
+    boolean authenticated = false;
+    if (identifier != null && !password.equals("")) {
+    
+        // Identify service provider to use
+        Hashtable env = new Hashtable(11);
+        env.put(Context.INITIAL_CONTEXT_FACTORY, 
+            "com.sun.jndi.ldap.LdapCtxFactory");
+
+        // Now that we have the dn, we can authenticate, so
+        // authenticate this time when opening the DirContext
+        env.put(Context.PROVIDER_URL, ldapsUrl + ldapBase);
+        if ( !ldapsUrl.equals(ldapUrl) ) {
+          // ldap is set on default port 389
+          // ldaps is set on second port - 636 by default
+          env.put(Context.SECURITY_PROTOCOL, "ssl");
+        }
+        env.put(Context.SECURITY_AUTHENTICATION, "simple");
+        env.put(Context.SECURITY_PRINCIPAL, identifier);
+        System.out.println("Trying DN: " + identifier);
+        env.put(Context.SECURITY_CREDENTIALS, password);
+        // If our auth credentials are invalid, an exception will be thrown
+        DirContext ctx = null;
+        try {
+          double startTime = System.currentTimeMillis();
+          ctx = new InitialDirContext(env);
+//          // StartTLS support from LDAPv3 with X.509 cert and with JSDKv1.4+
+//          LdapContext ctx = new InitialLdapContext(env, null);
+//          StartTlsResponse tls =
+//            (StartTlsResponse)ctx.extendedOperation(new StartTlsRequest());
+//          tls.negotiate();
+
+          double stopTime = System.currentTimeMillis();
+          System.out.println("Connection time thru " + ldapsUrl + " was: " +
+                             (stopTime-startTime)/1000 + " seconds.");
+          authenticated = true;
+          //tls.close();
+          ctx.close();
+          this.ldapUrl = ldapUrl;
+          this.ldapBase = ldapBase;
+          //break;
+        } catch (AuthenticationException ae) {
+          authenticated = false;
+//          if ( tls != null ) {
+//            tls.close();
+//          }
+          if ( ctx != null ) {
+            ctx.close();
+          }
+        } catch (javax.naming.InvalidNameException ine) {
+            System.out.println("An invalid DN was provided!");
+        }
+    } else { 
+        util.debugMessage("User not found");
+    }
+    return authenticated;
+  }
+
+  /**
    * Get the identifying name for a given userid or name.  This is the name
    * that is used in conjunction withthe LDAP BaseDN to create a
    * distinguished name (dn) for the record
Index: build.xml
===================================================================
--- build.xml	(revision 851)
+++ build.xml	(revision 852)
@@ -46,10 +46,12 @@
       <property name="style-path" value="/jones/style"/>
       <property name="server" value="dev.nceas.ucsb.edu:8443"/>
       <property name="replication-log" value="/tmp/metacatreplication.log"/>
-      <property name="user" value="your-pw-goes-here"/>
-      <property name="password" value="kinkaj0u"/>
+      <property name="user" value="jones"/>
+      <property name="password" value="your-pw-goes-here"/>
       <property name="config-dir" value="${installdir}" />
       <property name="default-style" value="knb" />
+      <property name="eml-version" value="2.0beta4" />
+      <property name="eml-tag" value="RELEASE_EML_2_BETA_4" />
 
       <filter token="jdbc-connect" value="${jdbc-connect}"/>
       <filter token="install-dir" value="${installdir}"/>
@@ -243,4 +245,9 @@
       <delete dir="${dist.dir}"/>
   </target> 
 
+  <target name="emlinst" depends="init">
+    <mkdir dir="lib/dtd" />
+    <cvs command="checkout -d lib/dtd" package="mdstandards/eml" 
+         tag="${eml-tag}" />
+  </target>
 </project>
