} else { if (!MozillaLdapPropertyRelator::findLdapPropertyFromMozilla (propertyName.get ())) continue;
if (NS_FAILED(rv) || !strlen(attrs[0])) { continue; }
nsresult nsAbQueryLDAPMessageListener::OnLDAPMessageSearchEntry (nsILDAPMessage *aMessage,        nsIAbDirectoryQueryResult** result){    nsresult rv;    nsCOMPtr<nsISupportsArray> propertyValues;    CharPtrArrayGuard properties;    rv = mQueryArguments->GetReturnProperties (properties.GetSizeAddr(), properties.GetArrayAddr());    NS_ENSURE_SUCCESS(rv, rv);    CharPtrArrayGuard attrs;    rv = aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());    NS_ENSURE_SUCCESS(rv, rv);    nsCAutoString propertyName;    for (PRUint32 i = 0; i < properties.GetSize(); i++)    {        propertyName.Assign (properties[i]);        nsAbDirectoryQueryPropertyValue* _propertyValue = 0;        if (propertyName.Equals("card:nsIAbCard"))        {            // Meta property            nsCAutoString dn;            rv = aMessage->GetDn (dn);            NS_ENSURE_SUCCESS(rv, rv);            nsCOMPtr<nsIAbCard> card;            rv = mDirectoryQuery->CreateCard (mUrl, dn.get(), getter_AddRefs (card));            NS_ENSURE_SUCCESS(rv, rv);            PRBool hasSetCardProperty = PR_FALSE;            rv = MozillaLdapPropertyRelator::createCardPropertyFromLDAPMessage (aMessage,                    card,                    &hasSetCardProperty);            NS_ENSURE_SUCCESS(rv, rv);            if (!hasSetCardProperty)                continue;            _propertyValue = new nsAbDirectoryQueryPropertyValue(propertyName.get (), card);            if (_propertyValue == NULL)                return NS_ERROR_OUT_OF_MEMORY;        }        else        {            if (!MozillaLdapPropertyRelator::findLdapPropertyFromMozilla (propertyName.get ()))                continue;            const MozillaLdapPropertyRelation* relation ;            for (PRUint32 j = 0; j < attrs.GetSize(); j++)            {                relation = MozillaLdapPropertyRelator::findMozillaPropertyFromLdap (attrs[j]);                if (!relation)                    continue;                /*                 * This change is necessary due to a side effect of #124022. The list of                 * requested attributes is created in reverse order than how they appear                 * in nsAbLDAPProperties.cpp. Thus while "surname" and "sn" both map to                 * LastName, "sn" will be returned by findLdapPropertyFromMozilla() as it                 * appears first in the hash table but "surname" will be returned by the                  * request.                  *                 * Rather than simply reversing the order, an alternative is to compare                 * the mapped Mozilla attributes where a one to one match exists.                */                if (nsCRT::strcasecmp (relation->mozillaProperty, propertyName.get()) == 0)                {                    PRUnicharPtrArrayGuard vals;                    rv = aMessage->GetValues (attrs[j], vals.GetSizeAddr(), vals.GetArrayAddr());                    NS_ENSURE_SUCCESS(rv, rv);                    if (vals.GetSize() == 0)                        break;                    _propertyValue = new nsAbDirectoryQueryPropertyValue(propertyName.get (), vals[0]);                    if (_propertyValue == NULL)                        return NS_ERROR_OUT_OF_MEMORY;                    break;                }            }        }        if (_propertyValue)        {            nsCOMPtr<nsIAbDirectoryQueryPropertyValue> propertyValue;            propertyValue = _propertyValue;            if (!propertyValues)            {                NS_NewISupportsArray(getter_AddRefs(propertyValues));            }            propertyValues->AppendElement (propertyValue);        }    }    if (!propertyValues)        return NS_OK;    return QueryResultStatus (propertyValues, result,nsIAbDirectoryQueryResult::queryResultMatch);}