Setting CGI environment variables, dynamically, from httpd.conf leveragingexising variables

--------------030708090309050006020409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

OS: Windoze httpd: 2.2.1.6

Hello everybody and thanks for taking the time to read this posting.

I apologize, in advance, if I'm a novice. I've looked extensively and
have not found a solution -- perhaps I've completely misunderstood.

I need to instantiate a CGI environment variable $SMUSER with the
contents of
an existing environment variable, say, $REMOTE_USER.

I'm testing with setenv.pl to display the CGI environment.

I've tried 3 techniques:

Technique 1: Rewrite
--------------------

RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

Result from my browser (setenv.pl):

SMUSER=""

Question 1: The syntax is incredibly cryptic. Where might I look to help
me understand the %, e, {} etc.

Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

Result: DAVESETENV="text"

But, I've read that this is only a static string.

http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html


Technique 3. JkEnvVar.
-----------------------

If I've understood correctly, we can 'fool' HTTPD into thinking there
is a Tomcat behind and, therefore, use mod_jk.

Question 2: Am I correct ?

JkWorkersFile conf/workers.properties
JkEnvVar DAVEJKENVVAR "test"
JkLogFile "logs/mod_jk.log"
JkLogLevel debug

Result: nothing related to DAVE in the browser

Question 3: Which technique do you recommend and can you please give me
a nudge in the right direction ?

Cdlt, Dave
--------


--------------030708090309050006020409
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
OS: Windoze httpd: 2.2.1.6<br>
<br>
Hello everybody and thanks for taking the time to read this posting.<br>
<br>
I apologize, in advance, if I'm a novice. I've looked extensively and
have not found a solution -- perhaps I've completely misunderstood.<br>
<br>
I need to instantiate a CGI environment variable $SMUSER with the
contents of <br>
an existing environment variable, say, $REMOTE_USER.<br>
<br>
I'm testing with setenv.pl to display the CGI environment.<br>
<br>
I've tried 3 techniques:<br>
<br>
Technique 1: Rewrite<br>
--------------------<br>
<br>
RewriteEngine on<br>
<br>
RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]<br>
RequestHeader set my_new_header %{SMUSER}e<br>
<br>
        Result from my browser (setenv.pl):<br>
<br>
        SMUSER=""<br>
<br>
Question 1: The syntax is incredibly cryptic. Where might I look to
help me understand the %, e, {} etc.<br>
<br>
Mind you, it works for simple text:<br>
<blockquote>RewriteRule .* - [E=SMUSER:test]<br>
<br>
Result: SMUSER="test"<br>
</blockquote>
2. Technique 2: setenv DAVESETENV "text"<br>
----------------------------------------------<br>
<br>
    Result: DAVESETENV="text"<br>
  <br>
But, I've read that this is only a static string.<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.usenet-forums.com/apache-web-server/10179-setenv-dynamic-variable.html"> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html</a><br>
<br>
<br>
Technique 3. JkEnvVar.<br>
-----------------------<br>
<br>
If I've understood correctly, we can 'fool' HTTPD into thinking there <br>
is a Tomcat behind and, therefore, use mod_jk.<br>
<br>
Question 2: Am I correct ?<br>
<br>
JkWorkersFile conf/workers.properties<br>
JkEnvVar DAVEJKENVVAR "test"<br>
JkLogFile "logs/mod_jk.log"<br>
JkLogLevel debug<br>
<br>
Result: nothing related to DAVE in the browser<br>
<br>
Question 3: Which technique do you recommend and can you please give me
a nudge in the right direction ?<br>
<br>
Cdlt, Dave<br>
--------<br>
<br>
</body>
</html>

--------------030708090309050006020409--
david.donnan [ Di, 28 September 2010 16:02 ] [ ID #2048499 ]

Re: Setting CGI environment variables, dynamically,from httpd.conf leveraging exising variables

On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
<david.donnan [at] thalesgroup.com> wrote:
> RewriteEngine on
>
> RewriteRule .* - [E=3DSMUSER:%{$REMOTE_USER}]
> RequestHeader set my_new_header %{SMUSER}e
>
> =A0=A0=A0=A0=A0=A0=A0 Result from my browser (setenv.pl):
>
> =A0=A0=A0=A0=A0=A0=A0 SMUSER=3D""

I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?

>
> Question 1: The syntax is incredibly cryptic. Where might I look to help =
me
> understand the %, e, {} etc.
The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule

> Mind you, it works for simple text:
>
> RewriteRule .* - [E=3DSMUSER:test]
>
> Result: SMUSER=3D"test"
>
> 2. Technique 2: setenv DAVESETENV "text"
> ----------------------------------------------
>
> =A0=A0=A0 Result: DAVESETENV=3D"text"
>
> But, I've read that this is only a static string.
>
> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-varia=
ble.html

setenvif is a bit more flexible:
http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif

--
Eric Covener
covener [at] gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Eric Covener [ Di, 28 September 2010 16:43 ] [ ID #2048500 ]

Re: Setting CGI environment variables, dynamically,from httpd.conf leveraging exising variables

--------------050106020802040003050201
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello everybody.

Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !

httpd.conf:
RewriteEngine on
RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]

Result (setenv.pl):
...
SMUSER="<my-LDAP-userid :-) >"
...
Thanks again, Dave

PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.
------

Eric Covener wrote:
> On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
> <david.donnan [at] thalesgroup.com> wrote:
>
>> RewriteEngine on
>>
>> RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
>> RequestHeader set my_new_header %{SMUSER}e
>>
>> Result from my browser (setenv.pl):
>>
>> SMUSER=""
>>
>
> I think the $ is extraneous and causing problems. Another potential
> problem -- See the "lookahead" feature to figure out REMOTE_USER when
> your RewriteRules are running in a phase before REMOTE_USER is set!
>
> You may be able to wrap your rules in <Directory>, which makes the
> Rewrite occur a little bit later, and might let some rules like this
> work better.
>
> Finally, why do you want to set the environment variable in a request
> header? Is this just some debug you added along the way, or your
> ultimate goal?
>
>
>> Question 1: The syntax is incredibly cryptic. Where might I look to help me
>> understand the %, e, {} etc.
>>
> The variable syntax for RequestHeader is defined in a table at the
> bottom of the Header directive:
>
> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader
>
> The syntax for mod_rewrite is midway down in the doc for RewriteRule:
> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>
>
>> Mind you, it works for simple text:
>>
>> RewriteRule .* - [E=SMUSER:test]
>>
>> Result: SMUSER="test"
>>
>> 2. Technique 2: setenv DAVESETENV "text"
>> ----------------------------------------------
>>
>> Result: DAVESETENV="text"
>>
>> But, I've read that this is only a static string.
>>
>> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html
>>
>
> setenvif is a bit more flexible:
> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif
>
>


--------------050106020802040003050201
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello everybody.<br>
<br>
Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !<br>
<br>
httpd.conf:<br>
    RewriteEngine on<br>
    RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]<br>
<br>
Result (setenv.pl):<br>
    ...<br>
    SMUSER="<my-LDAP-userid :-) >"<br>
    ...<br>
Thanks again, Dave<br>
<br>
PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.<br>
------<br>
<br>
Eric Covener wrote:
<blockquote
cite="mid:AANLkTi=_EdQytfNx4Wu9qsMhyRXHcbxh1BfVY59_v1nY [at] mail .gmail.com"
type="cite">
<pre wrap="">On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
<a class="moz-txt-link-rfc2396E" href="mailto:david.donnan [at] thalesgroup.com"><david.donnan [at] thalesgroup.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

        Result from my browser (setenv.pl):

        SMUSER=""
</pre>
</blockquote>
<pre wrap=""><!---->
I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?

</pre>
<blockquote type="cite">
<pre wrap="">Question 1: The syntax is incredibly cryptic. Where might I look to help me
understand the %, e, {} etc.
</pre>
</blockquote>
<pre wrap=""><!---->The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

<a class="moz-txt-link-freetext" href="http://httpd.apache.org/docs/current/mod/mod_headers.html#header"> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader</a>

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
<a class="moz-txt-link-freetext" href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule"> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule</a>

</pre>
<blockquote type="cite">
<pre wrap="">Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

    Result: DAVESETENV="text"

But, I've read that this is only a static string.

<a class="moz-txt-link-freetext" href="http://www.usenet-forums.com/apache-web-server/10179-setenv-dynamic-variable.html"> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html</a>
</pre>
</blockquote>
<pre wrap=""><!---->
setenvif is a bit more flexible:
<a class="moz-txt-link-freetext" href="http://httpd.apache.org/docs/current/mod/mod_setenvif.html#setenvif"> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif</a>

</pre>
</blockquote>
<br>
</body>
</html>

--------------050106020802040003050201--
david.donnan [ Mi, 29 September 2010 09:34 ] [ ID #2048509 ]

RewriteRule E=SMUSER:%{LA-U:REMOTE_USER} works but not E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}

--------------020506040305040804060607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello again. I hope I've not overstayed my welcome.

RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for both 80
and 443 (SSL)

However, the following doesn't work for either (I understand why it
doesn't work for port 80 :-)

RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]

Nor the following:

RewriteRule .* - [E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}] #
note L A-F, not LA-U

I've done my reading but have not found the definitive list of supported
variables.

I found a table at the following link, search for %{ NAME_OF_VARIABLE }

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule

Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing something ?

Any help would be greatly appreciated, Dave
-------

David (Dave) Donnan wrote:
> Hello everybody.
>
> Eric, thanks for the rapide response. I took the $PATH of least
> resistance, corrected Technique #1, and now it WORKS !
>
> httpd.conf:
> RewriteEngine on
> RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]
>
> Result (setenv.pl):
> ...
> SMUSER="<my-LDAP-userid :-) >"
> ...
> Thanks again, Dave
>
> PS: I had no luck with setenvif but I'm more than happy with the
> RewriteRule.
> ------
>
> Eric Covener wrote:
>> On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
>> <david.donnan [at] thalesgroup.com> wrote:
>>
>>> RewriteEngine on
>>>
>>> RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
>>> RequestHeader set my_new_header %{SMUSER}e
>>>
>>> Result from my browser (setenv.pl):
>>>
>>> SMUSER=""
>>>
>>
>> I think the $ is extraneous and causing problems. Another potential
>> problem -- See the "lookahead" feature to figure out REMOTE_USER when
>> your RewriteRules are running in a phase before REMOTE_USER is set!
>>
>> You may be able to wrap your rules in <Directory>, which makes the
>> Rewrite occur a little bit later, and might let some rules like this
>> work better.
>>
>> Finally, why do you want to set the environment variable in a request
>> header? Is this just some debug you added along the way, or your
>> ultimate goal?
>>
>>
>>> Question 1: The syntax is incredibly cryptic. Where might I look to help me
>>> understand the %, e, {} etc.
>>>
>> The variable syntax for RequestHeader is defined in a table at the
>> bottom of the Header directive:
>>
>> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader
>>
>> The syntax for mod_rewrite is midway down in the doc for RewriteRule:
>> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>>
>>
>>> Mind you, it works for simple text:
>>>
>>> RewriteRule .* - [E=SMUSER:test]
>>>
>>> Result: SMUSER="test"
>>>
>>> 2. Technique 2: setenv DAVESETENV "text"
>>> ----------------------------------------------
>>>
>>> Result: DAVESETENV="text"
>>>
>>> But, I've read that this is only a static string.
>>>
>>> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html
>>>
>>
>> setenvif is a bit more flexible:
>> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif
>>
>>
>


--------------020506040305040804060607
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello again. I hope I've not overstayed my welcome.<br>
<blockquote>RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for
both 80 and 443 (SSL)<br>
</blockquote>
However, the following doesn't work for either (I understand why it
doesn't work for port 80 :-)<br>
<blockquote>RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]<br>
</blockquote>
Nor the following:<br>
<blockquote>RewriteRule .* -
[E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}]      # note L A-F, not LA-U<br>
</blockquote>
I've done my reading but have not found the definitive list of
supported variables.<br>
<br>
I found a table at the following link, search for %{ NAME_OF_VARIABLE 
}  <br>
<blockquote><a
href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule</a><br>
</blockquote>
Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing
something ?<br>
<br>
Any help would be greatly appreciated, Dave<br>
-------<br>
<br>
David (Dave) Donnan wrote:
<blockquote
cite="mid:7903_1285745677_4CA2EC0D_7903_27653_1_4CA2EC0A.208 0409 [at] thalesgroup.com"
type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Hello everybody.<br>
<br>
Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !<br>
<br>
httpd.conf:<br>
    RewriteEngine on<br>
    RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]<br>
<br>
Result (setenv.pl):<br>
    ...<br>
    SMUSER="<my-LDAP-userid :-) >"<br>
    ...<br>
Thanks again, Dave<br>
<br>
PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.<br>
------<br>
<br>
Eric Covener wrote:
<blockquote
cite="mid:AANLkTi=_EdQytfNx4Wu9qsMhyRXHcbxh1BfVY59_v1nY [at] mail .gmail.com"
type="cite">
<pre wrap="">On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:david.donnan [at] thalesgroup.com"><david.donnan [at] thalesgroup.com ></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

        Result from my browser (setenv.pl):

        SMUSER=""
</pre>
</blockquote>
<pre wrap=""><!---->
I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?

</pre>
<blockquote type="cite">
<pre wrap="">Question 1: The syntax is incredibly cryptic. Where might I look to help me
understand the %, e, {} etc.
</pre>
</blockquote>
<pre wrap=""><!---->The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://httpd.apache.org/docs/current/mod/mod_headers.h tml#header">http://httpd.apache.org/docs/current/mod/mod_hea ders.html#header</a>

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule</a>

</pre>
<blockquote type="cite">
<pre wrap="">Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

    Result: DAVESETENV="text"

But, I've read that this is only a static string.

<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.usenet-forums.com/apache-web-server/10179-s etenv-dynamic-variable.html">http://www.usenet-forums.com/ap ache-web-server/10179-setenv-dynamic-variable.html</a>
</pre>
</blockquote>
<pre wrap=""><!---->
setenvif is a bit more flexible:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://httpd.apache.org/docs/current/mod/mod_setenvif. html#setenvif">http://httpd.apache.org/docs/current/mod/mod_ setenvif.html#setenvif</a>

</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>

--------------020506040305040804060607--
david.donnan [ Mi, 29 September 2010 14:18 ] [ ID #2048510 ]

Re: RewriteRule E=SMUSER:%{LA-U:REMOTE_USER} works but not E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}

--------------050106030201020908060209
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

My bad, it works as follows (worth noting for the archives).

RewriteRule .* - [E=SMUSER:%{SSL:SSL_CLIENT_S_DN_Email}]

Cdlt, Dave
------
David (Dave) Donnan wrote:
> Hello again. I hope I've not overstayed my welcome.
>
> RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for both 80
> and 443 (SSL)
>
> However, the following doesn't work for either (I understand why it
> doesn't work for port 80 :-)
>
> RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]
>
> Nor the following:
>
> RewriteRule .* - [E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}] #
> note L A-F, not LA-U
>
> I've done my reading but have not found the definitive list of
> supported variables.
>
> I found a table at the following link, search for %{ NAME_OF_VARIABLE }
>
> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>
> Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing
> something ?
>
> Any help would be greatly appreciated, Dave
> -------
>
> David (Dave) Donnan wrote:
>> Hello everybody.
>>
>> Eric, thanks for the rapide response. I took the $PATH of least
>> resistance, corrected Technique #1, and now it WORKS !
>>
>> httpd.conf:
>> RewriteEngine on
>> RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]
>>
>> Result (setenv.pl):
>> ...
>> SMUSER="<my-LDAP-userid :-) >"
>> ...
>> Thanks again, Dave
>>
>> PS: I had no luck with setenvif but I'm more than happy with the
>> RewriteRule.
>> ------
>>
>> Eric Covener wrote:
>>> On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
>>> <david.donnan [at] thalesgroup.com> wrote:
>>>
>>>> RewriteEngine on
>>>>
>>>> RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
>>>> RequestHeader set my_new_header %{SMUSER}e
>>>>
>>>> Result from my browser (setenv.pl):
>>>>
>>>> SMUSER=""
>>>>
>>>
>>> I think the $ is extraneous and causing problems. Another potential
>>> problem -- See the "lookahead" feature to figure out REMOTE_USER when
>>> your RewriteRules are running in a phase before REMOTE_USER is set!
>>>
>>> You may be able to wrap your rules in <Directory>, which makes the
>>> Rewrite occur a little bit later, and might let some rules like this
>>> work better.
>>>
>>> Finally, why do you want to set the environment variable in a request
>>> header? Is this just some debug you added along the way, or your
>>> ultimate goal?
>>>
>>>
>>>> Question 1: The syntax is incredibly cryptic. Where might I look to help me
>>>> understand the %, e, {} etc.
>>>>
>>> The variable syntax for RequestHeader is defined in a table at the
>>> bottom of the Header directive:
>>>
>>> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader
>>>
>>> The syntax for mod_rewrite is midway down in the doc for RewriteRule:
>>> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>>>
>>>
>>>> Mind you, it works for simple text:
>>>>
>>>> RewriteRule .* - [E=SMUSER:test]
>>>>
>>>> Result: SMUSER="test"
>>>>
>>>> 2. Technique 2: setenv DAVESETENV "text"
>>>> ----------------------------------------------
>>>>
>>>> Result: DAVESETENV="text"
>>>>
>>>> But, I've read that this is only a static string.
>>>>
>>>> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html
>>>>
>>>
>>> setenvif is a bit more flexible:
>>> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif
>>>
>>>
>>
>


--------------050106030201020908060209
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
My bad, it works as follows (worth noting for the archives).<br>
<blockquote>RewriteRule .* - [E=SMUSER:%{SSL:SSL_CLIENT_S_DN_Email}]<br>
</blockquote>
Cdlt, Dave<br>
------<br>
David (Dave) Donnan wrote:
<blockquote cite="mid:4CA32E83.6010809 [at] thalesgroup.com" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Hello again. I hope I've not overstayed my welcome.<br>
<blockquote>RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for
both 80 and 443 (SSL)<br>
</blockquote>
However, the following doesn't work for either (I understand why it
doesn't work for port 80 :-)<br>
<blockquote>RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]<br>
</blockquote>
Nor the following:<br>
<blockquote>RewriteRule .* -
[E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}]      # note L A-F, not LA-U<br>
</blockquote>
I've done my reading but have not found the definitive list of
supported variables.<br>
<br>
I found a table at the following link, search for %{ NAME_OF_VARIABLE 
}  <br>
<blockquote><a moz-do-not-send="true"
href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule</a><br>
</blockquote>
Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing
something ?<br>
<br>
Any help would be greatly appreciated, Dave<br>
-------<br>
<br>
David (Dave) Donnan wrote:
<blockquote
cite="mid:7903_1285745677_4CA2EC0D_7903_27653_1_4CA2EC0A.208 0409 [at] thalesgroup.com"
type="cite">
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
Hello everybody.<br>
<br>
Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !<br>
<br>
httpd.conf:<br>
    RewriteEngine on<br>
    RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]<br>
<br>
Result (setenv.pl):<br>
    ...<br>
    SMUSER="<my-LDAP-userid :-) >"<br>
    ...<br>
Thanks again, Dave<br>
<br>
PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.<br>
------<br>
<br>
Eric Covener wrote:
<blockquote
cite="mid:AANLkTi=_EdQytfNx4Wu9qsMhyRXHcbxh1BfVY59_v1nY [at] mail .gmail.com"
type="cite">
<pre wrap="">On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:david.donnan [at] thalesgroup.com"><david.donnan [at] thalesgroup.com ></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

        Result from my browser (setenv.pl):

        SMUSER=""
</pre>
</blockquote>
<pre wrap=""><!---->
I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?

</pre>
<blockquote type="cite">
<pre wrap="">Question 1: The syntax is incredibly cryptic. Where might I look to help me
understand the %, e, {} etc.
</pre>
</blockquote>
<pre wrap=""><!---->The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://httpd.apache.org/docs/current/mod/mod_headers.h tml#header">http://httpd.apache.org/docs/current/mod/mod_hea ders.html#header</a>

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule</a>

</pre>
<blockquote type="cite">
<pre wrap="">Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

    Result: DAVESETENV="text"

But, I've read that this is only a static string.

<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.usenet-forums.com/apache-web-server/10179-s etenv-dynamic-variable.html">http://www.usenet-forums.com/ap ache-web-server/10179-setenv-dynamic-variable.html</a>
</pre>
</blockquote>
<pre wrap=""><!---->
setenvif is a bit more flexible:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://httpd.apache.org/docs/current/mod/mod_setenvif. html#setenvif">http://httpd.apache.org/docs/current/mod/mod_ setenvif.html#setenvif</a>

</pre>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>

--------------050106030201020908060209--
david.donnan [ Mi, 29 September 2010 14:29 ] [ ID #2048511 ]
Webserver » gmane.comp.apache.user » Setting CGI environment variables, dynamically, from httpd.conf leveragingexising variables

Vorheriges Thema: LDAP authentication with password encryption from browser to webserver
Nächstes Thema: Re: LDAP authentication with password encryption frombrowser to web server