Martin,
I'm not sure what you mean by the "Apache userid", which taken literally would be the user account under which the server is running. I really don't think you want to expose that!
Assuming you meant the "userid" of the client on the browser, you *may* be able to get the value from one of the HTTP headers, which are available to you as server variables. For example, in ASP you could code:
var userid = Request.ServerVariables ("REMOTE_USER");
Note however that there are also other possibilities such as "LOGON_USER" and "AUTH_USER". Read up on the headers (try W3Schools) to determine which you need.