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


git-svn-id: svn://10.0.0.236/trunk@152072 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scott%scott-macgregor.org 2004-01-30 04:34:16 +00:00
parent 41452064b4
commit 90c32f6380
2 changed files with 28 additions and 2 deletions

View File

@ -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;

View File

@ -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 &