[Rt-devel] RTx::EmailCompletion with LDAP : testers needed

Roedel, Mark MarkRoedel at letu.edu
Mon Nov 12 11:47:05 EST 2007


Seems to be working all right here so far -- I did make a couple of
minor tweaks (diff is attached): 

* Added EmailCompletionLdapUser and EmailCompletionLdapPass
configuration variables to support LDAP servers that don't allow
anonymous binding

* Sorted the results of the LDAP search

One possible weakness I can see with my changes is that I don't think
they'll allow for a case where the ldap server used for email
autocompletion allows anonymous binds but the server used for
authentication doesn't.  I'm not sure what the most graceful way would
be to handle that scenario while still supporting fallthrough to an
underlying LDAP configuration.

Also...I'm not sure how hard this would be, but for sites that use both
LDAP and RDBM lookups for email completion, I can see it being useful
for the dropdown to indicate where each item originated.


--
Mark Roedel
Senior Programmer / Analyst
LeTourneau University
Longview, Texas  USA



-----Original Message-----
From: rt-devel-bounces at lists.bestpractical.com
[mailto:rt-devel-bounces at lists.bestpractical.com] On Behalf Of Nicolas
Chuche
Sent: Sunday, November 11, 2007 12:57 PM
To: rt-devel at lists.bestpractical.com
Subject: [Rt-devel] RTx::EmailCompletion with LDAP : testers needed

Hello,

I've added LDAP autocompletion in RTx::EmailCompletion. As I won't use
this feature myself, I need some testers before releasing it next
week.

You can find it here :
http://gaspard.mine.nu/RTx-EmailCompletion-0.03.tar.gz

Thanks
-------------- next part --------------
diff -r -u RTx-EmailCompletion-0.03/html/SelfService/Ajax/EmailCompletion RTx-EmailCompletion-0.03-letu/html/SelfService/Ajax/EmailCompletion
--- RTx-EmailCompletion-0.03/html/SelfService/Ajax/EmailCompletion      Sun Nov 11 12:42:37 2007
+++ RTx-EmailCompletion-0.03-letu/html/SelfService/Ajax/EmailCompletion Mon Nov 12 10:00:06 2007
@@ -7,6 +7,8 @@
 $RT::EmailCompletionSearch        ||= 'LIKE';

 $RT::EmailCompletionLdapServer     ||= $RT::LdapServer;
+$RT::EmailCompletionLdapUser       ||= $RT::LdapUser;
+$RT::EmailCompletionLdapPass       ||= $RT::LdapPass;
 $RT::EmailCompletionLdapBase       ||= $RT::LdapBase;
 $RT::EmailCompletionLdapFilter     ||= $RT::LdapFilter;
 $RT::EmailCompletionLdapAttrShow   ||= "mail";
diff -r -u RTx-EmailCompletion-0.03/lib/RTx/EmailCompletion/Ldap.pm RTx-EmailCompletion-0.03-letu/lib/RTx/EmailCompletion/Ldap.pm
--- RTx-EmailCompletion-0.03/lib/RTx/EmailCompletion/Ldap.pm    Sun Nov 11 10:49:54 2007
+++ RTx-EmailCompletion-0.03-letu/lib/RTx/EmailCompletion/Ldap.pm       Mon Nov 12 10:33:33 2007
@@ -16,7 +16,14 @@

     my $ldap = new Net::LDAP($RT::EmailCompletionLdapServer);

-    my $mesg = $ldap->bind();
+    my $mesg;
+
+    if ($RT::EmailCompletionLdapUser && $RT::EmailCompletionLdapPass) {
+        $mesg = $ldap->bind($RT::EmailCompletionLdapUser, password=>$RT::EmailCompletionLdapPass);
+    } else {
+        $mesg = $ldap->bind();
+    }
+
     if ($mesg->code != LDAP_SUCCESS) {
        $RT::Logger->crit("Unable to bind to $RT::EmailCompletionLdapServer: ", ldap_error_name($mesg->code), "\n");
        return;
@@ -35,7 +42,7 @@
        $RT::Logger->crit("Unable to search in LDAP: ", ldap_error_name($mesg->code), "\n");
     }

-    my @emails = map { $_->get_attribute( $RT::EmailCompletionLdapAttrShow ) } $mesg->entries;
+    my @emails = sort map { $_->get_attribute( $RT::EmailCompletionLdapAttrShow ) } $mesg->entries;

     @emails = grep { m/$RT::EmailCompletionUnprivileged/ } @emails
        if ref($RT::EmailCompletionUnprivileged) eq 'Regexp' and not $CurrentUser->Privileged();


More information about the Rt-devel mailing list