Browse Source

Ticket 48815 - ns-accountstatus.pl - fix DN normalization

Bug Description:  When processing an entry DN the script breaks the entry
                  up into separate parts which are used in a filter.
                  These parts were not being normalized which leads to
                  the script failing.

Fix Description:  First improve the DN normalize function to strip both
                  starting and trailing spaces, then normalize the new
                  DN filter when searching for the backend.

https://fedorahosted.org/389/ticket/48815

Reviewed by: nhosoi(Thanks!)
Mark Reynolds 9 years ago
parent
commit
886a1ff0ae
1 changed files with 4 additions and 2 deletions
  1. 4 2
      ldap/admin/src/scripts/ns-accountstatus.pl.in

+ 4 - 2
ldap/admin/src/scripts/ns-accountstatus.pl.in

@@ -620,7 +620,7 @@ sub normalizeDN
     @suffix=split /([,])/,$entry;
     $result="";
     foreach $part (@suffix){
-        $part=~s/^ +//;
+        $part =~ s/^\s+|\s+$//g;
         $part=~ tr/A-Z/a-z/;
         $result="$result$part";
     }
@@ -641,9 +641,11 @@ sub getSuffix
         # Look if suffix is the suffix of the entry
         #    ldapsearch -s one -b "cn=mapping tree,cn=config" "cn=\"uid=jvedder,ou=People,dc=example,dc=com\""
         #
+        my $filter = normalizeDN("@suffix");
+
         debug("\tSuffix from the entry: #@suffixN#\n");
         $info{base} = "cn=mapping tree, cn=config";
-        $info{filter} = "cn=@suffix";
+        $info{filter} = "cn=$filter";
         $info{scope} = "one";
         $info{attrs} = "cn";
         @mapping = DSUtil::ldapsrch_ext(%info);