| 1 |
#ifndef LDAP_XPLAT_H_ |
| 2 |
#define LDAP_XPLAT_H_ |
| 3 |
|
| 4 |
#define PY_SSIZE_T_CLEAN |
| 5 |
|
| 6 |
#include <Python.h> |
| 7 |
|
| 8 |
#ifdef WIN32 |
| 9 |
|
| 10 |
|
| 11 |
#include <WinSock2.h> |
| 12 |
|
| 13 |
#include "wldap-utf8.h" |
| 14 |
|
| 15 |
#define XTHREAD HANDLE |
| 16 |
#define FINDCTRL LDAPControl** |
| 17 |
|
| 18 |
int _ldap_parse_passwordpolicy_control(LDAP *ld, LDAPControl **ctrls, |
| 19 |
ber_int_t *expire, ber_int_t *grace, unsigned int *error); |
| 20 |
|
| 21 |
#else |
| 22 |
|
| 23 |
#include <ldap.h> |
| 24 |
#include <lber.h> |
| 25 |
#include <sasl/sasl.h> |
| 26 |
#include <sys/time.h> |
| 27 |
#include <pthread.h> |
| 28 |
#include <sys/socket.h> |
| 29 |
|
| 30 |
#ifdef HAVE_KRB5 |
| 31 |
#include <krb5.h> |
| 32 |
#include <gssapi.h> |
| 33 |
#include <gssapi/gssapi_krb5.h> |
| 34 |
#endif |
| 35 |
|
| 36 |
#define SOCKET int |
| 37 |
#define XTHREAD pthread_t |
| 38 |
#define FINDCTRL LDAPControl* |
| 39 |
|
| 40 |
int sasl_interact(LDAP *ld, unsigned flags, void *defaults, void *in); |
| 41 |
char *_ldap_get_opt_errormsg(LDAP *ld); |
| 42 |
int _ldap_parse_passwordpolicy_control(LDAP *ld, LDAPControl *ctrl, |
| 43 |
ber_int_t *expire, ber_int_t *grace, unsigned int *error); |
| 44 |
#endif |
| 45 |
|
| 46 |
typedef struct ldap_conndata_s { |
| 47 |
char *binddn; |
| 48 |
char *mech; |
| 49 |
char *realm; |
| 50 |
char *authcid; |
| 51 |
char *passwd; |
| 52 |
char *authzid; |
| 53 |
#ifdef WIN32 |
| 54 |
|
| 55 |
LDAP *ld; |
| 56 |
HANDLE thread; |
| 57 |
SOCKET sock; |
| 58 |
#else |
| 59 |
#ifdef HAVE_KRB5 |
| 60 |
krb5_context ctx; |
| 61 |
krb5_ccache ccache; |
| 62 |
gss_cred_id_t gsscred; |
| 63 |
char *errmsg; |
| 64 |
char request_tgt; |
| 65 |
char *ktname; |
| 66 |
#endif |
| 67 |
char **resps; |
| 68 |
int nresps; |
| 69 |
const char *rmech; |
| 70 |
#endif |
| 71 |
} ldap_conndata_t; |
| 72 |
|
| 73 |
typedef struct ldap_thread_data_s { |
| 74 |
LDAP *ld; |
| 75 |
char *url; |
| 76 |
char *sasl_sec_props; |
| 77 |
int referrals; |
| 78 |
int cert_policy; |
| 79 |
int retval; |
| 80 |
SOCKET sock; |
| 81 |
#ifdef WIN32 |
| 82 |
#else |
| 83 |
|
| 84 |
pthread_mutex_t *mux; |
| 85 |
int flag; |
| 86 |
ldap_conndata_t *info; |
| 87 |
#endif |
| 88 |
} ldapInitThreadData; |
| 89 |
|
| 90 |
#define LDAP_SERVER_EXTENDED_DN_OID "1.2.840.113556.1.4.529" |
| 91 |
#define LDAP_SERVER_TREE_DELETE_OID "1.2.840.113556.1.4.805" |
| 92 |
#define LDAP_SERVER_SD_FLAGS_OID "1.2.840.113556.1.4.801" |
| 93 |
|
| 94 |
int _ldap_finish_init_thread(char async, XTHREAD thread, int *timeout, void *misc, LDAP **ld); |
| 95 |
int _ldap_bind(LDAP *ld, ldap_conndata_t *info, char ppolicy, LDAPMessage *result, int *msgid); |
| 96 |
int _ldap_create_extended_dn_control(LDAP *ld, int format, LDAPControl **edn_ctrl); |
| 97 |
int _ldap_create_sd_flags_control(LDAP *ld, int flags, LDAPControl **edn_ctrl); |
| 98 |
void _ldap_control_free(LDAPControl *ctrl); |
| 99 |
|
| 100 |
int create_init_thread(void *param, ldap_conndata_t *info, XTHREAD *thread); |
| 101 |
void *create_conn_info(char *mech, SOCKET sock, PyObject *creds); |
| 102 |
void dealloc_conn_info(ldap_conndata_t* info); |
| 103 |
|
| 104 |
#endif |