[UPD] How to get the username in $_SERVER[‘auth_user’] ?

We are developing a small intranet project in php. Works on apache. You need to know which AD user submitted the form. How can I make the $_SERVER[‘auth_user’] variable contain the name of the user who is logged in?

In general, both options proposed here did not work… 🙁
In the first case, since the server runs on Linux, vbscript does not roll.
The second option is to access LDAP. Here, too, it is most likely impossible to get the name of the logged in user, because. LDAP is simply not designed for this. See comments below

Instead, you can configure apache to authenticate to AD via LDAP. Then the name of the domain user gets into the PHP_AUTH_USER variable. True, there is also a nuance here. At the moment, I have implemented only opaque basic authorization (the easiest option), i.e. with login and password. How it will be with transparent is not yet clear…

Answer 1

Strange desire 🙂 is that where you need to get it?

The fact is that there is PHP_AUTH_USER, which the username gets into when HTTP basic auth, and there is AUTH_USER, which can get into anything (not defined by the standard), up to the user running the web server, not necessarily a name from AD.

So you need to directly ask for a username via LDAP, for example. Or here’s an exampleof how it’s done via NetBIOS.