 
 ;;======== Helper functions ====================================================
 
+(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- add-response-control
+  "Adds the values contained in given response control to the given map"
+  [m control]
+  (condp instance? control
+    PreReadResponseControl 
+    (update-in m [:pre-read] merge (entry-as-map (.getEntry control)))
+    PostReadResponseControl
+    (update-in m [:post-read] merge (entry-as-map (.getEntry control)))
+    m))
+
+(defn- add-response-controls
+  "Adds the values contained in the given response controls to the given map"
+  [controls m]
+  (reduce add-response-control m (seq controls)))
+
 (defn- ldap-result
-  "Converts an LDAPResult object into a vector"
+  "Converts an LDAPResult object into a map"
   [obj]
-  (let [res (.getResultCode obj)]
-    [(.intValue res) (.getName res)]))
+  (let [res (.getResultCode obj)
+        controls (.getResponseControls obj)]
+    (add-response-controls
+     controls
+     {:code (.intValue res)
+      :name (.getName res)})))
 
 (defn- connection-options
   "Returns a LDAPConnectionOptions object"

  (for [[k v] modify-map]
    (create-modification modify-op (name k) v)))


(defn- get-modify-request
  "Sets up a ModifyRequest object using the contents of the given map"

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



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