douyao1994 2013-08-28 21:33 采纳率: 100%
浏览 75
已采纳

PHP LDAP绑定间歇性问题

I am developing an application for my company which requires the users to log in. To automate the log in process I have tried to integrate the ldap id and the password authentication with this app. Below is the code that I have written for this integration. I have checked online and could not find any one facing this issue.

I have this code ->

function isAuthenticated($u,$p) {
        $ldap_host = 'my_host';
        $ldap = ldap_connect($ldap_host);
        ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
        if($ldap) {
                if($bind = ldap_bind($ldap,$u,$p)) {
                    ldap_unbind($ldap);
                    return 'Authenticated';
                } else {
                        return 'Invalid Credentials';
                    }
            } else {
                    return 'Not able to connect';
                }
    }

$username = 'preventAnonymousLogin';
$password = 'preventAnonymousLogin';

if(isset($_REQUEST['uname'])) {
        $username = $_REQUEST['uname'];
    }

if(isset($_REQUEST['password'])) {
        $password = $_REQUEST['password'];
    }

$auth = isAuthenticated($username,$password);

This works most of the time but some time it does not and gives this error ->

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\avrs\htdocs\ldap.php on line 12

I have no idea why this would work some times and some times it just don't. Please suggest. Thanks in advance.

This same code works intermittently. I have tried to clear the cookies and all which seems to work some time but it is not today. So, unless I know for sure what the issue is I think I will not be able to fix this issue for good.

  • 写回答

3条回答 默认 最新

  • dongnan1899 2013-08-31 01:09
    关注

    Make sure you give the full DNS name for the ldap_host, e.g. myhost.mydomain.com.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用lstm来预测股票价格
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上