@asl @mark_nl @mrmarkuz @m.traeumner @planet_jeroen and all other this is what I plan to make, no hurry first we discuss of it
what I want to solve :
=> allow the imap acl to share the email box by dovecot
=> display the full name (in the top left corner)
all of this is for SambaAD (not sure that for ldap we need all of this)
for the good full displayed name
CNFieldName = cn;
should be
CNFieldName = displayName;
to allow the good imap acl
UIDFieldName = sAMAccountName;
should be
UIDFieldName = userPrincipalName;
My plan is
create a migration fragment and look after two properties UIDFieldName
and CNFieldName
-
case properties exist -> do nothing
-
case properties AND sogo mariadb do not exist-> create
UIDFieldName
and CNFieldName
with good values we want (It is a new installation)
-
case properties do not exist AND sogo mariadb exists->create
UIDFieldName
and CNFieldName
with the actual (bad) values because it is an older installation to migrate (in short do nothing and wait a manual migration if wanted)
now the live manual migration
I create a bash script, we will need the backup we do each night, in short
- create a dump of mysql (I do not like headache)
- cp backupfolder/user to backupfolder/user@domainName
- migrate some user values to user@domainName in the relevant sogo backup file
- import the backup to sogo mariadb by sogo-tool
- set the correct values of properties
UIDFieldName
and CNFieldName
- expand-template to the sogo configuration file
- restart sogo and enjoy
this is my script
#!/usr/bin/bash
#
# script to fix the bad ldap settings sogo
# stephane de labrusse <stephdl@de-labrusse.fr>
#
MYBACKUPDIR=$1
DOMAIN=$(/usr/sbin/e-smith/config get DomainName)
DATE=$(date '+%Y-%m-%d_%H_%M_%S')
if [ -z "${MYBACKUPDIR}" ]; then
exec >&2
echo "Restore the good UID user@domainName"
echo ""
echo "Usage: "
echo " " $(basename $0) "/var/lib/sogo/backups/sogo-DateOfBackup"
echo ""
exit 1
fi
echo "# dump the sogo database"
/usr/bin/mysqldump sogo > /root/sogo-MARIADB-$DATE.dump
#set good values for ldap
config setprop sogod UIDFieldName userPrincipalName CNFieldName displayName
expand-template /etc/sogo/sogo.conf
systemctl restart sogod
cd $MYBACKUPDIR
for i in `ls`
do
if [[ $i =~ $DOMAIN ]]; then
continue
fi
echo "#"
echo "#change name of $i to $i@$DOMAIN"
echo "#"
/usr/bin/cp -f $i $i\@$DOMAIN
/usr/bin/sed -i "s|/Users/$i|/Users/$i@$DOMAIN|g" $i@$DOMAIN
/usr/bin/sed -i "s|$i:|$i@$DOMAIN:|g" $i@$DOMAIN
sogo-tool restore -p $MYBACKUPDIR $i@$DOMAIN
sogo-tool restore -f ALL $MYBACKUPDIR $i@$DOMAIN
done
you call it by
myScript /var/lib/sogo/backups/sogo-2018-02-06_003
Of course what we will break is all links we did in carddav/caldav/ when we used user
in place after of user@domainName
The purpose is to let in the hand of the admin the choice to fix or not the ldap settings, new installations will start with the good values.
After that if something went wrong, restore mariadb and it is done, I tested on my server with my caldav/carddav and it seems workable