fmt: fmt and clippy

This commit is contained in:
silver 2023-06-18 18:34:27 +01:00
parent a990f31a45
commit 9cba5ce94a

View file

@ -1,7 +1,7 @@
use std::env;
use dotenv::dotenv;
use ldap3::{LdapConn, Mod};
use skynet_ldap_server::{Config, get_config};
use skynet_ldap_server::{get_config, Config};
use std::env;
#[async_std::main]
async fn main() -> tide::Result<()> {
@ -13,7 +13,6 @@ async fn main() -> tide::Result<()> {
Ok(())
}
//async fn update_users(config: &Config) {
//}
@ -35,14 +34,14 @@ async fn update_admin(config: &Config) -> tide::Result<()>{
Ok(())
}
async fn update_group(config: &Config, group: &str, users: &Vec<&str>, replace: bool) -> tide::Result<()>{
async fn update_group(config: &Config, group: &str, users: &[&str], replace: bool) -> tide::Result<()> {
let mut ldap = LdapConn::new(&config.ldap_host)?;
// use the admin account
ldap.simple_bind(&config.ldap_admin, &config.ldap_admin_pw)?.success()?;
let dn = format!("cn={},ou=groups,dc=skynet,dc=ie", group);
let members = users.clone().into_iter().map(|uid| uid_to_dn(uid)).collect();
let members = users.iter().map(|uid| uid_to_dn(uid)).collect();
let mods = if replace {
vec![Mod::Replace("member".to_string(), members)]
} else {
@ -54,7 +53,7 @@ async fn update_group(config: &Config, group: &str, users: &Vec<&str>, replace:
}
let dn_linux = format!("cn={}-linux,ou=groups,dc=skynet,dc=ie", group);
let members_linux = users.clone().into_iter().map(|uid| uid.to_string()).collect();
let members_linux = users.iter().map(|uid| uid.to_string()).collect();
let mods = if replace {
vec![Mod::Replace("memberUid".to_string(), members_linux)]
} else {