diff --git a/README.md b/README.md index 908fd5f..ee54c08 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,35 @@ Configuration values are as follows: |`ldap_sync_interval_seconds`|Integer|Optional|Number of seconds to wait between each LDAP request. Defaults to `60`| |`ldap_sync_loop`|Boolean|Optional|Indicates whether or not syncing should be polled in a loop or done once. Defaults to `true`| +## Testing + +All testing is manual right now. First step is to set up Bitwarden and the LDAP server. + +```bash +docker-compose up -d bitwarden ldap ldap_admin +``` + +1. After that, open the admin portal on http://localhost:8001 and log in using the default account info: + + Username: cn=admin,dc=example,dc=org + Password: admin + +From there you can set up your test group and users. + +2. Expand the `dc=example,dc=org` nav tree and select "Create new entry here" +3. Select "Generic: Posix Group" +4. Give it a name, eg. "Users" and then save and commit +5. Select "Create child object" +6. Select "Generic: User Account" +7. Give the user a name and select a group ID number and save and commit +8. Select "Add new attribute" and select "Email" and then add a test email address + +9. Run the ldap sync + +```bash +docker-compose up ldap_sync +``` + ## Future * Any kind of proper logging diff --git a/docker-compose.yml b/docker-compose.yml index fb1f223..365440c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,8 @@ services: # dockerfile: Dockerfile.alpine volumes: - ./example.config.toml:/usr/src/bitwarden_rs_ldap/config.toml:ro - # - ./example.config.toml:/config.toml:ro + environment: + RUST_BACKTRACE: 1 restart: always bitwarden: diff --git a/src/main.rs b/src/main.rs index 1e05acb..387417a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,7 +115,11 @@ fn invite_from_ldap( let mut num_users = 0; for ldap_user in search_entries(config)? { // Safely get first email from list of emails in field - if let Some(user_email) = ldap_user.attrs.get(mail_field.as_str()).and_then(|l| (l.first())) { + if let Some(user_email) = ldap_user + .attrs + .get(mail_field.as_str()) + .and_then(|l| (l.first())) + { if existing_users.contains(user_email) { println!("User with email already exists: {}", user_email); } else { @@ -125,6 +129,8 @@ fn invite_from_ldap( num_users = num_users + 1; // println!("Invite response: {:?}", response); } + } else { + println!("Warning: Email field, {:?}, not found on user", mail_field); } }