Bug #232453 --> ldap quick search and advanced search does not honor search filters

when applied to the ldap directory properties dialog.

r=dmose
sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2004-01-30 04:33:32 +00:00
Родитель 2c03598e56
Коммит 2fff9f432b
2 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -733,6 +733,32 @@ NS_IMETHODIMP nsAbLDAPDirectoryQuery::DoQuery(nsIAbDirectoryQueryArguments* argu
rv = mDirectoryUrl->GetOptions(&options);
NS_ENSURE_SUCCESS(rv,rv);
// get the directoryFilter from the directory url and merge it with the user's
// search filter
nsCAutoString urlFilter;
rv = mDirectoryUrl->GetFilter(urlFilter);
// if urlFilter is unset (or set to the default "objectclass=*"), there's
// no need to AND in an empty search term, so leave prefix and suffix empty
nsCAutoString searchFilter;
if (urlFilter.Length() && !urlFilter.Equals(NS_LITERAL_CSTRING("(objectclass=*)")))
{
// if urlFilter isn't parenthesized, we need to add in parens so that
// the filter works as a term to &
//
if (urlFilter[0] != '(')
searchFilter = NS_LITERAL_CSTRING("(&(") + urlFilter + NS_LITERAL_CSTRING(")");
else
searchFilter = NS_LITERAL_CSTRING("(&") + urlFilter;
searchFilter += filter;
searchFilter += ')';
}
else
searchFilter = filter;
nsCString ldapSearchUrlString;
char* _ldapSearchUrlString =
PR_smprintf ("ldap%s://%s:%d/%s?%s?%s?%s",
@ -742,7 +768,7 @@ NS_IMETHODIMP nsAbLDAPDirectoryQuery::DoQuery(nsIAbDirectoryQueryArguments* argu
dn.get (),
returnAttributes.get (),
scope.get (),
filter.get ());
searchFilter.get ());
if (!_ldapSearchUrlString)
return NS_ERROR_OUT_OF_MEMORY;
ldapSearchUrlString = _ldapSearchUrlString;

Просмотреть файл

@ -909,7 +909,7 @@ nsLDAPAutoCompleteSession::StartLDAPSearch()
// no need to AND in an empty search term, so leave prefix and suffix empty
//
nsCAutoString prefix, suffix;
if (!urlFilter.Equals(NS_LITERAL_CSTRING("(objectclass=*)"))) {
if (urlFilter.Length() && !urlFilter.Equals(NS_LITERAL_CSTRING("(objectclass=*)"))) {
// if urlFilter isn't parenthesized, we need to add in parens so that
// the filter works as a term to &