HardenedBSD/include/sm/ldap.h

142 lines
3.5 KiB
C
Raw Normal View History

2002-02-17 22:56:45 +01:00
/*
2014-01-26 21:46:55 +01:00
* Copyright (c) 2001-2003, 2005-2007 Proofpoint, Inc. and its suppliers.
2002-02-17 22:56:45 +01:00
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
2014-01-26 21:46:55 +01:00
* $Id: ldap.h,v 1.35 2013/11/22 20:51:31 ca Exp $
2002-02-17 22:56:45 +01:00
*/
#ifndef SM_LDAP_H
# define SM_LDAP_H
# include <sm/conf.h>
# include <sm/rpool.h>
2002-04-10 05:05:00 +02:00
/*
** NOTE: These should be changed from LDAPMAP_* to SM_LDAP_*
2007-04-09 03:38:51 +02:00
** in the next major release (8.x+1) of sendmail.
2002-04-10 05:05:00 +02:00
*/
2002-02-17 22:56:45 +01:00
# ifndef LDAPMAP_MAX_ATTR
# define LDAPMAP_MAX_ATTR 64
# endif /* ! LDAPMAP_MAX_ATTR */
# ifndef LDAPMAP_MAX_FILTER
# define LDAPMAP_MAX_FILTER 1024
# endif /* ! LDAPMAP_MAX_FILTER */
# ifndef LDAPMAP_MAX_PASSWD
# define LDAPMAP_MAX_PASSWD 256
# endif /* ! LDAPMAP_MAX_PASSWD */
# if LDAPMAP
2007-04-09 03:38:51 +02:00
/* maximum number of arguments in a map lookup, see sendmail.h: MAX_MAP_ARGS */
# define SM_LDAP_ARGS 10
/* error codes from sm_ldap_search*() */
# define SM_LDAP_ERR (-1) /* generic error: ldap_search(3) */
# define SM_LDAP_ERR_ARG_MISS (-2) /* an argument is missing */
2002-02-17 22:56:45 +01:00
/* Attribute types */
2004-08-01 03:04:57 +02:00
# define SM_LDAP_ATTR_NONE (-1)
# define SM_LDAP_ATTR_OBJCLASS 0
# define SM_LDAP_ATTR_NORMAL 1
# define SM_LDAP_ATTR_DN 2
# define SM_LDAP_ATTR_FILTER 3
# define SM_LDAP_ATTR_URL 4
2002-02-17 22:56:45 +01:00
/* sm_ldap_results() flags */
2004-08-01 03:04:57 +02:00
# define SM_LDAP_SINGLEMATCH 0x0001
# define SM_LDAP_MATCHONLY 0x0002
# define SM_LDAP_USE_ALLATTR 0x0004
# define SM_LDAP_SINGLEDN 0x0008
2002-02-17 22:56:45 +01:00
struct sm_ldap_struct
{
/* needed for ldap_open or ldap_init */
2004-08-01 03:04:57 +02:00
char *ldap_uri;
char *ldap_host;
2002-02-17 22:56:45 +01:00
int ldap_port;
2002-04-10 05:05:00 +02:00
int ldap_version;
2002-02-17 22:56:45 +01:00
pid_t ldap_pid;
/* options set in ld struct before ldap_bind_s */
int ldap_deref;
time_t ldap_timelimit;
int ldap_sizelimit;
int ldap_options;
/* args for ldap_bind_s */
LDAP *ldap_ld;
char *ldap_binddn;
char *ldap_secret;
int ldap_method;
/* args for ldap_search */
char *ldap_base;
int ldap_scope;
char *ldap_filter;
char *ldap_attr[LDAPMAP_MAX_ATTR + 1];
int ldap_attr_type[LDAPMAP_MAX_ATTR + 1];
2002-04-10 05:05:00 +02:00
char *ldap_attr_needobjclass[LDAPMAP_MAX_ATTR + 1];
2002-02-17 22:56:45 +01:00
bool ldap_attrsonly;
2007-04-09 03:38:51 +02:00
bool ldap_multi_args;
2002-02-17 22:56:45 +01:00
/* args for ldap_result */
struct timeval ldap_timeout;
LDAPMessage *ldap_res;
/* ldapmap_lookup options */
char ldap_attrsep;
2007-11-05 01:04:21 +01:00
# if _FFR_LDAP_NETWORK_TIMEOUT
2010-01-26 05:17:18 +01:00
int ldap_networktmo;
2007-11-05 01:04:21 +01:00
# endif /* _FFR_LDAP_NETWORK_TIMEOUT */
2002-02-17 22:56:45 +01:00
/* Linked list of maps sharing the same LDAP binding */
void *ldap_next;
};
typedef struct sm_ldap_struct SM_LDAP_STRUCT;
2002-04-10 05:05:00 +02:00
struct sm_ldap_recurse_entry
2002-02-17 22:56:45 +01:00
{
2007-04-09 03:38:51 +02:00
char *lr_search;
int lr_type;
LDAPURLDesc *lr_ludp;
char **lr_attrs;
bool lr_done;
2002-02-17 22:56:45 +01:00
};
2002-04-10 05:05:00 +02:00
struct sm_ldap_recurse_list
{
2007-04-09 03:38:51 +02:00
int lrl_size;
int lrl_cnt;
struct sm_ldap_recurse_entry **lrl_data;
2002-04-10 05:05:00 +02:00
};
typedef struct sm_ldap_recurse_entry SM_LDAP_RECURSE_ENTRY;
2002-02-17 22:56:45 +01:00
typedef struct sm_ldap_recurse_list SM_LDAP_RECURSE_LIST;
/* functions */
extern void sm_ldap_clear __P((SM_LDAP_STRUCT *));
extern bool sm_ldap_start __P((char *, SM_LDAP_STRUCT *));
extern int sm_ldap_search __P((SM_LDAP_STRUCT *, char *));
2007-04-09 03:38:51 +02:00
extern int sm_ldap_search_m __P((SM_LDAP_STRUCT *, char **));
2002-04-10 05:05:00 +02:00
extern int sm_ldap_results __P((SM_LDAP_STRUCT *, int, int, int,
SM_RPOOL_T *, char **, int *, int *,
2002-02-17 22:56:45 +01:00
SM_LDAP_RECURSE_LIST *));
extern void sm_ldap_setopts __P((LDAP *, SM_LDAP_STRUCT *));
extern int sm_ldap_geterrno __P((LDAP *));
extern void sm_ldap_close __P((SM_LDAP_STRUCT *));
2002-04-10 05:05:00 +02:00
/* Portability defines */
# if !SM_CONF_LDAP_MEMFREE
# define ldap_memfree(x) ((void) 0)
# endif /* !SM_CONF_LDAP_MEMFREE */
# endif /* LDAPMAP */
2002-02-17 22:56:45 +01:00
#endif /* ! SM_LDAP_H */