-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathldaptest.rs
More file actions
32 lines (20 loc) · 760 Bytes
/
ldaptest.rs
File metadata and controls
32 lines (20 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use ldap3::*;
use std::{process::exit, vec};
use ldap3::result::Result;
fn main() {
let ldap =LdapConn::new("ldap://192.168.0.110:3268");
let mut ldapcon =match ldap{
Ok(l) => l,
Err(r) => panic!("{}",r)
};
ldapcon.simple_bind("CN=Administrator,CN=Users,DC=tech69,DC=local", "Passw0rd").unwrap();
let username = "*)(serviceprincipalname=*";
//let username = "Administrator";
let filter = "(&(objectclass=user)(samaccountname=".to_owned() + username + "))";
println!("filter: {}",filter);
let res =ldapcon.search("DC=tech69,DC=local",Scope::Subtree,&filter[..],vec!["dn"]).unwrap();
let (re,ldapresult) = res.success().unwrap();
for i in re{
println!("{:#?}",SearchEntry::construct(i).dn);
}
}