You are here: Foswiki>Tasks Web>Item11407 (19 Nov 2012, MichaelDaum)Edit Attach

Item11407: Enhance LdapNGPlugin with caseinsensitivity

pencil
Priority: Low
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: LdapNgPlugin
Branches: trunk
Reported By: AlexanderStoffers
Waiting For:
Last Change By: MichaelDaum
Hi Michael,

we are using the %LDAPUSERS% macro within autocomplete functions. It would be nice to enable the user send caseinsensitive requests.

Following patch is working for us:

@@ -84,6 +84,7 @@ sub handleLdap {

   my $theClear = $params->{clear} || '';

   my $theExclude = $params->{exclude} || '';

   my $theInclude = $params->{include} || '';

+  my $theCasesensitive = $params->{casesensitive} || 'on';

 

   $theSep = $params->{sep} unless defined $theSep;

   $theSep = '$n' unless defined $theSep;

@@ -130,8 +131,14 @@ sub handleLdap {

   my $index = 0;

   foreach my $entry (@entries) {

     my $dn = $entry->dn();

-    next if $theExclude && $dn =~ /$theExclude/;

-    next if $theInclude && $dn !~ /$theInclude/;

+    

+    if ( $theCasesensitive eq 'off' ) {

+      next if $theExclude && $dn =~ /$theExclude/i;

+      next if $theInclude && $dn !~ /$theInclude/i;

+    } else {

+      next if $theExclude && $dn =~ /$theExclude/;

+      next if $theInclude && $dn !~ /$theInclude/;

+    }

 

     $index++;

     next if $index <= $theSkip;

@@ -193,6 +200,7 @@ sub handleLdapUsers {

   my $theSkip = $params->{skip} || 0;

   my $theInclude = $params->{include};

   my $theExclude = $params->{exclude};

+  my $theCasesensitive = $params->{casesensitive} || 'on';

   my $theHideUnknownUsers = $params->{hideunknown} || 'on';

   $theHideUnknownUsers = ($theHideUnknownUsers eq 'on')?1:0;

 

@@ -207,8 +215,15 @@ sub handleLdapUsers {

 

   my $index = 0;

   foreach my $wikiName (sort @$wikiNames) {

-    next if $theExclude && $wikiName =~ /$theExclude/;

-    next if $theInclude && $wikiName !~ /$theInclude/;

+    

+    if ( $theCasesensitive eq 'off' ) {

+      next if $theExclude && $wikiName =~ /$theExclude/i;

+      next if $theInclude && $wikiName !~ /$theInclude/i;

+    } else {

+      next if $theExclude && $wikiName =~ /$theExclude/;

+      next if $theInclude && $wikiName !~ /$theInclude/;

+    }

+

     my $loginName = $ldap->getLoginOfWikiName($wikiName);

     my $emailAddrs = $ldap->getEmails($loginName);

     my $distinguishedName = $ldap->getDnOfLogin($loginName) || '';

-- AlexanderStoffers - 05 Jan 2012

 
Topic revision: r3 - 19 Nov 2012, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy