1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 2001-2002 Sendmail, Inc. and its suppliers. 3*7c478bd9Sstevel@tonic-gate * All rights reserved. 4*7c478bd9Sstevel@tonic-gate * 5*7c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 6*7c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 7*7c478bd9Sstevel@tonic-gate * the sendmail distribution. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * $Id: ldap.h,v 1.27 2003/12/20 09:23:47 gshapiro Exp $ 10*7c478bd9Sstevel@tonic-gate */ 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 13*7c478bd9Sstevel@tonic-gate 14*7c478bd9Sstevel@tonic-gate #ifndef SM_LDAP_H 15*7c478bd9Sstevel@tonic-gate # define SM_LDAP_H 16*7c478bd9Sstevel@tonic-gate 17*7c478bd9Sstevel@tonic-gate # include <sm/conf.h> 18*7c478bd9Sstevel@tonic-gate # include <sm/rpool.h> 19*7c478bd9Sstevel@tonic-gate 20*7c478bd9Sstevel@tonic-gate /* 21*7c478bd9Sstevel@tonic-gate ** NOTE: These should be changed from LDAPMAP_* to SM_LDAP_* 22*7c478bd9Sstevel@tonic-gate ** in the next major release (8.13) of sendmail. 23*7c478bd9Sstevel@tonic-gate */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate # ifndef LDAPMAP_MAX_ATTR 26*7c478bd9Sstevel@tonic-gate # define LDAPMAP_MAX_ATTR 64 27*7c478bd9Sstevel@tonic-gate # endif /* ! LDAPMAP_MAX_ATTR */ 28*7c478bd9Sstevel@tonic-gate # ifndef LDAPMAP_MAX_FILTER 29*7c478bd9Sstevel@tonic-gate # define LDAPMAP_MAX_FILTER 1024 30*7c478bd9Sstevel@tonic-gate # endif /* ! LDAPMAP_MAX_FILTER */ 31*7c478bd9Sstevel@tonic-gate # ifndef LDAPMAP_MAX_PASSWD 32*7c478bd9Sstevel@tonic-gate # define LDAPMAP_MAX_PASSWD 256 33*7c478bd9Sstevel@tonic-gate # endif /* ! LDAPMAP_MAX_PASSWD */ 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate # if LDAPMAP 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate /* Attribute types */ 38*7c478bd9Sstevel@tonic-gate # define SM_LDAP_ATTR_NONE (-1) 39*7c478bd9Sstevel@tonic-gate # define SM_LDAP_ATTR_OBJCLASS 0 40*7c478bd9Sstevel@tonic-gate # define SM_LDAP_ATTR_NORMAL 1 41*7c478bd9Sstevel@tonic-gate # define SM_LDAP_ATTR_DN 2 42*7c478bd9Sstevel@tonic-gate # define SM_LDAP_ATTR_FILTER 3 43*7c478bd9Sstevel@tonic-gate # define SM_LDAP_ATTR_URL 4 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* sm_ldap_results() flags */ 46*7c478bd9Sstevel@tonic-gate # define SM_LDAP_SINGLEMATCH 0x0001 47*7c478bd9Sstevel@tonic-gate # define SM_LDAP_MATCHONLY 0x0002 48*7c478bd9Sstevel@tonic-gate # define SM_LDAP_USE_ALLATTR 0x0004 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate struct sm_ldap_struct 51*7c478bd9Sstevel@tonic-gate { 52*7c478bd9Sstevel@tonic-gate /* needed for ldap_open or ldap_init */ 53*7c478bd9Sstevel@tonic-gate char *ldap_uri; 54*7c478bd9Sstevel@tonic-gate char *ldap_host; 55*7c478bd9Sstevel@tonic-gate int ldap_port; 56*7c478bd9Sstevel@tonic-gate int ldap_version; 57*7c478bd9Sstevel@tonic-gate pid_t ldap_pid; 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* options set in ld struct before ldap_bind_s */ 60*7c478bd9Sstevel@tonic-gate int ldap_deref; 61*7c478bd9Sstevel@tonic-gate time_t ldap_timelimit; 62*7c478bd9Sstevel@tonic-gate int ldap_sizelimit; 63*7c478bd9Sstevel@tonic-gate int ldap_options; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* args for ldap_bind_s */ 66*7c478bd9Sstevel@tonic-gate LDAP *ldap_ld; 67*7c478bd9Sstevel@tonic-gate char *ldap_binddn; 68*7c478bd9Sstevel@tonic-gate char *ldap_secret; 69*7c478bd9Sstevel@tonic-gate int ldap_method; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* args for ldap_search */ 72*7c478bd9Sstevel@tonic-gate char *ldap_base; 73*7c478bd9Sstevel@tonic-gate int ldap_scope; 74*7c478bd9Sstevel@tonic-gate char *ldap_filter; 75*7c478bd9Sstevel@tonic-gate char *ldap_attr[LDAPMAP_MAX_ATTR + 1]; 76*7c478bd9Sstevel@tonic-gate int ldap_attr_type[LDAPMAP_MAX_ATTR + 1]; 77*7c478bd9Sstevel@tonic-gate char *ldap_attr_needobjclass[LDAPMAP_MAX_ATTR + 1]; 78*7c478bd9Sstevel@tonic-gate bool ldap_attrsonly; 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate /* args for ldap_result */ 81*7c478bd9Sstevel@tonic-gate struct timeval ldap_timeout; 82*7c478bd9Sstevel@tonic-gate LDAPMessage *ldap_res; 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate /* ldapmap_lookup options */ 85*7c478bd9Sstevel@tonic-gate char ldap_attrsep; 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /* Linked list of maps sharing the same LDAP binding */ 88*7c478bd9Sstevel@tonic-gate void *ldap_next; 89*7c478bd9Sstevel@tonic-gate }; 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate typedef struct sm_ldap_struct SM_LDAP_STRUCT; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate struct sm_ldap_recurse_entry 94*7c478bd9Sstevel@tonic-gate { 95*7c478bd9Sstevel@tonic-gate char *lr_search; 96*7c478bd9Sstevel@tonic-gate int lr_type; 97*7c478bd9Sstevel@tonic-gate LDAPURLDesc *lr_ludp; 98*7c478bd9Sstevel@tonic-gate char **lr_attrs; 99*7c478bd9Sstevel@tonic-gate bool lr_done; 100*7c478bd9Sstevel@tonic-gate }; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate struct sm_ldap_recurse_list 103*7c478bd9Sstevel@tonic-gate { 104*7c478bd9Sstevel@tonic-gate int lr_size; 105*7c478bd9Sstevel@tonic-gate int lr_cnt; 106*7c478bd9Sstevel@tonic-gate struct sm_ldap_recurse_entry **lr_data; 107*7c478bd9Sstevel@tonic-gate }; 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate typedef struct sm_ldap_recurse_entry SM_LDAP_RECURSE_ENTRY; 110*7c478bd9Sstevel@tonic-gate typedef struct sm_ldap_recurse_list SM_LDAP_RECURSE_LIST; 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* functions */ 113*7c478bd9Sstevel@tonic-gate extern void sm_ldap_clear __P((SM_LDAP_STRUCT *)); 114*7c478bd9Sstevel@tonic-gate extern bool sm_ldap_start __P((char *, SM_LDAP_STRUCT *)); 115*7c478bd9Sstevel@tonic-gate extern int sm_ldap_search __P((SM_LDAP_STRUCT *, char *)); 116*7c478bd9Sstevel@tonic-gate extern int sm_ldap_results __P((SM_LDAP_STRUCT *, int, int, int, 117*7c478bd9Sstevel@tonic-gate SM_RPOOL_T *, char **, int *, int *, 118*7c478bd9Sstevel@tonic-gate SM_LDAP_RECURSE_LIST *)); 119*7c478bd9Sstevel@tonic-gate extern void sm_ldap_setopts __P((LDAP *, SM_LDAP_STRUCT *)); 120*7c478bd9Sstevel@tonic-gate extern int sm_ldap_geterrno __P((LDAP *)); 121*7c478bd9Sstevel@tonic-gate extern void sm_ldap_close __P((SM_LDAP_STRUCT *)); 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate /* Portability defines */ 124*7c478bd9Sstevel@tonic-gate # if !SM_CONF_LDAP_MEMFREE 125*7c478bd9Sstevel@tonic-gate # define ldap_memfree(x) ((void) 0) 126*7c478bd9Sstevel@tonic-gate # endif /* !SM_CONF_LDAP_MEMFREE */ 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate # endif /* LDAPMAP */ 129*7c478bd9Sstevel@tonic-gate #endif /* ! SM_LDAP_H */ 130