#ifndef _LDAP_INT_H
#define _LDAP_INT_H
#include <sys/time.h>
#ifndef NEEDPROTOS
#define NEEDPROTOS
#endif
#define SDK_VERSION (350)
struct ldapmsg {
int lm_msgid;
int lm_msgtype;
BerElement *lm_ber;
struct ldapmsg *lm_chain;
struct ldapmsg *lm_next;
unsigned long lm_time;
};
typedef struct ldap_server {
char *lsrv_host;
char *lsrv_dn;
int lsrv_port;
struct ldap_server *lsrv_next;
} LDAPServer;
#define LDAP_CACHE_BUCKETS 31
typedef struct ldapcache {
struct ldapmsg *lc_buckets[LDAP_CACHE_BUCKETS];
struct ldapmsg *lc_requests;
long lc_timeout;
long lc_maxmem;
long lc_memused;
int lc_enabled;
unsigned long lc_options;
#define LDAP_CACHE_OPT_CACHENOERRS 0x00000001
#define LDAP_CACHE_OPT_CACHEALLERRS 0x00000002
} LDAPCache;
#define NULLLDCACHE ((LDAPCache *)NULL)
typedef struct ldap_conn {
Sockbuf *lconn_sb;
int lconn_refcnt;
unsigned long lconn_lastused;
int lconn_status;
#define LDAP_CONNST_NEEDSOCKET 1
#define LDAP_CONNST_CONNECTING 2
#define LDAP_CONNST_CONNECTED 3
LDAPServer *lconn_server;
char *lconn_krbinstance;
struct ldap_conn *lconn_next;
} LDAPConn;
typedef struct ldapreq {
int lr_msgid;
int lr_status;
#define LDAP_REQST_INPROGRESS 1
#define LDAP_REQST_CHASINGREFS 2
#define LDAP_REQST_NOTCONNECTED 3
#define LDAP_REQST_WRITING 4
int lr_outrefcnt;
int lr_origid;
int lr_parentcnt;
int lr_res_msgtype;
int lr_res_errno;
char *lr_res_error;
char *lr_res_matched;
BerElement *lr_ber;
LDAPConn *lr_conn;
struct ldapreq *lr_parent;
struct ldapreq *lr_refnext;
struct ldapreq *lr_prev;
struct ldapreq *lr_next;
} LDAPRequest;
#define LDAP_MAX_ATTR_LEN 100
struct ldap {
Sockbuf ld_sb;
char *ld_host;
int ld_version;
char ld_lberoptions;
int ld_deref;
int ld_timelimit;
int ld_sizelimit;
void *ld_filtd;
char *ld_ufnprefix;
int ld_errno;
char *ld_error;
char *ld_matched;
int ld_msgid;
LDAPRequest *ld_requests;
struct ldapmsg *ld_responses;
int *ld_abandoned;
char ld_attrbuffer[LDAP_MAX_ATTR_LEN];
LDAPCache *ld_cache;
#ifdef CLDAP
char *ld_cldapdn;
#endif
char *ld_defbase;
int ld_cldaptries;
int ld_cldaptimeout;
int ld_refhoplimit;
unsigned long ld_options;
#ifdef LDAP_DNS
#define LDAP_INTERNAL_OPT_DNS 0x00000001
#endif
#define LDAP_INTERNAL_OPT_REFERRALS 0x00000002
#define LDAP_INTERNAL_OPT_RESTART 0x00000004
char *ld_defhost;
int ld_defport;
BERTranslateProc ld_lber_encode_translate_proc;
BERTranslateProc ld_lber_decode_translate_proc;
LDAPConn *ld_defconn;
LDAPConn *ld_conns;
void *ld_selectinfo;
int (*ld_rebindproc)(struct ldap *, char **, char **, int *, int, void *);
void *ld_rebindarg;
};
#define LDAP_URL_PREFIX "ldap://"
#define LDAP_URL_PREFIX_LEN 7
#define LDAP_URL_URLCOLON "URL:"
#define LDAP_URL_URLCOLON_LEN 4
#ifdef LDAP_REFERRALS
#define LDAP_REF_STR "Referral:\n"
#define LDAP_REF_STR_LEN 10
#define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
#define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
#ifdef LDAP_DNS
#define LDAP_DX_REF_STR "dx://"
#define LDAP_DX_REF_STR_LEN 5
#endif
#endif
void add_request_to_cache( struct ldap *ld, unsigned long msgtype,
BerElement *request );
void add_result_to_cache( struct ldap *ld, struct ldapmsg *result );
int check_cache( struct ldap *ld, unsigned long msgtype, BerElement *request );
#ifdef KERBEROS
char *get_kerberosv4_credentials( struct ldap *ld, char *who, char *service,
int *len );
#endif
int open_ldap_connection( struct ldap *ld, Sockbuf *sb, char *host, int defport,
char **krbinstancep, int async );
int connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port,
int async );
void close_connection( Sockbuf *sb );
#ifdef KERBEROS
char *host_connected_to( Sockbuf *sb );
#endif
int do_ldap_select( struct ldap *ld, struct timeval *timeout );
void *new_select_info( void );
void free_select_info( void *sip );
void mark_select_write( struct ldap *ld, Sockbuf *sb );
void mark_select_read( struct ldap *ld, Sockbuf *sb );
void mark_select_clear( struct ldap *ld, Sockbuf *sb );
int is_read_ready( struct ldap *ld, Sockbuf *sb );
int is_write_ready( struct ldap *ld, Sockbuf *sb );
int send_initial_request( struct ldap *ld, unsigned long msgtype,
char *dn, BerElement *ber );
BerElement *alloc_ber_with_options( struct ldap *ld );
void set_ber_options( struct ldap *ld, BerElement *ber );
int send_server_request( struct ldap *ld, BerElement *ber, int msgid,
LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
int bind );
LDAPConn *new_connection( struct ldap *ld, LDAPServer **srvlistp, int use_ldsb,
int connect, int bind );
LDAPRequest *find_request_by_msgid( struct ldap *ld, int msgid );
void free_request( struct ldap *ld, LDAPRequest *lr );
void free_connection( struct ldap *ld, LDAPConn *lc, int force, int unbind );
void dump_connection( struct ldap *ld, LDAPConn *lconns, int all );
void dump_requests_and_responses( struct ldap *ld );
int chase_referrals( struct ldap *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
int append_referral( struct ldap *ld, char **referralsp, char *s );
BerElement *ldap_build_search_req( struct ldap *ld, char *base, int scope,
char *filter, char **attrs, int attrsonly );
int ldap_ld_free( struct ldap *ld, int close );
int send_unbind( struct ldap *ld, Sockbuf *sb );
#ifdef LDAP_DNS
char **getdxbyname( char *domain );
#endif
#if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
extern
int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input );
extern
int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
#endif
#endif
char *ldap_locate_path( char *pathbuf, const char *file );
#define SUFFIX_LIBRARYDIR "/LDAP/Configuration"
#define SUFFIX_FILTERFILE SUFFIX_LIBRARYDIR"/ldapfilter.conf"
#define SUFFIX_TEMPLATEFILE SUFFIX_LIBRARYDIR"/ldaptemplates.conf"
#endif