2026-09-01 17:57:42 +02:00
|
|
|
use ldap3_proto::LdapMsg;
|
|
|
|
|
|
2026-09-01 19:06:33 +02:00
|
|
|
use crate::db::{Database, DatabaseInterface};
|
2026-09-01 17:57:42 +02:00
|
|
|
use crate::ldap::{LdapStream, LdapStreamError};
|
|
|
|
|
|
2026-09-01 19:06:33 +02:00
|
|
|
#[tracing::instrument(name = "ldap", skip(s, db), fields(session = %s.session))]
|
|
|
|
|
pub async fn ldap_handler<D: DatabaseInterface>(mut s: LdapStream, db: Database<D>) {
|
2026-09-01 17:57:42 +02:00
|
|
|
tracing::info! {
|
|
|
|
|
remote_addr = ?s.remote_addr,
|
|
|
|
|
"New client connection"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
loop {
|
|
|
|
|
match s.next().await {
|
|
|
|
|
Ok(msg) => {
|
|
|
|
|
if let Err(e) = ldap_handler_inner(msg).await {
|
|
|
|
|
tracing::debug!(
|
|
|
|
|
reason = ?e,
|
|
|
|
|
"Failed to respond"
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Err(e) => {
|
|
|
|
|
tracing::debug!(
|
|
|
|
|
reason = ?e,
|
|
|
|
|
"Closing connection"
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn ldap_handler_inner(msg: LdapMsg) -> Result<(), LdapStreamError> {
|
|
|
|
|
tracing::debug!(msg = ?msg, "Received LDAP message");
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|