[pve-devel] [PATCH common v2 1/2] ldap: optionally save group name by attribute
Dominik Csapak
d.csapak at proxmox.com
Fri Mar 13 13:18:42 CET 2020
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* renamed attr to group_name_attr
* check if it is set
src/PVE/LDAP.pm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/PVE/LDAP.pm b/src/PVE/LDAP.pm
index 3288146..3294c51 100644
--- a/src/PVE/LDAP.pm
+++ b/src/PVE/LDAP.pm
@@ -176,7 +176,7 @@ sub query_users {
}
sub query_groups {
- my ($ldap, $base_dn, $classes, $filter) = @_;
+ my ($ldap, $base_dn, $classes, $filter, $group_name_attr) = @_;
my $tmp = "(|";
for my $class (@$classes) {
@@ -193,12 +193,14 @@ sub query_groups {
my $page = Net::LDAP::Control::Paged->new(size => 100);
+ my $attrs = [ 'member', 'uniqueMember' ];
+ push @$attrs, $group_name_attr if $group_name_attr;
my @args = (
base => $base_dn,
scope => "subtree",
filter => $filter,
control => [ $page ],
- attrs => [ 'member', 'uniqueMember' ],
+ attrs => $attrs,
);
my $cookie;
@@ -225,6 +227,9 @@ sub query_groups {
$members = [$entry->get_value('uniqueMember')];
}
$group->{members} = $members;
+ if ($group_name_attr && (my $name = $entry->get_value($group_name_attr))) {
+ $group->{name} = $name;
+ }
push @$groups, $group;
}
--
2.20.1
More information about the pve-devel
mailing list