简体   繁体   中英

Get Intranet windows username in php

i can get the windows username in my system but i need to retrieve the windows username from **visitors**. 

Visitor means not internet am saying about intranet .

Am developing intranet website for this only i need:

Below the code for your reference:-

/* to get the windows username */
$nw = new COM("WScript.Network");
print "username: " . $nw->username . "<br><br>";
$computername = $nw->computername;
print "computername: $computername<br>";
$owmi = new COM("winmgmts:\\\\$computername\\root\\cimv2");
$comp = $owmi->get("win32_computersystem.name='$computername'" );
print "username: " . $comp->username; echo "<br>";
/* to get the windows username */

Depending on your php version use $_SERVER['AUTH_USER'] or $_SERVER['PHP_AUTH_USER'], one of those should work.

See here for more info

See here for basic authentication

See here for NTLM authentication

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM