use ldap3::exop::WhoAmI; use ldap3::{LdapConnAsync, Scope, SearchEntry}; pub async fn try_authentication() -> ldap3::result::Result<()> { println!("Hello, world!"); // let (conn, mut ldap) = LdapConnAsync::new("ldap://ldap.forumsys.com:389").await?; let (conn, mut ldap) = LdapConnAsync::new("ldap://192.168.10.200:389").await?; ldap3::drive!(conn); let res = ldap // .simple_bind("cn=read-only-admin,dc=example,dc=com", "password") .simple_bind( // "CN=Abel Austin,OU=Accounting,OU=Mylab Users,DC=mylab,DC=local", "MYLAB\\A0H67123", "Passwort123", ) .await?; println!("{res:?}"); // let (res, re) = ldap // .search( // "ou=mathematicians,dc=example,dc=com", // Scope::Subtree, // "(objectClass=*)", // vec!["*"], // ) // .await? // .success()?; // for entry in res { // println!("{:?}", SearchEntry::construct(entry)); // } let (res, re) = ldap .search( // "CN=Abel Austin,OU=Accounting,OU=Mylab Users,DC=mylab,DC=local", "OU=Mylab Users,DC=mylab,DC=local", Scope::Subtree, // "(objectClass=*)", "(&(ObjectCategory=Person)(sAMAccountName=A0H67123))", vec!["givenName", "sn"], ) .await? .success()?; for entry in res { println!("{:?}", SearchEntry::construct(entry)); } let test = ldap.extended(WhoAmI).await?.0; let whoami: ldap3::exop::WhoAmIResp = test.parse(); println!("{whoami:?}"); Ok(ldap.unbind().await?) }