From 4ffe607f1ca52b8bb1e298aea60fb6d2d1f63d5a Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Mon, 2 Jan 2006 20:38:57 +0000 Subject: [PATCH] Bug 287832 Clean up nsDirPrefs.cpp. Part 2 - stop LDAP Change log using old nsDirPrefs attribute map stuff r/sr=dmose --- .../addrbook/src/nsAbLDAPChangeLogQuery.cpp | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mailnews/addrbook/src/nsAbLDAPChangeLogQuery.cpp b/mailnews/addrbook/src/nsAbLDAPChangeLogQuery.cpp index 0f6a38ee0aca..0387f17c1638 100644 --- a/mailnews/addrbook/src/nsAbLDAPChangeLogQuery.cpp +++ b/mailnews/addrbook/src/nsAbLDAPChangeLogQuery.cpp @@ -121,15 +121,20 @@ NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryAuthDN(const nsACString & aValueUsedT if(!mInitialized) return NS_ERROR_NOT_INITIALIZED; - nsresult rv = NS_OK; + nsresult rv = NS_OK; + + nsCOMPtr mapSvc = + do_GetService("@mozilla.org/addressbook/ldap-attribute-map-service;1", &rv); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr attrMap; + rv = mapSvc->GetMapForPrefBranch(nsDependentCString(mDirServer->prefName), getter_AddRefs(attrMap)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCAutoString filter; + rv = attrMap->GetFirstAttribute(NS_LITERAL_CSTRING("PrimaryEmail"), filter); + NS_ENSURE_SUCCESS(rv, rv); - CharPtrArrayGuard attributes; - *attributes.GetSizeAddr() = 2; - *attributes.GetArrayAddr() = NS_STATIC_CAST(char **, nsMemory::Alloc((*attributes.GetSizeAddr()) * sizeof(char *))); - attributes.GetArray()[0] = ToNewCString(nsDependentCString(DIR_GetFirstAttributeString(mDirServer, cn))); - attributes.GetArray()[1] = nsnull; - - nsCAutoString filter(DIR_GetFirstAttributeString(mDirServer, auth)); filter += '='; filter += aValueUsedToFindDn; @@ -141,8 +146,10 @@ NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryAuthDN(const nsACString & aValueUsedT rv = CreateNewLDAPOperation(); NS_ENSURE_SUCCESS(rv, rv); + // XXX We really should be using LDAP_NO_ATTRS here once its exposed via + // the XPCOM layer of the directory code. return mOperation->SearchExt(dn, nsILDAPURL::SCOPE_SUBTREE, filter, - attributes.GetSize(), attributes.GetArray(), + 0, nsnull, 0, 0); }