简体   繁体   English

在PHP中获取Intranet Windows用户名

[英]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: 正在为此开发Intranet网站,我需要:

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. 根据您的php版本,使用$ _SERVER ['AUTH_USER']或$ _SERVER ['PHP_AUTH_USER'],其中之一应该有效。

See here for more info 在这里查看更多信息

See here for basic authentication 请参阅此处获取基本身份验证

See here for NTLM authentication 有关NTLM身份验证,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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