feat: Search queries by mail attribute
This commit is contained in:
parent
7527ba7a09
commit
c77223048c
9 changed files with 592 additions and 78 deletions
|
|
@ -2,7 +2,9 @@ use ldap3_proto::LdapMsg;
|
|||
use ldap3_proto::proto::LdapOp;
|
||||
|
||||
use crate::db::{Database, DatabaseInterface};
|
||||
use crate::ldap::{LdapClientState, LdapStream, LdapStreamError, op_bind, op_ext};
|
||||
use crate::ldap::{
|
||||
LdapClientState, LdapStream, LdapStreamError, op_bind, op_ext, search_by_mail_filter,
|
||||
};
|
||||
|
||||
#[tracing::instrument(name = "ldap", skip(stream, db), fields(session = %stream.session))]
|
||||
pub async fn ldap_handler<D: DatabaseInterface>(mut stream: LdapStream, mut db: Database<D>) {
|
||||
|
|
@ -79,11 +81,21 @@ pub async fn ldap_handler_inner<D: DatabaseInterface>(
|
|||
client_state.bind(bound_dn);
|
||||
Ok(true)
|
||||
} else {
|
||||
tracing::debug!("Unsuccessful bind");
|
||||
// TODO: abort connection here?
|
||||
Ok(false)
|
||||
client_state.unbind();
|
||||
tracing::debug!("Failed bind or anonymous bind");
|
||||
// We keep the connection open in case it's an anonymous bind
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
LdapMsg {
|
||||
msgid,
|
||||
op: LdapOp::SearchRequest(sr),
|
||||
// TODO: ctrl for pagination
|
||||
ctrl: _,
|
||||
} => {
|
||||
search_by_mail_filter(stream, db, sr, msgid).await?;
|
||||
Ok(true)
|
||||
}
|
||||
// Unsupported message
|
||||
_ => {
|
||||
tracing::warn!("Unsupported client message, closing connection");
|
||||
|
|
|
|||
Loading…
Reference in a new issue