libersoft / zcs-php

A small set of PHP classes to query a Zimbra Collaboration Suite server via the SOAP API interface.
http://libersoft.github.com/zcs-php/
GNU General Public License v3.0
23 stars 16 forks source link

ldap.INVALID_SEARCH_FILTER #6

Closed davewkzn closed 10 years ago

davewkzn commented 11 years ago

Hi,

Please may I ask for your assistance with the following?

When attempting to use the example which lists all accounts via "$zimbra->getAccounts", I receiving the following error: PHP Fatal error: Uncaught exception 'Zimbra\ZCS\Exception' with message 'An unexpected error has occurred (ldap.INVALID_SEARCH_FILTER)' in /var....../zcs-php/src/Zimbra/ZCS/SoapClient.php:103

According to our Zimbra server's log I see the following: errorMessage='Unexpected opening parenthesis found at position 72 of the filter string.'

Have I done something wrong? Your assistance would be greatly appreciated. Zimbra version: zimbra-8.0.2 Many thanks.

pollok commented 11 years ago

I have the same problem and I haven't found anything googling around... the problem appears after upgrade 8.0.1 to 8.0.2

davewkzn commented 11 years ago

Thanks for your reply. I am glad to hear that I am not alone :)

pollok commented 11 years ago

I've changed this:

public function searchDirectory($domain, $limit = 10, $offset = 0, $type = 'accounts', $sort = null, $query = null)
{
    if ($type == 'accounts') {
        $ldapQuery = "&(";

        if ($query !== null) {
            $ldapQuery .= "(name=$query*)";
        }

        $ldapQuery .= '(!(zimbraIsSystemResource=TRUE))';
        $ldapQuery .= '(!(zimbraIsAdminAccount=TRUE))';

        $ldapQuery .= ')';
    } else {
        $ldapQuery = '';
    }

....

with:

public function searchDirectory($domain, $limit = 10, $offset = 0, $type = 'accounts', $sort = null, $query = null)
{
        $ldapQuery = '';

....

and is working for GetAllAccounts(), before confirm the validity of the solution is necessary some additional tests

davewkzn commented 11 years ago

Thank you for your input!

Upon further inspection, it would appear that the following at line 50 in Admin.php: $ldapQuery = "&(";

Is causing the ampersand symbol to appear on the wrong side of the parentheses in the search query. From what I can see it should rather be: $ldapQuery = "(&";

Tested and working on my system so far.

pollok commented 11 years ago

really good!

thanks, is working!

gionn commented 10 years ago

Merged, thanks.