简体   繁体   English

从LDAP获取用户名-您能告诉我什么地方吗?

[英]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.

相关问题 你能告诉我这个 PHP 表单有什么问题吗? - Can you tell me what's wrong with this PHP form? 你能告诉我这个用 PHP 编写的谷歌驱动 API 调用函数有什么问题吗? - can you tell me what's wrong with this google drive API call function in PHP 你能告诉我这个表格在做什么吗? - Can you tell me what this form is doing? 您能告诉我我的博客这段代码有什么问题吗? - Could you tell me what is wrong with this piece of code for my blog? 有人能告诉我我在 PHP 中的 MySQL 查询有什么问题吗? - Can someone tell me what's wrong with my MySQL query in PHP? 谁能告诉我我的openssl_sign示例出了什么问题 - Can someone tell me what's wrong with my openssl_sign example MySQL + PHP:谁能告诉我这段代码有什么问题? - MySQL+PHP: Can anyone tell me what is wrong with this code? 有人可以告诉我这个MySQL查询有什么问题吗? - Can someone tell me what is wrong with this MySQL query? 谁能告诉我此查询出了什么问题 - Can any one tell me what is wrong with this query 有人可以告诉我如何将用户名和密码信息从一种意图复制到网站,然后按登录按钮 - can someone tell me how to copy username & password info from one intent to website and press the login button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM