I've been trying to write a script to move user profile directories, and
so far not so good. Made the mistake of allowing windows to create the
profile dir in the user's homedir, and am attempting to rectify after
the fact. really do not want to go from machine to machine to deal with
this manually as it's monumentally inefficient.
Some symptoms are the inability to manage the profile on the workstation
- in my computer->properties->advanced->user profiles, copy and delete
are greyed out for the affected account, even for local admin.
I've tried to use the root postexec in smb.conf from the homes stanza to
trigger the move when the user logs off. Everything moves but seem to
be having the above issues with the profiles once they move.
using smb-tools to update ldap with the correct profile path, but I'm
wondering if something in the ntuser.dat or some other binary file needs
to be changed as well.
"windows is so cool" (!%@%#&@&!~)
Depending on primary group membership the users profile is moved to the
appropriate server
Here's the script.
#!/bin/bash
# this script is called by samba's root postexec from the user's home
directory.
# it checks to see if the user's profile is in the users home dir. If
so, it is
# moved to the samba/profiles directory, and ldap is updated to reflect
the change
# if the user has no profile directory, one is created.
# JD 4/2/2008
if ( [ -z $1 ] || [ -z $2 ] ); then
echo ""
echo
"****************************************************************************"
echo "* Moves user profiles from their home directory to the
profile directory on"
echo "* //staff or //teach, depending on group membership, and
updates their LDAP"
echo "* entry accordingly"
echo
"****************************************************************************"
echo ""
echo "usage: profiles.sh <userid> <group>"
echo ""
else
if [ $2 = "staff" ]; then
server="staff"
elif [ $2 = "teachers" ]; then
server="teach"
elif [ $2 = "students" ]; then
server="teach"
else exit
fi
# echo "$server is the server" >>
/net/staff/home/samba/netlogon/scripts/profiles.txt
if [ ! -d /net/$server/home/samba/profiles/$1 ]; then
if [ -d /net/$server/home/$1/profile ]
then
echo "$1 Needs to have their profile moved"
>>
/net/staff/home/samba/netlogon/scripts/profiles.txt
smbldap-usermod -F "\\\\$server\\profiles\\$1"
$1
mv /net/$server/home/$1/profile
/net/$server/home/samba/profiles/$1
echo "$(date) Profile moved for $1" >>
/net/staff/home/samba/netlogon/scripts/profiles.txt
else
echo "$(date) $1 has no existing profile
directory" >> /net/staff/home/samba/netlogon/scripts/profiles.txt
mkdir /net/$server/home/samba/profiles/$1
chown $1:$2 /net/$server/home/samba/profiles/$1
smbldap-usermod -F "\\\\$server\\profiles\\$1"
$1
echo "$(date) Profile directory created for
$1"
>> /net/staff/home/samba/netlogon/scripts/profiles.txt
fi
fi
fi