0

I login to our MS Exchange 2003 server via NTLM and can send messages with smtplib module. Is there a way to detect my email address (which will be specified in From: field of a message) based on NTLM username.

When one adds new Exchange account in Windows it asks for server address and username which can be resolved to an e-mail address (or several addresses if username is ambiguous) with a 'Check name' button. It's done even before logging in to server.

check name button

Related:

https://github.com/xulz/python-ntlm

SMTP through Exchange using Integrated Windows Authentication (NTLM) using Python

Upd: i think it uses NSPI ambiguous name resolution (ANR), and i also think that spending time on this isn't worth it.)

Community
  • 1
  • 1
Winand
  • 2,093
  • 3
  • 28
  • 48

1 Answers1

0

You might want to try and do it with Active Directory using pyad:

def get_user_email_address(name):
    try:
        from pyad import aduser
        user = aduser.ADUser.from_cn(name)
        return user.get_attribute('mail')
    except e:
        return None
splintor
  • 9,924
  • 6
  • 74
  • 89
  • 1
    i get `WARN: unable to connect to default domain. Computer is likely not attached to an AD domain` when trying to import `pyad`. Though the PC is actually connected to a domain. – Winand Sep 01 '16 at 10:55