[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: [Kde-pim] [PATCH] make KAddressbook ldap query only match persons,
From: Till Adam <till () adam-lilienthal ! de>
Date: 2005-05-01 14:48:35
Message-ID: 200505012318.24308.till () adam-lilienthal ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Pimsters,
attached patch tightens the filter that is used for ldap lookups in
KAddressbook somewhat, by restricting it to objects of the person class, the
groupofnames class, or everything that has a mail attribute. That way
structural ldap entries are not returned. This fixes a proko2 bug, but I
think it makes sense in the general case. Tobias, ok for both branches?
Till
["ldap-search-persons-only.diff" (text/x-diff)]
Index: ldapsearchdialog.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/ldapsearchdialog.cpp,v
retrieving revision 1.29.2.1
diff -u -3 -p -r1.29.2.1 ldapsearchdialog.cpp
--- ldapsearchdialog.cpp 14 Oct 2004 21:24:57 -0000 1.29.2.1
+++ ldapsearchdialog.cpp 1 May 2005 14:42:43 -0000
@@ -325,19 +325,22 @@ void LDAPSearchDialog::slotSetScope( boo
QString LDAPSearchDialog::makeFilter( const QString& query, const QString& attr,
bool startsWith )
{
+ /* The reasoning behind this filter is:
+ * If it's a person, or a distlist, show it, even if it doesn't have an email address.
+ * If it's not a person, or a distlist, only show it if it has an email attribute.
+ * This allows both resource accounts with an email address which are not a person and
+ * person entries without an email address to show up, while still not showing things
+ * like structural entries in the ldap tree. */
+ QString result( "&(|(objectclass=person)(objectclass=groupofnames)(mail=*))(" );
if( query.isEmpty() )
// Return a filter that matches everything
- return QString( "|(cn=*)(sn=*)" );
+ return result + "|(cn=*)(sn=*)" + ")";
if ( attr == i18n( "Name" ) ) {
- QString result( (startsWith ? "|(cn=%1*)(sn=%2*)" : "|(cn=*%1*)(sn=*%2*)") );
-
+ result += startsWith ? "|(cn=%1*)(sn=%2*)" : "|(cn=*%1*)(sn=*%2*)";
result = result.arg( query ).arg( query );
-
- return result;
} else {
- QString result( (startsWith ? "%1=%2*" : "%1=*%2*") );
-
+ result += (startsWith ? "%1=%2*" : "%1=*%2*");
if ( attr == i18n( "Email" ) ) {
result = result.arg( "mail" ).arg( query );
} else if ( attr == i18n( "Home Number" ) ) {
@@ -347,10 +350,11 @@ QString LDAPSearchDialog::makeFilter( co
} else {
// Error?
result = QString::null;
+ return result;
}
-
- return result;
}
+ result += ")";
+ return result;
}
void LDAPSearchDialog::slotStartSearch()
[Attachment #8 (application/pgp-signature)]
_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic