0.0
No commit activity in last 3 years
No release in over 3 years
DSL for dynamically building complex LDAP filters without concern for closing parentheses
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

ldap-filter

While working on a Rails application that leaned heavily on my school's LDAP server, I started off writing inflexible methods like:

def uid_filter(uid)
  "(uid=#{uid})"
end

def uid_or_email_filter(uid, email)
  "(|(#{uid_filter(uid)})(#{email_filter(email)}))"
end

And decided it would be easier to do:

filter = LDAP::Filter::Base.new :uid, 'mrhalp' # (uid=mrhalp)
if search[:email] # mrhalp@email.org
  email = LDAP::Filter::Base.new :mail, search[:email]
  filter = filter | email
end
MyLDAPLibrary.search filter.to_s # (|(email=mrhalp@email.org)(uid=mrhalp))

You also don't have to worry about all those nested parentheses.

Install

gem install ldap-filter

With Bundler:

gem 'ldap-filter'

Usage

More to come soon.