问题
I'm authenticating ldap users through Apache2's authnz_ldap module successfully. It is not clear to me how to fetch their username once they have logged in so that I can interact with them through any following forms/webpages. I've tried the typical ways (os.getenv os.environ getpass etc.) but they either just give me www-data or None result.
I suspect what I need is available in either an apache/ldap module, but I could use some help to search down the correct path. Can anyone point me in the right direction?
回答1:
To answer my own question: http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#exposed
Although the environment key was not documented, i threw in a few likely suspects and found that os.getenv('AUTHENTICATE_UID')
was the winner.
I hope this saves someone some time.
来源:https://stackoverflow.com/questions/12325578/python-get-user-from-apache-authnz-ldap