Debian Codegraph @

src/_bonsai/wldap-utf8.h

raw symbols SCIP
1 #ifndef WLDAP_UTF8_H_
2 #define WLDAP_UTF8_H_
3
4 /*****************************************************************************
5 * These functions and structs are (mostly) redefinitions of the used WinLDAP
6 * functions and structs in the extension, but instead using either ANSI or
7 * UTF-16 encoded character string, all of the functions expect and return
8 * narrow UTF-8 encoded values. The inputs are encoded to wide UTF-16 format
9 * before the corresponding wide function (that supports unicode) is explicitly
10 * called. The returned values are decoded back to UTF-8. Some of the functions
11 * are renamed or their signatures are changed to match with the ones defined
12 * in the OpenLDAP's API. The disadvantage of this approach is that the
13 * conversations generate extra overhead for every LDAP operations on Windows,
14 * but better platform independent unicode support can be achieved without
15 * breaking the rest of the codebase's integrity with platfrom dependent code.
16 ******************************************************************************/
17 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
18
19 #define UNICODE 1
20
21 #include <windows.h>
22 #include <winldap.h>
23 #include <winber.h>
24
25 #define SECURITY_WIN32 1
26
27 #include <security.h>
28 #include <Sspi.h>
29
30 /* These fields are differed from the ones in the OpenLDAP. */
31 #define attributeType sk_attrtype
32 #define orderingRule sk_matchruleoid
33 #define reverseOrder sk_reverseorder
34
35 #define attributeType sk_attrtype
36 #define timeval l_timeval
37
38 #define LDAP_OPT_X_TLS_PACKAGE 0x6011
39
40 #define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319"
41 #define LDAP_CONTROL_PASSWORDPOLICYREQUEST "1.3.6.1.4.1.42.2.27.8.5.1"
42 #define LDAP_CONTROL_PASSWORDPOLICYRESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
43 #define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474"
44 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2"
45
46 /* All of the used WinLDAP macros are redefined. */
47 #undef LDAPControl
48 #undef LDAPMod
49 #undef LDAPSortKey
50
51 #undef LDAPAPIInfo
52
53 #undef ldap_create_page_control
54 #undef ldap_control_free
55 #undef ldap_controls_free
56 #undef ldap_create_vlv_control
57
58 #undef ldap_get_dn
59 #undef ldap_add_ext
60 #undef ldap_modify_ext
61 #undef ldap_delete_ext
62 #undef ldap_first_attribute
63 #undef ldap_next_attribute
64 #undef ldap_get_values_len
65 #undef ldap_rename
66 #undef ldap_search_ext
67 #undef ldap_create_sort_control
68 #undef ldap_extended_operation
69 #undef ldap_parse_extended_result
70 #undef ldap_parse_reference
71 #undef ldap_parse_result
72 #undef ldap_err2string
73 #undef ldap_memfree
74 #undef ldap_start_tls_s
75 #undef ldap_simple_bind_s
76
77 #undef ldap_get_option
78
79 #define LDAPControl LDAPControlA
80 #define LDAPMod LDAPModA
81 #define LDAPSortKey LDAPSortKeyA
82
83 #define LDAPAPIInfo LDAPAPIInfoA
84
85 #define ldap_create_page_control ldap_create_page_controlA
86 #define ldap_create_sort_control ldap_create_sort_controlA
87 #define ldap_control_free ldap_control_freeA
88
89 #define ldap_get_dn ldap_get_dnU
90 #define ldap_add_ext ldap_add_extU
91 #define ldap_modify_ext ldap_modify_extU
92 #define ldap_delete_ext ldap_delete_extU
93 #define ldap_first_attribute ldap_first_attributeU
94 #define ldap_next_attribute ldap_next_attributeU
95 #define ldap_get_values_len ldap_get_values_lenU
96 #define ldap_rename ldap_renameU
97 #define ldap_search_ext ldap_search_extU
98 #define ldap_extended_operation ldap_extended_operationU
99 #define ldap_parse_extended_result ldap_parse_extended_resultU
100 #define ldap_parse_result ldap_parse_resultU
101 #define ldap_err2string ldap_err2stringU
102 /* Simple free is sufficed, because no WinLDAP dependent allocation
103 should be kept outside of the scope of the new functions. */
104 #define ldap_memfree free
105 #define ldap_start_tls ldap_start_tlsU
106 #define ldap_start_tls_s ldap_start_tls_sU
107 #define ldap_simple_bind_s ldap_simple_bind_sU
108 #define ldap_controls_free ldap_controls_freeU
109 #define ldap_create_vlv_control ldap_create_vlv_controlU
110 #define ldap_parse_vlvresponse_control ldap_parse_vlvresponse_controlU
111 #define ldap_create_passwordpolicy_control ldap_create_passwordpolicy_controlU
112 #define ldap_parse_passwordpolicy_control ldap_parse_passwordpolicy_controlU
113 #define ldap_parse_sortresponse_control ldap_parse_sortresponse_controlU
114 #define ldap_parse_reference ldap_parse_referenceU
115
116 /* These functions are not represented in the WinLDAP API. */
117 #define ldap_parse_pageresponse_control(ld, ctrls, count, cookie) ldap_parse_pageresponse_controlU(ld, ctrls, count, &(cookie))
118 #define ldap_control_create ldap_control_createU
119 #define ldap_control_find ldap_control_findU
120 #define ldap_initialize ldap_initializeU
121 #define ldap_sasl_sspi_bind_s ldap_sasl_sspi_bind_sU
122 #define _ldap_get_opt_errormsg _ldap_get_opt_errormsgU
123
124 #define ldap_get_option ldap_get_optionU
125
126 typedef struct sasl_defaults_s {
127 char *authcid;
128 char *passwd;
129 char *realm;
130 char *authzid;
131 } sasl_defaults_t;
132
133 typedef struct ldap_tls_data_s {
134 LDAP *ld;
135 LDAPControlA **serverctrls;
136 LDAPControlA **clientctrls;
137 } ldap_tls_data_t;
138
139 int ldap_unbind_ext(LDAP *ld, LDAPControlA **sctrls, LDAPControlA **cctrls);
140 int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControlA **sctrls, LDAPControlA **cctrls);
141 char *ldap_get_dnU(LDAP *ld, LDAPMessage *entry);
142 int ldap_add_extU(LDAP *ld, char *dn, LDAPModA **attrs, LDAPControlA **sctrls, LDAPControlA **cctrls, int *msgidp);
143 int ldap_modify_extU(LDAP *ld, char *dn, LDAPModA **attrs, LDAPControlA **sctrls, LDAPControlA **cctrls, int *msgidp);
144 int ldap_delete_extU(LDAP *ld, char *dn, LDAPControlA **sctrls, LDAPControlA **cctrls, int *msgidp);
145 char *ldap_first_attributeU(LDAP *ld, LDAPMessage *entry, BerElement **ber);
146 char *ldap_next_attributeU(LDAP *ld, LDAPMessage *entry, BerElement *ber);
147 struct berval **ldap_get_values_lenU(LDAP *ld, LDAPMessage *entry, char *target);
148 int ldap_renameU(LDAP *ld, char *dn, char *newrdn, char *newSuperior, int deleteoldrdn, LDAPControlA **sctrls, LDAPControlA **cctrls, int *msgidp);
149 int ldap_search_extU(LDAP *ld, char *base, int scope, char *filter, char **attrs, int attrsonly, LDAPControlA **sctrls, LDAPControlA **cctrls, struct timeval *timeout, int sizelimit, int *msgidp);
150 int ldap_extended_operationU(LDAP *ld, char *reqoid, struct berval *reqdata, LDAPControlA **sctrls, LDAPControlA **cctrls, int *msgidp);
151 int ldap_parse_extended_resultU(LDAP *ld, LDAPMessage *res, char **retoidp, struct berval **retdatap, int freeit);
152 int ldap_parse_pageresponse_controlU(LDAP *ld, LDAPControlA **ctrls, ber_int_t *count, struct berval **cookie);
153 int ldap_control_createU(char *requestOID, int iscritical, struct berval *value, int dupval, LDAPControlA **ctrlp);
154 LDAPControlA **ldap_control_findU(char *oid, LDAPControlA **ctrls, LDAPControlA ***nextctrlp);
155 int ldap_parse_sortresponse_controlU(LDAP *ld, LDAPControlA **ctrls, ber_int_t *result, char **attribute);
156 int ldap_create_vlv_controlU(LDAP *ld, LDAPVLVInfo *vlvinfo, LDAPControlA **ctrl);
157 int ldap_parse_vlvresponse_controlU(LDAP *ld, LDAPControlA **ctrls, long int *target_posp, long int *list_countp, struct berval **contextp, int *errcodep);
158 int ldap_parse_referenceU(LDAP *ld, LDAPMessage *reference, char ***referralsp, LDAPControlA ***serverctrlsp, int freeit);
159 int ldap_create_passwordpolicy_controlU(LDAP *ld, LDAPControlA **ctrlp);
160 int ldap_parse_passwordpolicy_controlU(LDAP *ld, LDAPControlA **ctrls, ber_int_t *expirep, ber_int_t *gracep, unsigned int *errorp);
161 int ldap_parse_resultU(LDAP *ld, LDAPMessage *res, int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, LDAPControlA ***sctrls, int freeit);
162 char *ldap_err2stringU(int err);
163 int ldap_initializeU(LDAP **ldp, char *url);
164 int ldap_start_tlsU(LDAP *ld, LDAPControlA **serverctrls, LDAPControlA **clientctrls, HANDLE *msgidp);
165 int ldap_start_tls_sU(LDAP *ld, LDAPControlA **sctrls, LDAPControlA **cctrls);
166 int ldap_simple_bind_sU(LDAP *ld, char *who, char *passwd);
167 void ldap_controls_freeU(LDAPControlA **ctrls);
168 int ldap_sasl_sspi_bind_sU(LDAP *ld, char *dn, char *mechanism, LDAPControlA **sctrls, LDAPControlA **cctrls, void *defaults);
169 int ldap_get_optionU(LDAP *ld, int option, void *outvalue);
170 char *_ldap_get_opt_errormsgU(LDAP *ld);
171
172 #endif
173
174 #endif /* WLDAP_UTF8_H_ */