UserConfiguration

This documentation provides details about the UserConfiguration class within the pyews package.

This class is used in the ServiceEndpoint parent class and all inherited child classes.

UserConfiguration is the main class of pyews.

It is used by all other ServiceEndpoint parent and child classes.
This class represents how you authorize communication with all other SOAP requests throughout this package.

Examples:

The UserConfiguration class is the main class used by all services, including the parent class of services called ServiceEndpoint.

A UserConfiguration object contains detailed information about how to communicate to Exchange Web Services, as well as additional properties

The traditional UserConfiguration object can be created by just passing in a username and password. This will attempt to connect using Autodiscover and will attempt every version of Exchange.

userConfig = UserConfiguration(
    'first.last@company.com',
    'mypassword123'
)

If you the know the Exchange version you want to communicate with you can provide this information:

userConfig = UserConfiguration(
    'first.last@company.com',
    'mypassword123',
    exchangeVersion='Office365'
)

If you do not wish to use Autodiscover then you can tell UserConfiguration to not use it by setting autodiscover to False and provide the ewsUrl instead

userConfig = UserConfiguration(
    'first.last@company.com',
    'mypassword123',
    autodiscover=False,
    ewsUrl='https://outlook.office365.com/EWS/Exchange.asmx'
)

If you would like to use impersonation, you first need to create an Impersonation object and pass that into the UserConfiguration class when creating a user configuration object.

impersonation = Impersonation(primarysmtpaddress='first.last@company.com')

userConfig = UserConfiguration(
    'first.last@company.com',
    'mypassword123',
    autodiscover=False,
    ewsUrl='https://outlook.office365.com/EWS/Exchange.asmx',
    impersonation=impersonation
)
Args:

username (str): An email address or username that you use to authenticate to Exchange Web Services password (str): The password that you use to authenticate to Exchange Web Services exchangeVersion (str, optional): Defaults to None. A string representation of the version of Exchange you are connecting to.

If no version is provided then we will attempt to use Autodiscover to determine this version from all approved versions

ewsUrl (str, optional): Defaults to None. An alternative Exchange Web Services URL. autodiscover (bool, optional): Defaults to True. If you don’t want to use Autodiscover then set this to False, but you must provide a ewsUrl. impersonation (bool, optional): Defaults to False. If your credentials have impersonation rights then you can set this value to True to impersonate another user

but you must provide either a principalname, sid, primarysmtpaddress, or smtpaddress to do so.

principalname ([type], optional): Defaults to None. Only used when impersonation is set to True. The PrincipalName of the account you want to impersonate sid ([type], optional): Defaults to None. Only used when impersonation is set to True. The SID of the account you want to impersonate primarysmtpaddress ([type], optional): Defaults to None. Only used when impersonation is set to True. The PrimarySmtpAddress of the account you want to impersonate smtpaddress ([type], optional): Defaults to None. Only used when impersonation is set to True. The SmtpAddress of the account you want to impersonate

Raises:
IncorrectParameters: Provided an incorrect configuration of parameters to this class
pyews.UserConfiguration.impersonation