Im need to connect to Exchange Server (via EWS api) from Windows and download a message with attachment. So I created the script below. Exchange using Kerberos for authentication. The main questions are:
- This code will be working? Or should I use another modules to connect? Mainly the part about connecting to Exchange using the Kerberos.
- On which thing Im need to focus or should I check before?
I using Exchangelib for connect to Exchange.The problem is related to Exchangelib, anyone using this in similar case like me (connecting to EWS via Kerberos from Windows)?
from exchangelib import DELEGATE, Configuration, GSSAPI
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
from exchangelib import Account, ServiceAccount
import extract_msg
import logging.handlers
import os
import winkerberos as kerberos
from datetime import datetime
#connecting to Exchange
user='administrator@xy.test'
password='secret!@#'
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
config = Configuration(
server='172.16.41.206',
credentials = ServiceAccount(username=user, password=password),
auth_type = GSSAPI
)
account = Account(
primary_smtp_address='administrator@xy.test',
autodiscover=False,
config=config,
access_type=DELEGATE)