A requirement: Obtain the computer name of the access user in the domain control scope. Method:
1. Test Software Environment: XAMPP Control Panel V3.2.1, Apache version 2.4.7
2. Apache 2.2 uses the Mod_auth_sspi.so module, and Apache 2.4 is no longer suitable for this module, using the Mod_authnz_sspi module.
Second, installation
1. Download the Mod_authnz_sspi module. (x86 for 32bit Apache, x64 for bit apche) Download the module from here
https://www.apachehaus.net/modules/mod_authnz_sspi/
2. Copy the module to the modules file in the Apache installation directory
3. Make sure that the following two modules are available.
LoadModule Authn_core_module modules/mod_authn_core.so
LoadModule Authz_core_module modules/mod_authz_core.so
4. Configure Apache's httpd. conf file
Add the Load module statement at the end of the LoadModule statement
LoadModule Authnz_sspi_module modules/mod_authnz_sspi.so
At the end of the httpd.conf file, add:
<directory "D:/xampp/htdocs" > # Specify Site root directory
AllowOverride None
Options None
AuthName "My Intranet" (this name can be set casually)
AuthType SSPI
Sspiauth on
Sspiauthoritative on
Require Valid-user
Require user "NT authority\anonymous LOGON" denied
</Directory>
5. Save the Conf file and restart Apache
See if the module is loaded: Phpinfo ();
Check the Apache Version
Httpd-v
PHP Implementation code:
$username = $_server[' Php_auth_user ');
echo $_server[' Php_auth_user '];
Or:
echo "<br>". $_server[' Remote_user ';
$username = substr (STRRCHR ($username, ' \ \ '), 1);
echo "<br>". $username;