PHP obtains the computer login name of the user in the domain control

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.