Sysadmin scripts to create Users in school


(Stéphane de Labrusse) #1

Just for the sake of my curiosity, I recall the need of your french colleague (sysadmin in a french school, about 900 account and 400 computers), each year he deletes all the accounts and recreates new one. He uses the lazzy-admin-tools on SME-Server for this purpose, I am not sure we have the same thing here


Delete user from active directory
(Carlo Minucci) #2

For import new user i follow this step http://docs.nethserver.org/en/v7/accounts.html#import-accounts-from-plain-text-files

For delete i don’t know if exist a script, i delete from web interface one at a time :slight_smile:


(Stéphane de Labrusse) #3

How many users you delete each years ?


(Carlo Minucci) #4

i need to delete about 50 users each year but i’m very lazy… i don’t delete all :slightly_smiling_face:
i have a lot of unused user in my server :smiley:


(Stéphane de Labrusse) #5

I recall a discussion like that with @robb about sysadmin work at school every year to create users


(Stéphane de Labrusse) #6

I talked about something like that : https://wiki.contribs.org/Lazy_Admin_Tools


(Stéphane de Labrusse) #7

@dev_team

a quick hack of the import_users to delete a list of users, do you think we could add it to nethserver-sssd ?

https://gist.github.com/stephdl/e3f65a0c433c6f1b616eb4215b35f111

it takes only one argument in a file, you can decide what is the separator (default one user per line)

Use either username or username@domainName

tips: you should be able to delete users from the list you used to create them


(Stéphane de Labrusse) #8

a script to delete all users, before to recreate them by a script

this time for fun I tried PHP @davidep


(Giacomo Sanchietti) #9

I like the idea.
Just a couple:


(Carlo Minucci) #10

can you explain me this line of code?

if( ! esmith::event::event_signal(‘user-delete’, $username) ) {

what is event_signal?


(Stéphane de Labrusse) #11

if the event_signal fails (return a code 1) then a warn is displayed, event_signal is the equivalent of signal-event but this time it used only in perl script (esmith::event::event_signal(‘user-delete’, $username))


(Emiliano Vavassori) #12

We modified the import script from nethserver-mail package to import/delete and create needed groups inside NS. This is supported on 6.x version but I cannot assure on 7.x (probably it does). Also, we don’t have any web interface for the feature but it is fine.

Here are the sources https://git.libreschool.org/LibreSchool/nethserver-usercsvimport

All credits go to @paspo anyways.