[Samba] Execute a user script whenever a user is added in the domain

Rowland Penny rpenny at samba.org
Sun Nov 26 12:42:38 UTC 2017


On Sun, 26 Nov 2017 12:55:53 +0100
Fabian Fritz via samba <samba at lists.samba.org> wrote:

> My DC handle the authentification and some other Samba server provide
> shares (they're pure file servers with winbind). Users get their
> personal directory as a share with appropriate permissions.
> 
> Up until now I used a Samba 3 server to both handle the
> authentification and act as a file server. I had a script to create a
> Samba user, create the personal directories and set some ZFS quota on
> it.
> 
> Now with AD I want to allow people to easily be able to create users
> with the ADUC tool. The DC now is on a separate machine then than
> file server. But I still need a way(script) to automatically create
> the directories.
> 
> I already tested using the "add user script" on the file servers, but
> since they use winbind, I guess they "find" the user and the script
> isn't executed. I think I found a solution though by using 'root
> preexec', like suggested here: https://serverfault.com/a/576142/437431
> 
> But I would still be interested in also having a way to run a script
> on the DC, to add the user to some mailing lists there.
> 
> Thanks,
> Fabian

Creating the users home directory on Unix is easy, just add:

session    required   pam_mkhomedir.so skel=/etc/skel/ umask=0022

to the end of '/etc/pam.d/common-session'

When the user logs in, their home directory will be created on the fly.
This is on debian, red-hat has something similar 'oddjob-mkhomedir' 

Or you could use pam_script to run a script the first time a user logs
on.

Rowland



More information about the samba mailing list