mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
implemented ldap compare
This commit is contained in:
parent
7d67ce7050
commit
9b130947db
@ -547,7 +547,10 @@ impl<Backend: BackendHandler + LoginHandler + OpaqueHandler> LdapHandler<Backend
|
|||||||
async fn do_compare(&mut self, request: LdapCompareRequest) -> LdapResult<Vec<LdapOp>> {
|
async fn do_compare(&mut self, request: LdapCompareRequest) -> LdapResult<Vec<LdapOp>> {
|
||||||
let req = make_search_request::<String>(
|
let req = make_search_request::<String>(
|
||||||
&self.ldap_info.base_dn_str,
|
&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![],
|
vec![],
|
||||||
);
|
);
|
||||||
let res = self.do_search_or_dse(&req).await?;
|
let res = self.do_search_or_dse(&req).await?;
|
||||||
@ -557,8 +560,23 @@ impl<Backend: BackendHandler + LoginHandler + OpaqueHandler> LdapHandler<Backend
|
|||||||
})?;
|
})?;
|
||||||
match entry {
|
match entry {
|
||||||
LdapOp::SearchResultEntry(entry) => {
|
LdapOp::SearchResultEntry(entry) => {
|
||||||
println!("res:{:?}", entry);
|
let mut available = false;
|
||||||
Ok(vec![])
|
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 {
|
_ => Err(LdapError {
|
||||||
code: LdapResultCode::NoSuchObject,
|
code: LdapResultCode::NoSuchObject,
|
||||||
|
Loading…
Reference in New Issue
Block a user