Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: get user from apache authnz_ldap

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?

like image 940
jreed Avatar asked May 06 '26 01:05

jreed


1 Answers

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.

like image 171
jreed Avatar answered May 08 '26 14:05

jreed