Subject: | [PATCH] Return only the requested attributes in auto_schema mode |
Previously all attributes were returned, but this tends to be the
opposite of real LDAP server behaviour.
Subject: | 0001-Return-only-the-requested-attributes-in-auto_schema-.patch |
From d22ec34c4d9af0d6e9dd9d921eda7d4f33f32fc8 Mon Sep 17 00:00:00 2001
From: Thomas Sibley <trs@bestpractical.com>
Date: Fri, 27 Jan 2012 17:59:45 -0500
Subject: [PATCH] Return only the requested attributes in auto_schema mode
Previously all attributes were returned, but this tends to be the
opposite of real LDAP server behaviour.
---
lib/Net/LDAP/Server/Test.pm | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/Net/LDAP/Server/Test.pm b/lib/Net/LDAP/Server/Test.pm
index 67c4670..9c0b6e1 100644
--- a/lib/Net/LDAP/Server/Test.pm
+++ b/lib/Net/LDAP/Server/Test.pm
@@ -129,6 +129,7 @@ Only one user-level method is implemented: new().
my @results;
my $base = $reqData->{baseObject};
my $scope = $reqData->{scope} || 'sub';
+ my @attrs = @{$reqData->{attributes} || []};
my @filters = ();
if ( $scope ne 'base' ) {
@@ -217,7 +218,16 @@ Only one user-level method is implemented: new().
if ( $match == scalar(@filters) ) { # or $dn eq $base ) {
# clone the entry so that client cannot modify %Data
- push( @results, $entry->clone );
+ my $result = $entry->clone;
+
+ # filter returned attributes to those requested
+ if (@attrs) {
+ my %wanted = map { $_ => 1 } @attrs;
+ $result->delete($_)
+ for grep { not $wanted{$_} } $result->attributes;
+ }
+
+ push( @results, $result );
}
}
--
1.7.8.3