dongwei3172 2018-02-28 07:09
浏览 137
已采纳

如何获取客户端用户名php - 只获取localhost用户名

Hi I am using the code below to retrieve client username on my website but it only works for me on localhost, other people connected remotely to the file its just finding nothing with no errors or anything.

exec("wmic /node:$_SERVER[REMOTE_ADDR] COMPUTERSYSTEM Get UserName", $user);
echo($user[1]);

What is the problem ?

  • 写回答

1条回答 默认 最新

  • drlnwji79147769 2018-02-28 07:19
    关注

    For a remote system you may need to send administrator credentials, e.g.

    exec("wmic /node:$_SERVER[REMOTE_ADDR] /user:administrator /password:mypassword COMPUTERSYSTEM Get UserName", $user);
    echo($user[1]); 
    

    I'd also research if safe to trust REMOTE_ADDR and use it in this way with wmic.

    If you are using IIS and looking to get the remote users AD username, this may help: Can you get a Windows (AD) username in PHP?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部