1/* |
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> |
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 */ |
592 if ((char) delim == '\0' && 593 !bitset(SM_LDAP_SINGLEMATCH, flags) && 594 *result != NULL) |
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 } |
780 break; 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 */ |
993 if ((char) delim == '\0' && 994 !bitset(SM_LDAP_SINGLEMATCH, flags) && 995 *result != NULL) |
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 --- |