diff --git a/src/main.rs b/src/main.rs index 9164b2a..886f24c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,7 @@ pub enum AuthError { #[derive(Debug)] struct LdapUser { pub dn: String, + pub groups: Vec, pub mail: Vec, pub services: Vec, } @@ -69,7 +70,7 @@ fn auth_user(auth: &BasicAuthentication) -> Result { }; let filter = format!("(uid={})", auth.username); - let s = match ldap.search(&base, Scope::Subtree, &filter, vec!["mail", "enabledService"]) { + let s = match ldap.search(&base, Scope::Subtree, &filter, vec!["mail", "enabledService", "memberOf"]) { Ok(result) => { let (rs, _) = result.success().unwrap(); rs @@ -87,10 +88,15 @@ fn auth_user(auth: &BasicAuthentication) -> Result { Some(mail) => mail.to_vec(), None => [].to_vec(), }; + let groups = match se.attrs.get("memberOf") { + Some(groups) => groups.to_vec(), + None => [].to_vec(), + }; info!("Authentication success for {:?}", base); Ok(LdapUser { dn: base, + groups: groups, mail: mail, services: services, })