Subject: | Support exact matches as well as substring matches in LDAP |
It might not be appropriate to perform an substring match on some LDAP
fields:
- because the search attribute is an opaque identifier[1]
- because the search attribute on the LDAP search does not have a
substring index.
Patch attached to allow a second type of search attribute.
Cheers,
Dominic.
[1] Yes, I realise this isn't quite what the module was designed for,
but it looks like it's going to work well for us. We want helpdesk users
to be able to put a walk-in requestor in using their official university
id number rather than email address.
Subject: | exact.patch |
diff -urN RTx-EmailCompletion-0.06.debug/lib/RTx/EmailCompletion/Ldap.pm RTx-EmailCompletion-0.06.exact/lib/RTx/EmailCompletion/Ldap.pm
--- RTx-EmailCompletion-0.06.debug/lib/RTx/EmailCompletion/Ldap.pm 2009-10-08 13:22:18.000000000 +0100
+++ RTx-EmailCompletion-0.06.exact/lib/RTx/EmailCompletion/Ldap.pm 2009-10-08 15:36:48.000000000 +0100
@@ -43,7 +43,10 @@
return;
}
- my $filter = "(|" . join('', map { "($_=*$param*)" } @{ $RT::EmailCompletionLdapAttrSearch }) . ")";
+ my $filter = "(|" .
+ join('', map { "($_=*$param*)" } @{ $RT::EmailCompletionLdapAttrSearch }) .
+ join('', map { "($_=$param)" } @{ $RT::EmailCompletionLdapAttrSearchExact }) .
+ ")";
$filter = "(&" . $RT::EmailCompletionLdapFilter . $filter . ")" if $RT::EmailCompletionLdapFilter;
$RT::Logger->debug("LDAP filter is: $filter\n") if RTx::EmailCompletion::DEBUG;
diff -urN RTx-EmailCompletion-0.06.debug/lib/RTx/EmailCompletion.pm RTx-EmailCompletion-0.06.exact/lib/RTx/EmailCompletion.pm
--- RTx-EmailCompletion-0.06.debug/lib/RTx/EmailCompletion.pm 2009-10-08 15:33:49.000000000 +0100
+++ RTx-EmailCompletion-0.06.exact/lib/RTx/EmailCompletion.pm 2009-10-08 15:38:56.000000000 +0100
@@ -295,13 +295,20 @@
(configured for the LDAP RT authentification layout).
=item *
-EmailCompletionLdapAttrSearch : the ldap search attributes
+EmailCompletionLdapAttrSearch : the ldap search attributes to use in
+a substring match
Set($EmailCompletionLdapAttrSearch, [qw/mail cn/]);
Default value is mail.
=item *
+EmailCompletionLdapAttrSearchExact : additional ldap search attributes to
+use in an exact match
+
+Default value is empty.
+
+=item *
EmailCompletionLdapAttrShow : the mail attribute name
Set($EmailCompletionLdapAttrShow, "mail");