             LDAPEntrySource
             EntrySourceException
             SearchScope])
+  (:import [com.unboundid.ldap.sdk.controls
+            PreReadRequestControl
+            PostReadRequestControl
+            PreReadResponseControl
+            PostReadResponseControl])
   (:import [com.unboundid.util.ssl
             SSLUtil
             TrustAllTrustManager

      (> (.size attr) 1)     [k (vec (.getValues attr))]
      :else                  [k (.getValue attr)])))

(defn- entry-as-map
  "Converts an Entry object into a map"
  [entry]
  (let [col-a (.getAttributes entry)
        attrs (seq (.getAttributes entry))]
      (apply hash-map :dn (.getDN entry)
             (mapcat extract-attribute attrs))))

(defn- set-entry-kv!
  "Sets the given key/value pair in the given entry object"

  (let [adds (modify-ops ModificationType/ADD (modifications :add))
        deletes (modify-ops ModificationType/DELETE (modifications :delete))
        replacements (modify-ops ModificationType/REPLACE
                                 (modifications :replace))
        all (concat adds deletes replacements)]
    (doto (ModifyRequest. dn (into-array all))
      (add-request-controls modifications))))

(defn- next-entry
  "Attempts to get the next entry from an LDAPEntrySource object"
