|
|
@@ -1,4 +1,4 @@
|
|
|
-use ldap3::{Ldap, LdapConnAsync, LdapError};
|
|
|
+use ldap3::{Ldap, LdapConnAsync, LdapConnSettings, LdapError};
|
|
|
use deadpool::managed::{self, Pool};
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
@@ -8,6 +8,7 @@ pub struct LdapConfig {
|
|
|
pub basedn: String,
|
|
|
pub binddn: String,
|
|
|
pub bindpw: String,
|
|
|
+ pub starttls: bool,
|
|
|
}
|
|
|
|
|
|
pub struct LdapManager {config: LdapConfig}
|
|
|
@@ -23,8 +24,10 @@ impl managed::Manager for LdapManager {
|
|
|
type Error = LdapError;
|
|
|
|
|
|
async fn create(&self) -> Result<Self::Type, Self::Error> {
|
|
|
+ let ldap_settings = LdapConnSettings::new()
|
|
|
+ .set_starttls(self.config.starttls);
|
|
|
let ldap_url = format!("ldap://{}:{}", self.config.hostname, self.config.port);
|
|
|
- let (conn, ldap) = LdapConnAsync::new(&ldap_url)
|
|
|
+ let (conn, ldap) = LdapConnAsync::with_settings(ldap_settings, &ldap_url)
|
|
|
.await?;
|
|
|
ldap3::drive!(conn);
|
|
|
Ok(ldap)
|