[英]Getting the username from LDAP - Can you tell me what's wrong?
I'd like to ask you how can i dinamically get a username from ldap. 我想问你我该如何从ldap获取用户名。 As you can see below, i entered the username 'smith2' 如下所示,我输入了用户名“ smith2”
$_SERVER["REMOTE_USER"] = 'smith2';
$param = $_SERVER["REMOTE_USER"]
And I can get his first name, like this: 我可以得到他的名字,像这样:
$ldap1 = new ldapl;
$fname=$ldap1->getFname($param);
This is useful because I have some forms with some fields which are filled by default (name, first name, etc). 这很有用,因为我有一些带有默认填写的字段的表单(名称,名字等)。
It must be dynamic. 它必须是动态的。 Each person has a PC, so the person Y should see his name, first name, etc The person X his name, first name, etc. 每个人都有一台PC,因此Y人应该看到他的名字,名字等等。X人应该看到他的名字,名字等等。
I deleted the line $_SERVER["REMOTE_USER"] = 'smith2'; 我删除了行$ _SERVER [“ REMOTE_USER”] ='smith2'; and i did like this: 我确实是这样的:
$fname=$ldap1->getFname($_SERVER["REMOTE_USER"]);
But it does not work, it displays anything. 但是它不起作用,它显示任何内容。 Can you tell me whats wrong? 你能告诉我怎么了吗?
Is there a simple way to do this? 有没有简单的方法可以做到这一点?
Thanks 谢谢
The variable $_SERVER['REMOTE_USER'] is probably empty. 变量$ _SERVER ['REMOTE_USER']可能为空。
You can check predefined variables using phpinfo(); 您可以使用phpinfo()检查预定义的变量;
See http://us.php.net/phpinfo 参见http://us.php.net/phpinfo
To fix this you need to replace the variable name with an accurate one that actually holds the value of the username you want to fetch LDAP information for. 要解决此问题,您需要用一个准确的变量名替换该变量名,该变量名实际上包含您要获取LDAP信息的用户名的值。
You can also debug this by adding the following line below your code: 您还可以通过在代码下方添加以下行来调试此代码:
echo "REMOTE_USER: {$_SERVER['REMOTE_USER']}";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.