windows WAMP 上的 LDAP 身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5093433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LDAP Auth on WAMP
提问by Cory Dee
I'm trying to write some LDAP authentication code on my WAMP server.
我正在尝试在我的 WAMP 服务器上编写一些 LDAP 身份验证代码。
I'm using this:
我正在使用这个:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$ldapconfig['host'] = 'my.server.province.country';
$ldapconfig['port'] = 389;
$ldapconfig['basedn'] = 'DC=x,DC=y,DC=z,DC=x1';
$ldapconfig['authrealm'] = 'My Realm';
ldap_connect($ldapconfig['host'], $ldapconfig['port']) or die ('Could not connect');
echo 'connected';
?>
I'm getting this error:
我收到此错误:
Fatal error: Call to undefined function ldap_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\oplweb\index.php on line 10
致命错误:在第 10 行调用 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\oplweb\index.php 中未定义的函数 ldap_connect()
From some basic Googling, it looks like I need to turn on mod_ldap. Seems simple. I've done the following:
从一些基本的谷歌搜索来看,看起来我需要打开 mod_ldap。看起来很简单。我做了以下工作:
- Went to C:\Program Files\Apache Software Foundation\Apache2.2\modules and made sure that mod_ldap.so exists.
- I've gone into C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf and made sure that this line is not commented out: LoadModule ldap_module modules/mod_ldap.so
- I've gone into C:\Program Files\PHP\php.ini and made sure this line is not commented out: extension=php_ldap.dll
- Restart apache
- 转到 C:\Program Files\Apache Software Foundation\Apache2.2\modules 并确保 mod_ldap.so 存在。
- 我已经进入 C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf 并确保没有注释掉这一行:LoadModule ldap_module modules/mod_ldap.so
- 我已经进入 C:\Program Files\PHP\php.ini 并确保没有注释掉这一行:extension=php_ldap.dll
- 重启apache
The problem still persists. Does the ldap_connect() function in php have any other dependencies? Am I missing a step?
问题仍然存在。php 中的 ldap_connect() 函数是否还有其他依赖项?我错过了一步吗?
Cheers
干杯
回答by Slukehart
I ran into this same issue with my Windows Server 2008 - Have you added the php.ini file to your windows path?
我的 Windows Server 2008 遇到了同样的问题 - 您是否已将 php.ini 文件添加到 Windows 路径中?
Go to Control Panel and open the System icon (Start -> Settings -> Control Panel -> System, or just Start -> Control Panel -> System for Windows XP/2003+)
转到控制面板并打开系统图标(开始 -> 设置 -> 控制面板 -> 系统,或者只是开始 -> 控制面板 -> Windows XP/2003+ 的系统)
Go to the Advanced tab
转到高级选项卡
Click on the 'Environment Variables' button
单击“环境变量”按钮
Look into the 'System Variables' pane
查看“系统变量”窗格
Find the Path entry (you may need to scroll to find it)
找到路径条目(您可能需要滚动才能找到它)
Double click on the Path entry
双击路径条目
Enter your PHP directory at the end, including ';' before (e.g. ;C:\php)
最后输入你的PHP目录,包括';' 之前(例如;C:\php)
Press OK
按确定
回答by dobrien
Check your phpinfo to make sure ldap is enabled. You should see an LDAP section, and
检查您的 phpinfo 以确保启用了 ldap。您应该会看到一个 LDAP 部分,并且
Support | enabled
支持 | 启用
You may have php set to auto-enable anything in your extension dir, or you may have to manually enable it by uncommenting a line that looks like:
您可能将 php 设置为自动启用扩展目录中的任何内容,或者您可能必须通过取消注释如下所示的行来手动启用它:
extension=php_ldap.dll
扩展名=php_ldap.dll
in your php.ini file
在你的 php.ini 文件中
Remember to restart apache after you enable it.
启用后记得重启apache。
回答by Capsule
If you're connecting to an Active Directory, you can use this class which doesn't require any special PHP extension: http://sourceforge.net/projects/adldap/
如果您要连接到 Active Directory,则可以使用不需要任何特殊 PHP 扩展的此类:http: //sourceforge.net/projects/adldap/
回答by fulinyun
I ran into the same problem recently and I searched for php.ini
on my disk and found that there are two php.ini
files there -- one under the phpdirectory and the other under the apache\bin
directory. I uncommented the extension=php_ldap.dll
line in both files and the problem is solved.
我最近遇到了同样的问题,我php.ini
在我的磁盘上搜索,发现那里有两个php.ini
文件——一个在php目录下,另一个在php目录下apache\bin
。我取消注释这extension=php_ldap.dll
两个文件中的行,问题就解决了。
回答by MIchael
for WAMP, the working version of php.ini is located at apache\bin. i was experienced same problem before until i change php.ini setting inside apache\bin and finally it works.
对于 WAMP,php.ini 的工作版本位于 apache\bin。我之前遇到过同样的问题,直到我更改了 apache\bin 中的 php.ini 设置,最后它才起作用。