2 * Copyright (c) 2001-2003, 2005-2007 Proofpoint, Inc. and its suppliers.
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.
9 * $Id: ldap.h,v 1.35 2013-11-22 20:51:31 ca Exp $
16 # include <sm/rpool.h>
19 ** NOTE: These should be changed from LDAPMAP_* to SM_LDAP_*
20 ** in the next major release (8.x+1) of sendmail.
23 # ifndef LDAPMAP_MAX_ATTR
24 # define LDAPMAP_MAX_ATTR 64
26 # ifndef LDAPMAP_MAX_FILTER
27 # define LDAPMAP_MAX_FILTER 1024
29 # ifndef LDAPMAP_MAX_PASSWD
30 # define LDAPMAP_MAX_PASSWD 256
35 /* maximum number of arguments in a map lookup, see sendmail.h: MAX_MAP_ARGS */
36 # define SM_LDAP_ARGS 10
38 /* error codes from sm_ldap_search*() */
39 # define SM_LDAP_ERR (-1) /* generic error: ldap_search(3) */
40 # define SM_LDAP_ERR_ARG_MISS (-2) /* an argument is missing */
43 # define SM_LDAP_ATTR_NONE (-1)
44 # define SM_LDAP_ATTR_OBJCLASS 0
45 # define SM_LDAP_ATTR_NORMAL 1
46 # define SM_LDAP_ATTR_DN 2
47 # define SM_LDAP_ATTR_FILTER 3
48 # define SM_LDAP_ATTR_URL 4
50 /* sm_ldap_results() flags */
51 # define SM_LDAP_SINGLEMATCH 0x0001
52 # define SM_LDAP_MATCHONLY 0x0002
53 # define SM_LDAP_USE_ALLATTR 0x0004
54 # define SM_LDAP_SINGLEDN 0x0008
58 /* needed for ldap_open or ldap_init */
65 /* options set in ld struct before ldap_bind_s */
67 time_t ldap_timelimit;
71 /* args for ldap_bind_s */
77 /* args for ldap_search */
81 char *ldap_attr[LDAPMAP_MAX_ATTR + 1];
82 int ldap_attr_type[LDAPMAP_MAX_ATTR + 1];
83 char *ldap_attr_needobjclass[LDAPMAP_MAX_ATTR + 1];
87 /* args for ldap_result */
88 struct timeval ldap_timeout;
89 LDAPMessage *ldap_res;
91 /* ldapmap_lookup options */
94 # if LDAP_NETWORK_TIMEOUT
101 /* Linked list of maps sharing the same LDAP binding */
105 typedef struct sm_ldap_struct SM_LDAP_STRUCT;
107 struct sm_ldap_recurse_entry
111 LDAPURLDesc *lr_ludp;
116 struct sm_ldap_recurse_list
120 struct sm_ldap_recurse_entry **lrl_data;
123 typedef struct sm_ldap_recurse_entry SM_LDAP_RECURSE_ENTRY;
124 typedef struct sm_ldap_recurse_list SM_LDAP_RECURSE_LIST;
127 extern void sm_ldap_clear __P((SM_LDAP_STRUCT *));
128 extern bool sm_ldap_start __P((char *, SM_LDAP_STRUCT *));
129 extern int sm_ldap_search __P((SM_LDAP_STRUCT *, char *));
130 extern int sm_ldap_search_m __P((SM_LDAP_STRUCT *, char **));
131 extern int sm_ldap_results __P((SM_LDAP_STRUCT *, int, int, int,
132 SM_RPOOL_T *, char **, int *, int *,
133 SM_LDAP_RECURSE_LIST *));
134 extern void sm_ldap_setopts __P((LDAP *, SM_LDAP_STRUCT *));
135 extern int sm_ldap_geterrno __P((LDAP *));
136 extern void sm_ldap_close __P((SM_LDAP_STRUCT *));
138 /* Portability defines */
139 # if !SM_CONF_LDAP_MEMFREE
140 # define ldap_memfree(x) ((void) 0)
143 # endif /* LDAPMAP */
144 #endif /* ! SM_LDAP_H */