Deleted Added
full compact
ldap.c (141858) ldap.c (147078)
1/*
1/*
2 * Copyright (c) 2001-2004 Sendmail, Inc. and its suppliers.
2 * Copyright (c) 2001-2005 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 */
9
10#include <sm/gen.h>
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 */
9
10#include <sm/gen.h>
11SM_RCSID("@(#)$Id: ldap.c,v 1.60 2004/08/03 20:42:21 ca Exp $")
11SM_RCSID("@(#)$Id: ldap.c,v 1.62 2005/02/24 00:30:01 ca Exp $")
12
13#if LDAPMAP
14# include <sys/types.h>
15# include <errno.h>
16# include <setjmp.h>
17# include <stdlib.h>
18# include <unistd.h>
19

--- 564 unchanged lines hidden (view full) ---

584 while ((ret = ldap_result(lmap->ldap_ld, msgid, 0,
585 (lmap->ldap_timeout.tv_sec == 0 ? NULL :
586 &(lmap->ldap_timeout)),
587 &(lmap->ldap_res))) == LDAP_RES_SEARCH_ENTRY)
588 {
589 LDAPMessage *entry;
590
591 /* If we don't want multiple values and we have one, break */
12
13#if LDAPMAP
14# include <sys/types.h>
15# include <errno.h>
16# include <setjmp.h>
17# include <stdlib.h>
18# include <unistd.h>
19

--- 564 unchanged lines hidden (view full) ---

584 while ((ret = ldap_result(lmap->ldap_ld, msgid, 0,
585 (lmap->ldap_timeout.tv_sec == 0 ? NULL :
586 &(lmap->ldap_timeout)),
587 &(lmap->ldap_res))) == LDAP_RES_SEARCH_ENTRY)
588 {
589 LDAPMessage *entry;
590
591 /* If we don't want multiple values and we have one, break */
592 if ((char) delim == '\0' && *result != NULL)
592 if ((char) delim == '\0' &&
593 !bitset(SM_LDAP_SINGLEMATCH, flags) &&
594 *result != NULL)
593 break;
594
595 /* Cycle through all entries */
596 for (entry = ldap_first_entry(lmap->ldap_ld, lmap->ldap_res);
597 entry != NULL;
598 entry = ldap_next_entry(lmap->ldap_ld, lmap->ldap_res))
599 {
600 BerElement *ber;

--- 161 unchanged lines hidden (view full) ---

762 ** return first found.
763 */
764
765 if ((char) delim == '\0')
766 {
767 if (*result != NULL)
768 {
769 /* already have a value */
595 break;
596
597 /* Cycle through all entries */
598 for (entry = ldap_first_entry(lmap->ldap_ld, lmap->ldap_res);
599 entry != NULL;
600 entry = ldap_next_entry(lmap->ldap_ld, lmap->ldap_res))
601 {
602 BerElement *ber;

--- 161 unchanged lines hidden (view full) ---

764 ** return first found.
765 */
766
767 if ((char) delim == '\0')
768 {
769 if (*result != NULL)
770 {
771 /* already have a value */
772 if (bitset(SM_LDAP_SINGLEMATCH,
773 flags))
774 {
775 /* only wanted one match */
776 SM_LDAP_ERROR_CLEANUP();
777 errno = ENOENT;
778 return EX_NOTFOUND;
779 }
770 break;
771 }
772
780 break;
781 }
782
773 if (bitset(SM_LDAP_SINGLEMATCH,
774 flags) &&
775 *result != NULL)
776 {
777 /* only wanted one match */
778 SM_LDAP_ERROR_CLEANUP();
779 errno = ENOENT;
780 return EX_NOTFOUND;
781 }
782
783 if (lmap->ldap_attrsonly == LDAPMAP_TRUE)
784 {
785 *result = sm_rpool_strdup_x(rpool,
786 attr);
787 ldap_memfree(attr);
788 break;
789 }
790

--- 194 unchanged lines hidden (view full) ---

985 }
986 if (rl->lr_attrs != NULL)
987 {
988 free(rl->lr_attrs);
989 rl->lr_attrs = NULL;
990 }
991
992 /* We don't want multiple values and we have one */
783 if (lmap->ldap_attrsonly == LDAPMAP_TRUE)
784 {
785 *result = sm_rpool_strdup_x(rpool,
786 attr);
787 ldap_memfree(attr);
788 break;
789 }
790

--- 194 unchanged lines hidden (view full) ---

985 }
986 if (rl->lr_attrs != NULL)
987 {
988 free(rl->lr_attrs);
989 rl->lr_attrs = NULL;
990 }
991
992 /* We don't want multiple values and we have one */
993 if ((char) delim == '\0' && *result != NULL)
993 if ((char) delim == '\0' &&
994 !bitset(SM_LDAP_SINGLEMATCH, flags) &&
995 *result != NULL)
994 break;
995 }
996 save_errno = sm_ldap_geterrno(lmap->ldap_ld);
997 if (save_errno != LDAP_SUCCESS &&
998 save_errno != LDAP_DECODING_ERROR)
999 {
1000 /* Must be an error */
1001 save_errno += E_LDAPBASE;

--- 329 unchanged lines hidden ---
996 break;
997 }
998 save_errno = sm_ldap_geterrno(lmap->ldap_ld);
999 if (save_errno != LDAP_SUCCESS &&
1000 save_errno != LDAP_DECODING_ERROR)
1001 {
1002 /* Must be an error */
1003 save_errno += E_LDAPBASE;

--- 329 unchanged lines hidden ---