For anyone interested: after some furhter troubleshooting, I found the error. The password I was passing was incorrect. What I found interesting is that even though the password was incorrect, the bind function still worked. I'm thinking that it logged me in as anonymous at that stage. >Our organization is migrating away from Novell E-directory to MS Active >Directory. I have a php class that allows me to run various queries on our >e-directory ldap server which I am working to convert to AD. However, I'm >running into an error that i cannot figure out. I have updated the base_dn to >point tothe correct location (verified by a third party ldap browser). Also >added a username and password since our AD environment doesn't allow anonymous >queries. The error I get is > >Warning: ldap_search() [function.ldap-search]: Search: Operations error in >/var/www/html/intranet/_php/class.ldap_test.php on line 149 > >On that line I have this line of code >$result = ldap_search($this->conn,$this->base_dn,$filter); > >Where $this->conn evaluates to Resource id #3, $this->base_dn is the correct >dn (ou=something,dc=domain,dc=domain_part_2) and $filter is cn=myusername > >Can anyone shed some light on this? Below is the entire method from the >class. > > function connectldap($filter,$override=false) { > //connect to the server > $this->conn = ldap_connect($this->server); > > //if the connection failed, set the error message > //and return false > if(!$this->conn) { > $this->errMsg[] = "Unable to connect to server\n"; > return false; > } > //ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3); > //bind the connection. This function will perform an > //anonymous query to get the full > $bind = @ldap_bind($this->conn,$this->ldap_user,$ldap_passwd); > if(!$bind) { > $this->errMsg[] = "Unable to bind to server\n"; > return false; > } > echo "<p>$filter - " . $this->conn . " - " . $bind . " - " . $this->base_dn >. "</p>\n"; > //run the ldap query > $result = ldap_search($this->conn,$this->base_dn,$filter); > //if the search failed, then return false and set the error message > if(!$result) { > $this->errMsg[] = "Search failed - " . ldap_error($this->conn) . "\n"; > return false; > } > //get the entries and store them in a variable > $info=ldap_get_entries($this->conn,$result); > > //if the number of entries reutnred is zero, then the user > //could not be found in the ldap server > if($info["count"] == 0) { > $this->errMsg[] = "User Unknown\n"; > return false; > } > //otherwise, if the number of entries found is greater than 1, then > //more than one object was found. > elseif($info["count"]>1 && !$override) { > $this->errMsg[] = "There was more than one user found\n"; > return false; > } > else { > return $info; > } > } > >Thank you, >Robbert van Andel > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php