WHY IS IT NOT WORKING

This commit is contained in:
selfhoster selfhoster 2026-09-03 20:31:28 +02:00
commit 1626fb0624
5 changed files with 27 additions and 10 deletions

View file

@ -2,9 +2,30 @@ use ldap3_proto::LdapMsg;
use ldap3_proto::proto::LdapOp;
use crate::db::{Database, DatabaseInterface};
use crate::error::GlobalError;
use crate::ldap::{
LdapClientState, LdapStream, LdapStreamError, op_bind, op_ext, search_by_mail_filter,
};
use crate::listener::Listener;
pub async fn ldap_listen<D: DatabaseInterface>(listener: Listener, db: Database<D>) {
// If the connection is None, it's because the client aborted early
// so there's nothing to do about it.
loop {
match listener.accept_ldap().await {
Ok(Some(stream)) => {
let db = db.clone();
tokio::spawn(ldap_handler(stream, db));
}
Ok(None) => {
panic!("LDAP listener closed");
}
Err(e) => {
panic!("Failed to listen on LDAP listener");
}
}
}
}
#[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>) {

View file

@ -5,7 +5,7 @@ pub use dn::{Dn, MalformedDn};
mod filter;
mod handler;
mod op;
pub use handler::ldap_handler;
pub use handler::ldap_listen;
pub use op::bind::{BindDn, op_bind};
pub use op::ext::op_ext;
pub use op::search::search_by_mail_filter;

View file

@ -153,7 +153,7 @@ fn search_entry_from_user(user: &User, req_attrs: &[String]) -> LdapSearchResult
for attr in req_attrs {
if let Some(attr_value) = match attr.as_str() {
"uid" => Some(user.username.clone()),
"cn"|"mail" => Some(user.mail.clone()),
"cn" | "mail" => Some(user.mail.clone()),
_ => {
tracing::warn!("Ignoring unknown attr in search query: {attr}");
None