We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,664 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

php ldap_search operation error

help me find out what's wrong with this code i got stuck with this error

ldap_search Search: Operations error

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$ADServer = 'sample.example.net';
$loginto = 'Aboitiz';
$uname = $_POST['uname'];
$passwd = $_POST['pass'];


$ldapconn = ldap_connect($ADServer) or die("Could not connect to LDAP server.");
$ldaprdn = $loginto."\\".$uname; 
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $passwd); 

if($ldapbind){
     $find = array("cn", "givenname", "samaccountname", "homedirectory", "telephonenumber", "mail");

    $base = "DC=example,DC=net";
    $email = "toytoy.me@example.net";
    $filter = "mail=".$email;

    $result = ldap_search($ldapconn,$base,$filter,$find);
    if(!$result){

        die('Error - '.ldap_error($ldapconn));
    }

    $info = ldap_get_entries($ldapconn, $result);
    print_r($info);
}else{
    echo 'user dont exists';
}
ldap_close($ldapconn);
?>
2
Contributors
1
Reply
10 Hours
Discussion Span
2 Months Ago
Last Updated
9
Views
code739
Posting Whiz in Training
208 posts since May 2012
Reputation Points: 17
Solved Threads: 28
Skill Endorsements: 5

@code739

php ldap_search operation error

This is the line that has the error:

$result = ldap_search($ldapconn,$base,$filter,$find);

You trying to search in Active Directory?

If you look closely it's this code:

$ldapconn = ldap_connect($ADServer) or die("Could not connect to LDAP server.");

The error means you are not connect correctly.

There should be a bridge connecting to $ldapconn and to $ldapbind.

Once it is connected your issue should be resolve.

I think.

Let me know if you have more questions.

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0686 seconds using 2.69MB