Multiple user referentials working with IPA.
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / directory / ldap / LdapConnection.java
index f7838381d3884a872661ea8b61b408042da63bef..748efe35087867c086aae4d7706b0d216aaf5b5c 100644 (file)
@@ -99,6 +99,20 @@ public class LdapConnection {
                }
        }
 
+       public synchronized boolean entryExists(LdapName name) throws NamingException {
+               String[] noAttrOID = new String[] { "1.1" };
+               try {
+                       getLdapContext().getAttributes(name, noAttrOID);
+                       return true;
+               } catch (CommunicationException e) {
+                       reconnect();
+                       getLdapContext().getAttributes(name, noAttrOID);
+                       return true;
+               } catch (NameNotFoundException e) {
+                       return false;
+               }
+       }
+
        public synchronized void prepareChanges(WorkingCopy<?, ?, LdapName> wc) throws NamingException {
                // make sure connection will work
                reconnect();
@@ -121,13 +135,13 @@ public class LdapConnection {
 
        }
 
-       protected boolean entryExists(LdapName dn) throws NamingException {
-               try {
-                       return getAttributes(dn).size() != 0;
-               } catch (NameNotFoundException e) {
-                       return false;
-               }
-       }
+//     protected boolean entryExists(LdapName dn) throws NamingException {
+//             try {
+//                     return getAttributes(dn).size() != 0;
+//             } catch (NameNotFoundException e) {
+//                     return false;
+//             }
+//     }
 
        public synchronized void commitChanges(LdapEntryWorkingCopy wc) throws NamingException {
                // delete