From d20bd196bc737c66d0655d399e32037f4dfaa439 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 11 Feb 2022 08:40:10 +0100 Subject: [PATCH] ldap_handler: trim spaces in LDAP identifiers --- server/src/infra/ldap_handler.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/src/infra/ldap_handler.rs b/server/src/infra/ldap_handler.rs index 8e627e1..27f63f3 100644 --- a/server/src/infra/ldap_handler.rs +++ b/server/src/infra/ldap_handler.rs @@ -37,7 +37,7 @@ where fn parse_distinguished_name(dn: &str) -> Result> { dn.split(',') - .map(|s| make_dn_pair(s.split('=').map(String::from))) + .map(|s| make_dn_pair(s.split('=').map(str::trim).map(String::from))) .collect() } @@ -908,6 +908,11 @@ mod tests { parse_distinguished_name("ou=people,dc=example,dc=com").expect("parsing failed"), parsed_dn ); + assert_eq!( + parse_distinguished_name(" ou = people , dc = example , dc = com ") + .expect("parsing failed"), + parsed_dn + ); } #[tokio::test] @@ -1212,7 +1217,7 @@ mod tests { let request = make_user_search_request( LdapFilter::Equality( "memberOf".to_string(), - "cn=group_1,ou=groups,dc=example,dc=com".to_string(), + "cn=group_1, ou=groups, dc=example,dc=com".to_string(), ), vec!["objectClass"], );