[pve-devel] [PATCH common v2 2/2] ldap: add optional classes to query_users
Dominik Csapak
d.csapak at proxmox.com
Fri Mar 13 13:18:43 CET 2020
and filter by it
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
no changes
src/PVE/LDAP.pm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LDAP.pm b/src/PVE/LDAP.pm
index 3294c51..ff98e36 100644
--- a/src/PVE/LDAP.pm
+++ b/src/PVE/LDAP.pm
@@ -94,7 +94,7 @@ sub auth_user_dn {
}
sub query_users {
- my ($ldap, $filter, $attributes, $base_dn) = @_;
+ my ($ldap, $filter, $attributes, $base_dn, $classes) = @_;
# build filter from given filter and attribute list
my $tmp = "(|";
@@ -103,6 +103,14 @@ sub query_users {
}
$tmp .= ")";
+ if ($classes) {
+ $tmp = "(&$tmp(|";
+ for my $class (@$classes) {
+ $tmp .= "(objectclass=$class)";
+ }
+ $tmp .= "))";
+ }
+
if ($filter) {
$filter = "($filter)" if $filter !~ m/^\(.*\)$/;
$filter = "(&${filter}${tmp})"
--
2.20.1
More information about the pve-devel
mailing list