This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c99144a Low-level LDAP search function
9c99144a is described below

commit 9c99144ad764528114e57dd3b5860b3f6cace933
Author: Sebb <[email protected]>
AuthorDate: Tue Mar 19 14:48:10 2024 +0000

    Low-level LDAP search function
---
 lib/whimsy/asf/ldap.rb | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 348c5dbb..c6cbf90a 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -530,6 +530,14 @@ module ASF
       ASF.search_one(base, "cn=#{name}", 'cn').any?
     end
 
+    # Low-level search for retrieving LDAP entries. Assumes scope ONE
+    # Returns list of hashes, where the keys are the attributes
+    # Optionally provide a list of attributes to return, e.g. ['uid','mail']
+    # Always includes 'dn' in the hashes
+    def self.ldap_search(filter, attributes=['dn'])
+      raise ArgumentError.new "Cannot be used for #{self.name} instances" 
unless base
+      ASF.search_one(base, filter, [attributes].flatten)
+    end
   end
 
   # a hash of attributes which is not populated until the first attempt

Reply via email to