Koozali.org: home of the SME Server

my quick mandatory profiles hack

Offline tariqf

  • *****
  • 179
  • +0/-0
my quick mandatory profiles hack
« on: April 13, 2007, 11:33:24 AM »
Needed a nice easy way to manage mandatory profiles and came up with a simple perl script and modification to smb.conf;

(1) modify the smb.conf template to contain this in the [netlogon] section
"root postexec = /usr/local/sbin/logoff.pl %u"
(2) create logoff.pl containing
#!/usr/bin/perl
$user=@ARGV[0];
$usermand="$user" . "_mand";
if ($user=~"_profile" && $user!~"_mand")
{
if(not -e "/home/e-smith/files/samba/profiles/$usermand"){`mkdir /home/e-smith/files/samba/profiles/$usermand`;}
`rm -R -f /home/e-smith/files/samba/profiles/$usermand/*`;
`cp -R --reply=yes /home/e-smith/files/samba/profiles/$user/* /home/e-smith/files/samba/profiles/$usermand`;
`chmod 775 /home/e-smith/files/samba/profiles/$usermand -R`;
`chown root:$user /home/e-smith/files/samba/profiles/$usermand -R`;

if(-e "/home/e-smith/files/samba/profiles/$usermand/NTUSER.DAT"){
`mv /home/e-smith/files/samba/profiles/$usermand/NTUSER.DAT /home/e-smith/files/samba/profiles/$usermand/NTUSER.MAN`;
`chmod 744 /home/e-smith/files/samba/profiles/$usermand/NTUSER.MAN`;}

if(-e "/home/e-smith/files/samba/profiles/$usermand/ntuser.dat"){
`mv /home/e-smith/files/samba/profiles/$usermand/ntuser.dat /home/e-smith/files/samba/profiles/$usermand/ntuser.dat`;
`chmod 744 /home/e-smith/files/samba/profiles/$usermand/ntuser.man`;}

}
(3) create a new user named username_profile and log in as that user whenever you want to update or set the profile.
(4) symlink any users you want to be mandatory to the new username_profile_mand folder

This is working nicely for my purposes.

Offline haymann

  • *
  • 212
  • +0/-0
my quick mandatory profiles hack
« Reply #1 on: April 17, 2007, 04:02:02 AM »
I have been a bit sick lately so my brain might not be up to speed yet, but what exactly do you use this for? I guess I am stumbling at the mandatory profile part... What is a mandatory profile?

I am asking because it might be something that I want to setup as well, I am just not completely sure what this does :oops:

Thanks for the help,
Ryan