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.