Add LDAP group memberships to returned data
This commit is contained in:
parent
f32681d95d
commit
998e3de74b
|
@ -48,6 +48,7 @@ pub enum AuthError {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct LdapUser {
|
struct LdapUser {
|
||||||
pub dn: String,
|
pub dn: String,
|
||||||
|
pub groups: Vec<String>,
|
||||||
pub mail: Vec<String>,
|
pub mail: Vec<String>,
|
||||||
pub services: Vec<String>,
|
pub services: Vec<String>,
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ fn auth_user(auth: &BasicAuthentication) -> Result<LdapUser, AuthError> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let filter = format!("(uid={})", auth.username);
|
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) => {
|
Ok(result) => {
|
||||||
let (rs, _) = result.success().unwrap();
|
let (rs, _) = result.success().unwrap();
|
||||||
rs
|
rs
|
||||||
|
@ -87,10 +88,15 @@ fn auth_user(auth: &BasicAuthentication) -> Result<LdapUser, AuthError> {
|
||||||
Some(mail) => mail.to_vec(),
|
Some(mail) => mail.to_vec(),
|
||||||
None => [].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);
|
info!("Authentication success for {:?}", base);
|
||||||
Ok(LdapUser {
|
Ok(LdapUser {
|
||||||
dn: base,
|
dn: base,
|
||||||
|
groups: groups,
|
||||||
mail: mail,
|
mail: mail,
|
||||||
services: services,
|
services: services,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue