2012-02-02 119 views
0

我有一个.htaccess文件,它使用mod_auth_ldap对LDAP进行身份验证。我的要求是以某种方式存储他们的用户名并在其他地方使用**。我想我可以用mod_rewrite和cookies来完成。mod_auth_ldap mod_rewrite将用户名设置为cookie

AuthBasicProvider ldap 
AuthType Basic 
AuthName "xxx" 
AuthzLDAPAuthoritative off 

AuthLDAPUrl "xxx" NONE 
AuthLDAPBindDN "xx" 
AuthLDAPBindPassword xx 

Require valid-user 

-

RewriteCond %{HTTP_COOKIE} !(username) 
RewriteRule ^(.*)$ - [L,CO=username:%{USERNAME}:.domain.com] 

如果有人想告诉我的cookies是垃圾的想法,有一个更好的,请做。

非常感谢。

**我注意到使用cookie的用户名有安全隐患,但在我的应用程序中这是可以接受的。

回答

0

魔术变量为%{REMOTE_USER}。

RewriteEngine on 
RewriteCond %{HTTP_COOKIE} !username 
RewriteRule ^(.*)$ - [L,CO=username:%{REMOTE_USER}:.domain.com]