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