[python-win32] Re: Getting the current user's email address
12 Dec 2002 09:38:19 -0800
Jens B Jorgensen writes:
> Actually I wouldn't think this would be simple at all. Why would an IIS
> server know the email address of the user that connected to it? If the
> server is part of a native win2k domain with Active Directory then the
> directory service *might* have the user's email address.
I probably should have been clearer that this is exactly my situation; the
ASP process is part of an intranet, impersonating a local user (via
Integrated Authentication). Effectively, the process belongs to the user,
and the idea is to get at "my" Exchange account.
> Which is to say that by coincidence user principal name might be the same
> as the user's email address. That's what you can get from GetUserNameEx
> but is not the same as a user's email address even though it looks like
Right; what I wanted from GetUserNameEx is the "Fully Qualified DN", from
which I can get the LDAP string I need.
> On the other hand if you're running Exchange you may be able to get the
> user's email address through the ADSI interface to Exchange. If your
> Domain user names are mapped 1-to-1 to Mailbox names in exchange then you
> should be able to get the email address with:
> adsi_obj = GetObject('LDAP://<exchange server>/cn=<mailbox name (nt user
> name)>,cn=Recipients,ou=<whatever your ou is>,o=<whatever was set as the
> organization name>')
> email_addr = adsi_obj.Get('mail')
I can indeed get there with a string of that form; the trouble is that (here
at least) the CN has to be the user's full name ("Don Dwiggins" in my case);
the login name (which I can get from GetUserName) doesn't work as the CN.
So, aside from GetUserNameEx, do you know any good way to get the full name
of the current user? Or another way to get the FQDN?
Don Dwiggins "The truth will make you free,
email@example.com but first it will make you miserable"
-- Tom DeMarco