Hello,
For anyone interested, included a little patch for courierldapaliasd to
enable it to lookup more than a single address (entry) when doing lookups on
the LDAP_MAIL field. It makes it possible for users to share a common
email-address. Everyone with this address will receive mail for this address
without the need to create a separate LDAP-entry for this address.
I posted this question few weeks ago on this list, but despite help, I could
not find the answer in the docs, so I created this patch, which could also
be very obsolete if I misread the docs ......
diff -ruN courier-0.47-orig/courier/ldapaliasd.c
courier-0.47/courier/ldapaliasd.c
--- courier-0.47-orig/courier/ldapaliasd.c 2004-03-14 03:26:24.000000000
+0100
+++ courier-0.47/courier/ldapaliasd.c 2004-10-28 08:54:47.010680840 +0200
@@ -311,28 +311,33 @@
if (!result)
return (0); /* Protocol error. */
- if (ldap_count_entries(my_ldap_fp, result) == 1)
+ if (ldap_count_entries(my_ldap_fp, result) != 0)
{
- LDAPMessage *entry;
+
+ LDAPMessage *entry;
+
+ for ( entry = ldap_first_entry( my_ldap_fp,result ); entry != NULL;
+ entry = ldap_next_entry( my_ldap_fp,entry ) )
+ {
char **values;
+ values=ldap_get_values(my_ldap_fp, entry, (char *)maildropfield);
- if ((entry=ldap_first_entry(my_ldap_fp, result)) != NULL &&
- (values=ldap_get_values(my_ldap_fp, entry,
- (char *)
- maildropfield)) != NULL)
+ if (entry != NULL && values != NULL) /* No entries. */
{
- int n=ldap_count_values(values);
- int i;
+ int n=ldap_count_values(values);
+ int i;
- for (i=0; i<n; i++)
- {
- fprintf(outfp, "maildrop: %s\n",
- values[i]);
- rc=0;
- }
- ldap_value_free(values);
+ for (i=0; i<n; i++)
+ {
+ fprintf(outfp, "maildrop: %s\n", values[i]);
+ rc=0;
+ }
+ ldap_value_free(values);
}
+ }
+ ldap_msgfree(entry);
}
+
ldap_msgfree(result);
if (rc == 0)