diff --git a/bin/lib/ldap.py b/bin/lib/ldap.py index dfee7e3..f8d427d 100644 --- a/bin/lib/ldap.py +++ b/bin/lib/ldap.py @@ -108,3 +108,17 @@ class Ldap: return True + def update_user(self, email, field, value): + """ + Mettre à jour un champ. + """ + if not validate_email(email): + return False + + # Construire le DN + dn = f"cn={email},ou=users,{self.ldap_root}" + + mod_attrs = [(ldap.MOD_REPLACE, field, value)] + + self.ldap_connection.modify_s(dn, mod_attrs) + return True diff --git a/bin/lib/misc.py b/bin/lib/misc.py new file mode 100644 index 0000000..fd4ad39 --- /dev/null +++ b/bin/lib/misc.py @@ -0,0 +1,12 @@ +import os + +def get_disk_size(path): + total_size = 0 + for dirpath, dirnames, filenames in os.walk(path): + for f in filenames: + fp = os.path.join(dirpath, f) + # skip if it is symbolic link + if not os.path.islink(fp): + total_size += os.path.getsize(fp) + + return total_size \ No newline at end of file