fix: Include (empty) group memberof info in user search results

This commit is contained in:
selfhoster selfhoster 2026-09-20 18:22:46 +02:00
commit 89995a0386

View file

@ -151,9 +151,11 @@ pub async fn search_success(
fn search_entry_from_user(user: &User, req_attrs: &[String]) -> LdapSearchResultEntry {
let mut res: Vec<LdapPartialAttribute> = vec![];
for attr in req_attrs {
if let Some(attr_value) = match attr.as_str() {
"uid" => Some(user.username.clone()),
"cn" | "mail" => Some(user.mail.clone()),
if let Some(attr_values) = match attr.as_str() {
"uid" => Some(vec![user.username.clone()]),
"cn" | "mail" => Some(vec![user.mail.clone()]),
// TODO: group membership
"memberof" => Some(vec![]),
_ => {
tracing::warn!("Ignoring unknown attr in search query: {attr}");
None
@ -161,9 +163,8 @@ fn search_entry_from_user(user: &User, req_attrs: &[String]) -> LdapSearchResult
} {
res.push(LdapPartialAttribute {
atype: attr.clone(),
// TODO: there may be multiple values here in the future,
// eg. mailaliases
vals: vec![Vec::from(attr_value)],
// LDAP response expects raw byte vec for each value
vals: attr_values.into_iter().map(Vec::from).collect(),
});
}
}