ldap.h revision 94334
190792Sgshapiro/* 290792Sgshapiro * Copyright (c) 2001-2002 Sendmail, Inc. and its suppliers. 390792Sgshapiro * All rights reserved. 490792Sgshapiro * 590792Sgshapiro * By using this file, you agree to the terms and conditions set 690792Sgshapiro * forth in the LICENSE file which can be found at the top level of 790792Sgshapiro * the sendmail distribution. 890792Sgshapiro * 994334Sgshapiro * $Id: ldap.h,v 1.22 2002/03/05 02:17:26 ca Exp $ 1090792Sgshapiro */ 1190792Sgshapiro 1290792Sgshapiro#ifndef SM_LDAP_H 1390792Sgshapiro# define SM_LDAP_H 1490792Sgshapiro 1590792Sgshapiro# include <sm/conf.h> 1690792Sgshapiro# include <sm/rpool.h> 1790792Sgshapiro 1894334Sgshapiro/* 1994334Sgshapiro** NOTE: These should be changed from LDAPMAP_* to SM_LDAP_* 2094334Sgshapiro** in the next major release (8.13) of sendmail. 2194334Sgshapiro*/ 2294334Sgshapiro 2390792Sgshapiro# ifndef LDAPMAP_MAX_ATTR 2490792Sgshapiro# define LDAPMAP_MAX_ATTR 64 2590792Sgshapiro# endif /* ! LDAPMAP_MAX_ATTR */ 2690792Sgshapiro# ifndef LDAPMAP_MAX_FILTER 2790792Sgshapiro# define LDAPMAP_MAX_FILTER 1024 2890792Sgshapiro# endif /* ! LDAPMAP_MAX_FILTER */ 2990792Sgshapiro# ifndef LDAPMAP_MAX_PASSWD 3090792Sgshapiro# define LDAPMAP_MAX_PASSWD 256 3190792Sgshapiro# endif /* ! LDAPMAP_MAX_PASSWD */ 3290792Sgshapiro 3390792Sgshapiro# if LDAPMAP 3490792Sgshapiro 3590792Sgshapiro# if _FFR_LDAP_RECURSION 3690792Sgshapiro 3790792Sgshapiro/* Attribute types */ 3894334Sgshapiro# define SM_LDAP_ATTR_NONE (-1) 3994334Sgshapiro# define SM_LDAP_ATTR_OBJCLASS 0 4094334Sgshapiro# define SM_LDAP_ATTR_NORMAL 1 4194334Sgshapiro# define SM_LDAP_ATTR_DN 2 4294334Sgshapiro# define SM_LDAP_ATTR_FILTER 3 4394334Sgshapiro# define SM_LDAP_ATTR_URL 4 4490792Sgshapiro 4590792Sgshapiro/* sm_ldap_results() flags */ 4690792Sgshapiro# define SM_LDAP_SINGLEMATCH 0x0001 4790792Sgshapiro# define SM_LDAP_MATCHONLY 0x0002 4894334Sgshapiro# define SM_LDAP_USE_ALLATTR 0x0004 4994334Sgshapiro 5090792Sgshapiro# endif /* _FFR_LDAP_RECURSION */ 5190792Sgshapiro 5290792Sgshapirostruct sm_ldap_struct 5390792Sgshapiro{ 5490792Sgshapiro /* needed for ldap_open or ldap_init */ 5594334Sgshapiro char *ldap_target; 5690792Sgshapiro int ldap_port; 5794334Sgshapiro# if _FFR_LDAP_URI 5894334Sgshapiro bool ldap_uri; 5994334Sgshapiro# endif /* _FFR_LDAP_URI */ 6094334Sgshapiro# if _FFR_LDAP_SETVERSION 6194334Sgshapiro int ldap_version; 6294334Sgshapiro# endif /* _FFR_LDAP_SETVERSION */ 6390792Sgshapiro pid_t ldap_pid; 6490792Sgshapiro 6590792Sgshapiro /* options set in ld struct before ldap_bind_s */ 6690792Sgshapiro int ldap_deref; 6790792Sgshapiro time_t ldap_timelimit; 6890792Sgshapiro int ldap_sizelimit; 6990792Sgshapiro int ldap_options; 7090792Sgshapiro 7190792Sgshapiro /* args for ldap_bind_s */ 7290792Sgshapiro LDAP *ldap_ld; 7390792Sgshapiro char *ldap_binddn; 7490792Sgshapiro char *ldap_secret; 7590792Sgshapiro int ldap_method; 7690792Sgshapiro 7790792Sgshapiro /* args for ldap_search */ 7890792Sgshapiro char *ldap_base; 7990792Sgshapiro int ldap_scope; 8090792Sgshapiro char *ldap_filter; 8190792Sgshapiro char *ldap_attr[LDAPMAP_MAX_ATTR + 1]; 8290792Sgshapiro# if _FFR_LDAP_RECURSION 8390792Sgshapiro int ldap_attr_type[LDAPMAP_MAX_ATTR + 1]; 8494334Sgshapiro char *ldap_attr_needobjclass[LDAPMAP_MAX_ATTR + 1]; 8590792Sgshapiro# endif /* _FFR_LDAP_RECURSION */ 8690792Sgshapiro bool ldap_attrsonly; 8790792Sgshapiro 8890792Sgshapiro /* args for ldap_result */ 8990792Sgshapiro struct timeval ldap_timeout; 9090792Sgshapiro LDAPMessage *ldap_res; 9190792Sgshapiro 9290792Sgshapiro /* ldapmap_lookup options */ 9390792Sgshapiro char ldap_attrsep; 9490792Sgshapiro 9590792Sgshapiro /* Linked list of maps sharing the same LDAP binding */ 9690792Sgshapiro void *ldap_next; 9790792Sgshapiro}; 9890792Sgshapiro 9990792Sgshapirotypedef struct sm_ldap_struct SM_LDAP_STRUCT; 10090792Sgshapiro 10190792Sgshapiro# if _FFR_LDAP_RECURSION 10294334Sgshapirostruct sm_ldap_recurse_entry 10390792Sgshapiro{ 10490792Sgshapiro char *lr_search; 10590792Sgshapiro int lr_type; 10694334Sgshapiro bool lr_done; 10790792Sgshapiro}; 10890792Sgshapiro 10994334Sgshapirostruct sm_ldap_recurse_list 11094334Sgshapiro{ 11194334Sgshapiro int lr_size; 11294334Sgshapiro int lr_cnt; 11394334Sgshapiro struct sm_ldap_recurse_entry **lr_data; 11494334Sgshapiro}; 11594334Sgshapiro 11694334Sgshapirotypedef struct sm_ldap_recurse_entry SM_LDAP_RECURSE_ENTRY; 11790792Sgshapirotypedef struct sm_ldap_recurse_list SM_LDAP_RECURSE_LIST; 11890792Sgshapiro# endif /* _FFR_LDAP_RECURSION */ 11990792Sgshapiro 12090792Sgshapiro/* functions */ 12190792Sgshapiroextern void sm_ldap_clear __P((SM_LDAP_STRUCT *)); 12290792Sgshapiroextern bool sm_ldap_start __P((char *, SM_LDAP_STRUCT *)); 12390792Sgshapiroextern int sm_ldap_search __P((SM_LDAP_STRUCT *, char *)); 12490792Sgshapiro# if _FFR_LDAP_RECURSION 12594334Sgshapiroextern int sm_ldap_results __P((SM_LDAP_STRUCT *, int, int, int, 12694334Sgshapiro SM_RPOOL_T *, char **, int *, int *, 12790792Sgshapiro SM_LDAP_RECURSE_LIST *)); 12890792Sgshapiro# endif /* _FFR_LDAP_RECURSION */ 12990792Sgshapiroextern void sm_ldap_setopts __P((LDAP *, SM_LDAP_STRUCT *)); 13090792Sgshapiroextern int sm_ldap_geterrno __P((LDAP *)); 13190792Sgshapiroextern void sm_ldap_close __P((SM_LDAP_STRUCT *)); 13294334Sgshapiro 13394334Sgshapiro/* Portability defines */ 13494334Sgshapiro# if !SM_CONF_LDAP_MEMFREE 13594334Sgshapiro# define ldap_memfree(x) ((void) 0) 13694334Sgshapiro# endif /* !SM_CONF_LDAP_MEMFREE */ 13794334Sgshapiro 13890792Sgshapiro# endif /* LDAPMAP */ 13990792Sgshapiro#endif /* ! SM_LDAP_H */ 140