diff --git a/src/ldap/op/search.rs b/src/ldap/op/search.rs index d881508..1ef39f4 100644 --- a/src/ldap/op/search.rs +++ b/src/ldap/op/search.rs @@ -151,9 +151,11 @@ pub async fn search_success( fn search_entry_from_user(user: &User, req_attrs: &[String]) -> LdapSearchResultEntry { let mut res: Vec = 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(), }); } }