mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
Map ldap fields to internal fields
This commit is contained in:
parent
c48da8b758
commit
9459f53a13
@ -28,8 +28,8 @@ impl Default for Configuration {
|
|||||||
http_port: 17170,
|
http_port: 17170,
|
||||||
secret_pepper: String::from("secretsecretpepper"),
|
secret_pepper: String::from("secretsecretpepper"),
|
||||||
ldap_base_dn: String::from("dc=example,dc=com"),
|
ldap_base_dn: String::from("dc=example,dc=com"),
|
||||||
ldap_user_dn: String::new(),
|
ldap_user_dn: String::from("cn=admin,dc=example,dc=com"),
|
||||||
ldap_user_pass: String::new(),
|
ldap_user_pass: String::from("password"),
|
||||||
database_url: String::from("sqlite://users.db?mode=rwc"),
|
database_url: String::from("sqlite://users.db?mode=rwc"),
|
||||||
verbose: false,
|
verbose: false,
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,26 @@ fn is_subtree(subtree: &[(String, String)], base_tree: &[(String, String)]) -> b
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn map_field(field: &str) -> Result<String> {
|
||||||
|
Ok(if field == "uid" {
|
||||||
|
"user_id".to_string()
|
||||||
|
} else if field == "mail" {
|
||||||
|
"email".to_string()
|
||||||
|
} else if field == "cn" {
|
||||||
|
"display_name".to_string()
|
||||||
|
} else if field == "givenName" {
|
||||||
|
"first_name".to_string()
|
||||||
|
} else if field == "sn" {
|
||||||
|
"last_name".to_string()
|
||||||
|
} else if field == "avatar" {
|
||||||
|
"avatar".to_string()
|
||||||
|
} else if field == "creationDate" {
|
||||||
|
"creation_date".to_string()
|
||||||
|
} else {
|
||||||
|
bail!("Unknown field: {}", field);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn convert_filter(filter: &LdapFilter) -> Result<RequestFilter> {
|
fn convert_filter(filter: &LdapFilter) -> Result<RequestFilter> {
|
||||||
match filter {
|
match filter {
|
||||||
LdapFilter::And(filters) => Ok(RequestFilter::And(
|
LdapFilter::And(filters) => Ok(RequestFilter::And(
|
||||||
@ -93,7 +113,7 @@ fn convert_filter(filter: &LdapFilter) -> Result<RequestFilter> {
|
|||||||
)),
|
)),
|
||||||
LdapFilter::Not(filter) => Ok(RequestFilter::Not(Box::new(convert_filter(&*filter)?))),
|
LdapFilter::Not(filter) => Ok(RequestFilter::Not(Box::new(convert_filter(&*filter)?))),
|
||||||
LdapFilter::Equality(field, value) => {
|
LdapFilter::Equality(field, value) => {
|
||||||
Ok(RequestFilter::Equality(field.clone(), value.clone()))
|
Ok(RequestFilter::Equality(map_field(field)?, value.clone()))
|
||||||
}
|
}
|
||||||
_ => bail!("Unsupported filter"),
|
_ => bail!("Unsupported filter"),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user