Skip to content

Commit

Permalink
Docs: Documented time stamp representation
Browse files Browse the repository at this point in the history
Fix: UTC time stamp creation is now only done
if add time stamp feature is toggled on
  • Loading branch information
BoolPurist committed May 16, 2024
1 parent 59f111a commit 2815435
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ The `conf.toml` file looks as follows:
# Timestamp is when an user was created within LDAP database user entry
# Make sure to also include the field "'ldapAttributes'" under the array "objectclass_common"
# Within the config file. Otherwise one gets an error while creating an user within LDAP.
# The timestamp is saved in the format of rfc 3339 with the UTC time zone.
# Example of date and time 'year: 2024, month: may, day: 9 and hour: 10, minutes: 49 and seconds: 34'
# 2024-05-09T10:49:34.545686277+00:00
# Link: To this rfc 3339 => https://www.rfc-editor.org/rfc/rfc3339
ldap_add_created_at = true
# Default value of the Slurm default QOS for the student group
student_default_qos = 'basic'
Expand Down
35 changes: 26 additions & 9 deletions usermgmt_lib/src/ldap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ where
where
T: LdapCredential,
{
fn add_fields<T>(
connection: &mut LdapConn,
entity: &NewEntity,
ldap_config: &LDAPConfig<T>,
fields: Vec<(&str, HashSet<&str>)>,
) -> AppResult
where
T: LdapCredential,
{
let result_from_adding = connection.add(
&format!("uid={},{}", entity.username, ldap_config.base()),
fields,
);

ldap_is_success(result_from_adding).context("Unable to create LDAP user!")?;
Ok(())
}

let un = entity.username.as_ref().as_str();
let gid = entity.group.gid().to_string();
let uid = uid.to_string();
Expand Down Expand Up @@ -134,19 +152,18 @@ where
("sshPublicKey", hashset! {pubkey}),
("loginShell", hashset! {config.login_shell.as_str()}),
];
let created_at = Utc::now().to_rfc3339();

if config.ldap_add_created_at {
let created_at = Utc::now().to_rfc3339();
let attr = hashset! {created_at.as_str()};
fields.push(("createdAt", attr));
}

let result_form_adding = connection.add(
&format!("uid={},{}", entity.username, ldap_config.base()),
fields,
);

ldap_is_success(result_form_adding).context("Unable to create LDAP user!")?;
Ok(())
add_fields(connection, entity, ldap_config, fields)?;
Ok(())
} else {
add_fields(connection, entity, ldap_config, fields)?;
Ok(())
}
})
}
}
Expand Down

0 comments on commit 2815435

Please sign in to comment.