From 9b130947db7526e1b95eba54ae9c34e9639182c1 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 12 Jan 2023 12:07:07 +0100 Subject: [PATCH] implemented ldap compare --- server/src/infra/ldap_handler.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/server/src/infra/ldap_handler.rs b/server/src/infra/ldap_handler.rs index 7d02224..6fa87cc 100644 --- a/server/src/infra/ldap_handler.rs +++ b/server/src/infra/ldap_handler.rs @@ -547,7 +547,10 @@ impl LdapHandler LdapResult> { let req = make_search_request::( &self.ldap_info.base_dn_str, - LdapFilter::And(vec![LdapFilter::Equality("dn".to_string(), request.dn)]), + LdapFilter::And(vec![LdapFilter::Equality( + "dn".to_string(), + request.dn.to_string(), + )]), vec![], ); let res = self.do_search_or_dse(&req).await?; @@ -557,8 +560,23 @@ impl LdapHandler { - println!("res:{:?}", entry); - Ok(vec![]) + let mut available = false; + for attr in entry.attributes.iter() { + if attr.atype == request.atype && attr.vals.contains(&request.val) { + available = true; + break; + } + } + Ok(vec![LdapOp::CompareResult(LdapResultOp { + code: if available { + LdapResultCode::CompareTrue + } else { + LdapResultCode::CompareFalse + }, + matcheddn: request.dn, + message: "".to_string(), + referral: vec![], + })]) } _ => Err(LdapError { code: LdapResultCode::NoSuchObject,