Hello,
I'm not sure if this is simply my misunderstanding of LDAP, or a bug, or both. I was hoping someone with a little more experience could point me in the right direction.
I have a Ruby script that takes an email address as input, and confirms it exists in our corporate LDAP server by searching through 'mail' entities, and simply returns a true or false value. I've come into a problem where the LDAP entry for some users is cased oddly. For example, the user Joe Smith:
CN=Joe Smith,OU=My Company West Coast,OU=My Company,OU=People,DC=corprate,DC=parentCompany,DC=com
mail: JSm...@parentCompany.com
As a result, my search for "jsm...@parentCompany.com" fails. I would like to have the LDAP search ignore case, so that it succeeds instead of fails in this example. Before I discovered this problem, my code looked like this:
treebase = "OU=People,DC=corporate,DC=parentCompany,DC=com"
filter = Net::LDAP::Filter.eq("mail", addr)
@ldap.search(:base => treebase, :filter => filter,:return_result => false) { |entry|
if entry.mail.first == addr
I've tried a few variations of the extensible search to no avail:
# Neither of these attr strings worked:
attr = "mail:caseIgnoreMatch"
attr = "mail:1.3.6.1.4.1.1466.115.121.1.15"
filter = Net::LDAP::Filter.ex(attr, addr)
I also tried constructing a string, no worky:
filter = Net::LDAP::Filter.construct("(mail:caseIgnoreMatch:=#{addr})")
Any suggestions are much appreciated! Thanks for your help. Also thanks for cleaning the gem up and incorporating some of the older fixes; I had been stuck using the 0.2.2 gem due to the
UndefinedConversionError.