【问题标题】:Connecting to Exchange via EWS API - Kerberos authentication - from Windows通过 EWS API 连接到 Exchange - Kerberos 身份验证 - 从 Windows
【发布时间】:2019-09-12 11:51:14
【问题描述】:

我需要从 Windows 连接到 Exchange Server(通过 EWS api)并下载带有附件的邮件。所以我创建了下面的脚本。使用 Kerberos 进行身份验证进行交换。 主要问题是:

  1. 此代码可以使用吗?还是应该使用其他模块进行连接?主要是关于使用 Kerberos 连接到 Exchange 的部分。
  2. 我需要关注哪些事情,或者我应该先检查一下?

我使用 Exchangelib 连接到 Exchange。问题与 Exchangelib 有关,任何人都像我一样在类似的情况下使用它(从 Windows 通过 Kerberos 连接到 EWS)?

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)

【问题讨论】:

    标签: python exchange-server exchangewebservices kerberos exchangelib


    【解决方案1】:

    使用 Kerberos 身份验证,代码需要在您的环境中存在有效票证,因此您的 Python 代码不需要用户名和密码。只需按照https://github.com/ecederstrand/exchangelib#setup-and-connecting 中的说明使用ServiceAccount('', '')

    我不知道如何在 Windows 上创建或检查有效的 Kerberos 票证。在 Linux 上,我会使用 kinit 和 klist。

    请注意,exchangelib 中的 Kerberos 支持未经测试和实验。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      • 1970-01-01
      • 1970-01-01
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多