ews autodiscovery script proposal
Hi folk.
It is quite hard for new user to configure evolution-ews plugin and start reading mail from MS Exchange.
I tried to start using evolution-ews in big organization and realized that there is no any autodiscovery mechanism.
So my main goal is Outlook-like user expirence for new users.
Users computers are joined to AD domain with samba+winbind.
I wrote script, and put it into autostart folder in /etc/skel/
My script can be found there: https:/
So I want to know - may be it is usefull for community...
-------
#! /bin/bash
export GIO_USE_
DOMAINNAME=
#######
### Check if Evolution EWS source files already exist. If exist - exit 0
#######
for f in ~/.config/
#######
## Check if connected to AD
#######
if ! wbinfo -P; then
echo "NETLOGON test failed" >> ~/.ews_setup.log
else
echo "NETLOGON test OK" >> ~/.ews_setup.log
CURRENT_DC=`wbinfo -P | awk '{print $9}' | awk -F "\"" '{print $2}'`
FULL_NAME=`wbinfo -i $USER | awk -F ":" '{print $5}'`
BASEDN=`echo $CURRENT_DC | sed s/"\."/,dc=/g | sed -r 's!^[^dc=]+!!'`
MAIL=`ldapsearch -h $CURRENT_DC -b "$BASEDN" "sAMAccountName
NAME_PREFIX=`date +%s.%N | cut -c 1-16`
#######
### MS Exchange autodiscovery
#### Joined AD with samba/winbind and have package gss-ntlmssp
#######
AUTOD_URL="https:/
REQUEST=$(cat <<EOF
<Autodiscover xmlns="http://
<Request>
<EMailAddress>
<AcceptableResp
</Request>
</Autodiscover>
EOF
)
bash -c "curl -k -d '$REQUEST' --header \"Content-Type: text/xml\" -s --negotiate -u : $AUTOD_URL" > ~/.autodiscover.xml
OABUrl=$(cat ~/.autodiscover.xml | grep -m 1 OABUrl | awk -F '[<>]' '{ print $3 }')oab.xml
EwsUrl=$(cat ~/.autodiscover.xml | grep -m 1 EwsUrl | awk -F '[<>]' '{ print $3 }')
EwsHost=$(echo $EwsUrl | awk -F '/' '{ print $3 }')
rm ~/.autodiscover.xml
echo CURRENT_DC - $CURRENT_DC > ~/.ews_setup.log
echo FULL_NAME - $FULL_NAME >> ~/.ews_setup.log
echo BASEDN - $BASEDN >> ~/.ews_setup.log
echo MAIL - $MAIL >> ~/.ews_setup.log
echo DOMAINNAME - $DOMAINNAME >> ~/.ews_setup.log
echo OABUrl - $OABUrl >> ~/.ews_setup.log
echo EwsUrl - $EwsUrl >> ~/.ews_setup.log
echo EwsHost - $EwsHost >> ~/.ews_setup.log
#######
### Check URLs format
#######
echo $OABUrl | grep -E '(https|
OAB_URL_Check=$?
echo $EwsUrl | grep -E '(https|
EWS_URL_Check=$?
if [ $OAB_URL_Check != 0 ] || [ $EWS_URL_Check != 0 ]; then
echo "OAB and EWS URLs check failed... Exit..." >> ~/.ews_setup.log
else
echo "OAB and EWS URLs check OK" >> ~/.ews_setup.log
#######
### CleaningUp and creating evolution source files
#######
killall evolution-
rm -Rf ~/.config/
mkdir --parents ~/.config/
#######
cat <<EOF > ~/.config/
[Data Source]
DisplayName=$MAIL
Enabled=true
Parent=
[Offline]
StaySynchronize
[Authentication]
Host=$EwsHost
Method=GSSAPI
Port=443
ProxyUid=
RememberPasswor
User=$USER
CredentialName=
[Collection]
BackendName=ews
CalendarEnabled
ContactsEnabled
Identity=$USER
MailEnabled=true
[Security]
Method=none
[Ews Backend]
FilterInbox=true
StoreChangesInt
CheckAll=true
ListenNotificat
Email=$MAIL
FilterJunk=true
FilterJunkInbox
FoldersInitiali
GalUid=
Hosturl=$EwsUrl
Oaburl=$OABUrl
OabOffline=true
OalSelected=
Timeout=300
UseImpersonatio
ImpersonateUser=
EOF
#######
cat <<EOF > ~/.config/
[Data Source]
DisplayName=$MAIL
Enabled=true
Parent=
[Mail Composition]
Bcc=
Cc=
DraftsFolder=
SignImip=true
TemplatesFolder
[Mail Identity]
Address=$MAIL
Name=$FULL_NAME
Organization=
ReplyTo=
SignatureUid=
[Mail Submission]
SentFolder=
TransportUid=
RepliesToOrigin
EOF
#######
cat <<EOF > ~/.config/
[Data Source]
DisplayName=$MAIL
Enabled=true
Parent=
[Refresh]
Enabled=true
IntervalMinutes=3
[Mail Account]
BackendName=ews
IdentityUid=
ArchiveFolder=
EOF
#######
cat <<EOF > ~/.config/
[Data Source]
DisplayName=$MAIL
Enabled=true
Parent=
[Mail Transport]
BackendName=ews
EOF
#######
cat <<EOF > ~/.config/
# Special built-in mail store.
[Data Source]
DisplayName=On This Computer
Enabled=false
Parent=
[Mail Account]
BackendName=maildir
IdentityUid=self
ArchiveFolder=
[Maildir Backend]
FilterInbox=true
Path=$HOME/
EOF
#######
cat <<EOF > ~/.config/
# Special built-in mail store.
[Data Source]
DisplayName=Search Folders
Enabled=false
Parent=
[Mail Account]
BackendName=vfolder
IdentityUid=self
ArchiveFolder=
[Vfolder Backend]
FilterInbox=true
EOF
#######
mkdir --parents ~/.config/
cat <<EOF > ~/.config/
[GlobalFolder]
GroupByThreads=
PreviewVisible=true
[Store $NAME_PREFIX.
Expanded=true
[Search Bar]
SearchScope=
SearchOption=
[Folder Tree]
Selected=
[Folder folder:
GroupByThreads=
PreviewVisible=true
Expanded=true
EOF
#######
### Create Signature
cat <<EOF > ~/.config/
[Data Source]
DisplayName=$MAIL
Enabled=true
Parent=
[Mail Signature]
MimeType=text/html
EOF
mkdir --parents ~/.config/
cat <<EOF > ~/.config/
<html><
EOF
fi
fi
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- actionparsnip
- Solved:
- Last query:
- Last reply: