简体   繁体   English

如何获得登录的用户名?

[英]How can I get the logged in username?

Im working on a page, that contains, the modifications of a database ( have a webpage, where you can modify the database and this is a history database of the modifications which contains when, what have been modified). 我正在处理一个包含数据库修改的页面(有一个网页,您可以在其中修改数据库,这是修改的历史数据库,其中包含修改的时间,内容)。 On this page/ in this database I have to store that who modified it. 在此页面/此数据库中,我必须存储修改它的人。 And my quetion is that how can I get the windows user name. 我的问题是,如何获取Windows用户名。 Im working on apache server mysql db and in php and i have to get only windows users. 我在Apache服务器上的MySQL数据库和PHP工作,我只需要Windows用户。

I tried this on my laptop: 我在笔记本电脑上尝试过:

cmd> php -r "exec('echo %username%', $output); var_dump($output);"
array(1) {
  [0] =>
  string(7) "jigar.d"
}

And if you want username along with computer name: 如果您需要用户名和计算机名:

cmd> php -r "exec('echo %username%@%computername%', $output); var_dump($output);"
array(1) {
  [0] =>
  string(20) "jigar.d@****JIGARD"
}

Not sure if this is what you are looking for. 不知道这是您在寻找什么。

For authentication of intranet PHP based applications we use PHP LDAP to connect and authenticate users. 对于基于Intranet PHP的应用程序的身份验证,我们使用PHP LDAP连接并验证用户。

Note: My laptop is on AD as well. 注意:我的笔记本电脑也在AD上。 I have * my actual computername . 我已经*我的实际computername

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

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