26 #ifndef WCE_LDAP_HELP_H
27 #define WCE_LDAP_HELP_H
28 ULONG map_error(
int );
34 static inline char *strdupU(
const char *src )
38 if (!src)
return NULL;
39 dst = (
char * )malloc( (strlen( src ) + 1) *
sizeof(char) );
45 static inline LPWSTR strAtoW( LPCSTR str )
50 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
51 if ((ret = ( WCHAR* )malloc( len *
sizeof(WCHAR) )))
52 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
57 static inline LPSTR strWtoA( LPCWSTR str )
62 DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
63 if ((ret = (
char* )malloc( len )))
64 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
69 static inline char *strWtoU( LPCWSTR str )
74 DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
75 if ((ret = (
char * )malloc( len )))
76 WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
81 static inline LPWSTR strUtoW(
char *str )
86 DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
87 if ((ret = ( WCHAR* )malloc( len *
sizeof(WCHAR) )))
88 MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
93 static inline DWORD strarraylenA( LPSTR *strarray )
100 static inline DWORD strarraylenW( LPWSTR *strarray )
102 LPWSTR *p = strarray;
107 static inline DWORD strarraylenU(
char **strarray )
114 static inline LPWSTR *strarrayAtoW( LPSTR *strarray )
116 LPWSTR *strarrayW = NULL;
121 size =
sizeof(WCHAR*) * (strarraylenA( strarray ) + 1);
122 strarrayW = ( WCHAR** )malloc( size );
127 LPWSTR *q = strarrayW;
129 while (*p) *q++ = strAtoW( *p++ );
136 static inline LPSTR *strarrayWtoA( LPWSTR *strarray )
138 LPSTR *strarrayA = NULL;
143 size =
sizeof(LPSTR) * (strarraylenW( strarray ) + 1);
144 strarrayA = (
char** )malloc( size );
148 LPWSTR *p = strarray;
149 LPSTR *q = strarrayA;
151 while (*p) *q++ = strWtoA( *p++ );
158 static inline char **strarrayWtoU( LPWSTR *strarray )
160 char **strarrayU = NULL;
165 size =
sizeof(
char*) * (strarraylenW( strarray ) + 1);
166 strarrayU = (
char** )malloc( size );
170 LPWSTR *p = strarray;
171 char **q = strarrayU;
173 while (*p) *q++ = strWtoU( *p++ );
180 static inline LPWSTR *strarrayUtoW(
char **strarray )
182 LPWSTR *strarrayW = NULL;
187 size =
sizeof(WCHAR*) * (strarraylenU( strarray ) + 1);
188 strarrayW = ( WCHAR ** )malloc( size );
193 LPWSTR *q = strarrayW;
195 while (*p) *q++ = strUtoW( *p++ );
202 static inline void strarrayfreeA( LPSTR *strarray )
207 while (*p) free( *p++ );
212 static inline void strarrayfreeW( LPWSTR *strarray )
216 LPWSTR *p = strarray;
217 while (*p) free( *p++ );
222 static inline void strarrayfreeU(
char **strarray )
227 while (*p) free( *p++ );
232 static inline struct berval *bvdup(
struct berval *bv )
234 struct berval *berval;
235 DWORD size =
sizeof(
struct berval) + bv->bv_len;
237 berval = (
struct berval * )malloc( size );
240 char *val = (
char *)berval +
sizeof(
struct berval);
242 berval->bv_len = bv->bv_len;
243 berval->bv_val = val;
244 memcpy( val, bv->bv_val, bv->bv_len );
249 static inline DWORD bvarraylen(
struct berval **bv )
251 struct berval **p = bv;
256 static inline struct berval **bvarraydup(
struct berval **bv )
258 struct berval **berval = NULL;
263 size =
sizeof(
struct berval *) * (bvarraylen( bv ) + 1);
264 berval = (
struct berval ** )malloc( size );
268 struct berval **p = bv;
269 struct berval **q = berval;
271 while (*p) *q++ = bvdup( *p++ );
278 static inline void bvarrayfree(
struct berval **bv )
280 struct berval **p = bv;
281 while (*p) free( *p++ );
285 static inline LDAPModW *modAtoW( LDAPModA *mod )
289 modW = ( LDAPModW *)malloc(
sizeof(LDAPModW) );
292 modW->mod_op = mod->mod_op;
293 modW->mod_type = strAtoW( mod->mod_type );
295 if (mod->mod_op & LDAP_MOD_BVALUES)
296 modW->mod_vals.modv_bvals = bvarraydup( mod->mod_vals.modv_bvals );
298 modW->mod_vals.modv_strvals = strarrayAtoW( mod->mod_vals.modv_strvals );
303 static inline LDAPMod *modWtoU( LDAPModW *mod )
307 modU = ( LDAPMod * )malloc(
sizeof(LDAPMod) );
310 modU->mod_op = mod->mod_op;
311 modU->mod_type = strWtoU( mod->mod_type );
313 if (mod->mod_op & LDAP_MOD_BVALUES)
314 modU->mod_vals.modv_bvals = bvarraydup( mod->mod_vals.modv_bvals );
316 modU->mod_vals.modv_strvals = strarrayWtoU( mod->mod_vals.modv_strvals );
321 static inline void modfreeW( LDAPModW *mod )
323 if (mod->mod_op & LDAP_MOD_BVALUES)
324 bvarrayfree( mod->mod_vals.modv_bvals );
326 strarrayfreeW( mod->mod_vals.modv_strvals );
330 static inline void modfreeU( LDAPMod *mod )
332 if (mod->mod_op & LDAP_MOD_BVALUES)
333 bvarrayfree( mod->mod_vals.modv_bvals );
335 strarrayfreeU( mod->mod_vals.modv_strvals );
339 static inline DWORD modarraylenA( LDAPModA **modarray )
341 LDAPModA **p = modarray;
346 static inline DWORD modarraylenW( LDAPModW **modarray )
348 LDAPModW **p = modarray;
353 static inline LDAPModW **modarrayAtoW( LDAPModA **modarray )
355 LDAPModW **modarrayW = NULL;
360 size =
sizeof(LDAPModW*) * (modarraylenA( modarray ) + 1);
361 modarrayW = ( LDAPModW**)malloc( size );
365 LDAPModA **p = modarray;
366 LDAPModW **q = modarrayW;
368 while (*p) *q++ = modAtoW( *p++ );
375 static inline LDAPMod **modarrayWtoU( LDAPModW **modarray )
377 LDAPMod **modarrayU = NULL;
382 size =
sizeof(LDAPMod*) * (modarraylenW( modarray ) + 1);
383 modarrayU = ( LDAPMod** )malloc( size );
387 LDAPModW **p = modarray;
388 LDAPMod **q = modarrayU;
390 while (*p) *q++ = modWtoU( *p++ );
397 static inline void modarrayfreeW( LDAPModW **modarray )
401 LDAPModW **p = modarray;
402 while (*p) modfreeW( *p++ );
407 static inline void modarrayfreeU( LDAPMod **modarray )
411 LDAPMod **p = modarray;
412 while (*p) modfreeU( *p++ );
417 static inline LDAPControlW *controlAtoW( LDAPControlA *control )
419 LDAPControlW *controlW;
420 DWORD len = control->ldctl_value.bv_len;
423 if (control->ldctl_value.bv_val)
425 val = (
char* )malloc( len );
426 if (!val)
return NULL;
427 memcpy( val, control->ldctl_value.bv_val, len );
430 controlW = ( LDAPControlW* )malloc(
sizeof(LDAPControlW) );
437 controlW->ldctl_oid = strAtoW( control->ldctl_oid );
438 controlW->ldctl_value.bv_len = len;
439 controlW->ldctl_value.bv_val = val;
440 controlW->ldctl_iscritical = control->ldctl_iscritical;
445 static inline LDAPControlA *controlWtoA( LDAPControlW *control )
447 LDAPControlA *controlA;
448 DWORD len = control->ldctl_value.bv_len;
451 if (control->ldctl_value.bv_val)
453 val = (
char* )malloc( len );
454 if (!val)
return NULL;
455 memcpy( val, control->ldctl_value.bv_val, len );
458 controlA = ( LDAPControlA* )malloc(
sizeof(LDAPControlA) );
465 controlA->ldctl_oid = strWtoA( control->ldctl_oid );
466 controlA->ldctl_value.bv_len = len;
467 controlA->ldctl_value.bv_val = val;
468 controlA->ldctl_iscritical = control->ldctl_iscritical;
473 static inline LDAPControl *controlWtoU( LDAPControlW *control )
475 LDAPControl *controlU;
476 DWORD len = control->ldctl_value.bv_len;
479 if (control->ldctl_value.bv_val)
481 val = (
char * )malloc( len );
482 if (!val)
return NULL;
483 memcpy( val, control->ldctl_value.bv_val, len );
486 controlU = ( LDAPControl* )malloc(
sizeof(LDAPControl) );
493 controlU->ldctl_oid = strWtoU( control->ldctl_oid );
494 controlU->ldctl_value.bv_len = len;
495 controlU->ldctl_value.bv_val = val;
496 controlU->ldctl_iscritical = control->ldctl_iscritical;
501 static inline LDAPControlW *controlUtoW( LDAPControl *control )
503 LDAPControlW *controlW;
504 DWORD len = control->ldctl_value.bv_len;
507 if (control->ldctl_value.bv_val)
509 val = (
char* )malloc( len );
510 if (!val)
return NULL;
511 memcpy( val, control->ldctl_value.bv_val, len );
514 controlW = ( LDAPControlW* )malloc(
sizeof(LDAPControlW) );
521 controlW->ldctl_oid = strUtoW( control->ldctl_oid );
522 controlW->ldctl_value.bv_len = len;
523 controlW->ldctl_value.bv_val = val;
524 controlW->ldctl_iscritical = control->ldctl_iscritical;
529 static inline void controlfreeA( LDAPControlA *control )
533 free( control->ldctl_oid );
534 free( control->ldctl_value.bv_val );
539 static inline void controlfreeW( LDAPControlW *control )
543 free( control->ldctl_oid );
544 free( control->ldctl_value.bv_val );
549 static inline void controlfreeU( LDAPControl *control )
553 free( control->ldctl_oid );
554 free( control->ldctl_value.bv_val );
559 static inline DWORD controlarraylenA( LDAPControlA **controlarray )
561 LDAPControlA **p = controlarray;
563 return p - controlarray;
566 static inline DWORD controlarraylenW( LDAPControlW **controlarray )
568 LDAPControlW **p = controlarray;
570 return p - controlarray;
573 static inline DWORD controlarraylenU( LDAPControl **controlarray )
575 LDAPControl **p = controlarray;
577 return p - controlarray;
580 static inline LDAPControlW **controlarrayAtoW( LDAPControlA **controlarray )
582 LDAPControlW **controlarrayW = NULL;
587 size =
sizeof(LDAPControlW*) * (controlarraylenA( controlarray ) + 1);
588 controlarrayW = ( LDAPControlW ** )malloc( size );
592 LDAPControlA **p = controlarray;
593 LDAPControlW **q = controlarrayW;
595 while (*p) *q++ = controlAtoW( *p++ );
599 return controlarrayW;
602 static inline LDAPControlA **controlarrayWtoA( LDAPControlW **controlarray )
604 LDAPControlA **controlarrayA = NULL;
609 size =
sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
610 controlarrayA = ( LDAPControlA** )malloc( size );
614 LDAPControlW **p = controlarray;
615 LDAPControlA **q = controlarrayA;
617 while (*p) *q++ = controlWtoA( *p++ );
621 return controlarrayA;
624 static inline LDAPControl **controlarrayWtoU( LDAPControlW **controlarray )
626 LDAPControl **controlarrayU = NULL;
631 size =
sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
632 controlarrayU = ( LDAPControl ** )malloc( size );
636 LDAPControlW **p = controlarray;
637 LDAPControl **q = controlarrayU;
639 while (*p) *q++ = controlWtoU( *p++ );
643 return controlarrayU;
646 static inline LDAPControlW **controlarrayUtoW( LDAPControl **controlarray )
648 LDAPControlW **controlarrayW = NULL;
653 size =
sizeof(LDAPControlW*) * (controlarraylenU( controlarray ) + 1);
654 controlarrayW = (LDAPControlW** )malloc( size );
658 LDAPControl **p = controlarray;
659 LDAPControlW **q = controlarrayW;
661 while (*p) *q++ = controlUtoW( *p++ );
665 return controlarrayW;
668 static inline void controlarrayfreeA( LDAPControlA **controlarray )
672 LDAPControlA **p = controlarray;
673 while (*p) controlfreeA( *p++ );
674 free( controlarray );
678 static inline void controlarrayfreeW( LDAPControlW **controlarray )
682 LDAPControlW **p = controlarray;
683 while (*p) controlfreeW( *p++ );
684 free( controlarray );
688 static inline void controlarrayfreeU( LDAPControl **controlarray )
692 LDAPControl **p = controlarray;
693 while (*p) controlfreeU( *p++ );
694 free( controlarray );
698 #ifdef _WIN32_WCE //krazy:exclude=cpp allow as this is a non-Qt source file
699 static inline ULONG my_win_ldap_compare_ext_sA( LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value,
700 struct berval *data, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
702 ULONG ret = LDAP_NOT_SUPPORTED;
703 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
704 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
706 ret = LDAP_NO_MEMORY;
708 if (!ld)
return LDAP_PARAM_ERROR;
715 attrW = strAtoW( attr );
716 if (!attrW)
goto exit;
719 valueW = strAtoW( value );
720 if (!valueW)
goto exit;
723 serverctrlsW = controlarrayAtoW( serverctrls );
724 if (!serverctrlsW)
goto exit;
727 clientctrlsW = controlarrayAtoW( clientctrls );
728 if (!clientctrlsW)
goto exit;
731 ret = ldap_compare_ext_sW( ld, dnW, attrW, valueW, data, serverctrlsW,
738 controlarrayfreeW( serverctrlsW );
739 controlarrayfreeW( clientctrlsW );
744 static inline ULONG my_win_ldap_compare_extA( LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value,
745 struct berval *data, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls,
748 ULONG ret = LDAP_NOT_SUPPORTED;
749 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
750 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
752 ret = LDAP_NO_MEMORY;
754 if (!ld || !message)
return LDAP_PARAM_ERROR;
761 attrW = strAtoW( attr );
762 if (!attrW)
goto exit;
765 valueW = strAtoW( value );
766 if (!valueW)
goto exit;
769 serverctrlsW = controlarrayAtoW( serverctrls );
770 if (!serverctrlsW)
goto exit;
773 clientctrlsW = controlarrayAtoW( clientctrls );
774 if (!clientctrlsW)
goto exit;
777 ret = ldap_compare_extW( ld, dnW, attrW, valueW, data,
778 serverctrlsW, clientctrlsW, message );
784 controlarrayfreeW( serverctrlsW );
785 controlarrayfreeW( clientctrlsW );
790 static inline ULONG my_win_ldap_modify_ext_sA( LDAP *ld, PCHAR dn, LDAPModA *mods[],
791 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
793 ULONG ret = LDAP_NOT_SUPPORTED;
795 LDAPModW **modsW = NULL;
796 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
798 ret = LDAP_NO_MEMORY;
800 if (!ld)
return LDAP_PARAM_ERROR;
807 modsW = modarrayAtoW( mods );
808 if (!modsW)
goto exit;
811 serverctrlsW = controlarrayAtoW( serverctrls );
812 if (!serverctrlsW)
goto exit;
815 clientctrlsW = controlarrayAtoW( clientctrls );
816 if (!clientctrlsW)
goto exit;
819 ret = ldap_modify_ext_sW( ld, dnW, modsW, serverctrlsW, clientctrlsW );
823 modarrayfreeW( modsW );
824 controlarrayfreeW( serverctrlsW );
825 controlarrayfreeW( clientctrlsW );
830 static inline ULONG my_win_ldap_add_ext_sA( LDAP *ld, PCHAR dn, LDAPModA *attrs[],
831 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
833 ULONG ret = LDAP_NOT_SUPPORTED;
835 LDAPModW **attrsW = NULL;
836 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
838 ret = LDAP_NO_MEMORY;
840 if (!ld)
return LDAP_PARAM_ERROR;
847 attrsW = modarrayAtoW( attrs );
848 if (!attrsW)
goto exit;
851 serverctrlsW = controlarrayAtoW( serverctrls );
852 if (!serverctrlsW)
goto exit;
855 clientctrlsW = controlarrayAtoW( clientctrls );
856 if (!clientctrlsW)
goto exit;
859 ret = ldap_add_ext_sW( ld, dnW, attrsW, serverctrlsW, clientctrlsW );
863 modarrayfreeW( attrsW );
864 controlarrayfreeW( serverctrlsW );
865 controlarrayfreeW( clientctrlsW );
870 static inline ULONG my_win_ldap_add_extA( LDAP *ld, PCHAR dn, LDAPModA *attrs[],
871 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
873 ULONG ret = LDAP_NOT_SUPPORTED;
875 LDAPModW **attrsW = NULL;
876 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
878 ret = LDAP_NO_MEMORY;
880 if (!ld)
return LDAP_PARAM_ERROR;
887 attrsW = modarrayAtoW( attrs );
888 if (!attrsW)
goto exit;
891 serverctrlsW = controlarrayAtoW( serverctrls );
892 if (!serverctrlsW)
goto exit;
895 clientctrlsW = controlarrayAtoW( clientctrls );
896 if (!clientctrlsW)
goto exit;
899 ret = ldap_add_extW( ld, dnW, attrsW, serverctrlsW, clientctrlsW, message );
903 modarrayfreeW( attrsW );
904 controlarrayfreeW( serverctrlsW );
905 controlarrayfreeW( clientctrlsW );
910 static void my_win_ldap_mods_freeA(LDAPMod **mods,
int freemods)
912 modarrayfreeU( mods );
918 static inline ULONG my_win_ldap_parse_resultA( LDAP *ld, LDAPMessage *result,
919 ULONG *retcode, PCHAR *matched, PCHAR *error, PCHAR **referrals,
920 PLDAPControlA **serverctrls, BOOLEAN free )
922 ULONG ret = LDAP_NOT_SUPPORTED;
923 WCHAR *matchedW = NULL, *errorW = NULL, **referralsW = NULL;
924 LDAPControlW **serverctrlsW = NULL;
926 if (!ld)
return LDAP_PARAM_ERROR;
928 ret = ldap_parse_resultW( ld, result, retcode, &matchedW, &errorW,
929 &referralsW, &serverctrlsW, free );
931 if (matched) *matched = strWtoA( matchedW );
932 if (error) *error = strWtoA( errorW );
934 if (referrals) *referrals = strarrayWtoA( referralsW );
935 if (serverctrls) *serverctrls = controlarrayWtoA( serverctrlsW );
937 ldap_memfreeW( matchedW );
938 ldap_memfreeW( errorW );
939 ldap_value_freeW( referralsW );
940 ldap_controls_freeW( serverctrlsW );
945 static inline ULONG my_win_ldap_controls_freeA( LDAPControlA **controls )
947 ULONG ret = LDAP_SUCCESS;
949 controlarrayfreeA( controls );
954 static inline ULONG my_win_ldap_sasl_bind_sA( LDAP *ld,
const PCHAR dn,
955 const PCHAR mechanism,
const BERVAL *cred, PLDAPControlA *serverctrls,
956 PLDAPControlA *clientctrls, PBERVAL *serverdata )
958 ULONG ret = LDAP_NOT_SUPPORTED;
959 WCHAR *dnW, *mechanismW = NULL;
960 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
962 ret = LDAP_NO_MEMORY;
964 if (!ld || !dn || !mechanism || !cred || !serverdata)
965 return LDAP_PARAM_ERROR;
970 mechanismW = strAtoW( mechanism );
971 if (!mechanismW)
goto exit;
974 serverctrlsW = controlarrayAtoW( serverctrls );
975 if (!serverctrlsW)
goto exit;
978 clientctrlsW = controlarrayAtoW( clientctrls );
979 if (!clientctrlsW)
goto exit;
982 ret = ldap_sasl_bind_sW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, serverdata );
987 controlarrayfreeW( serverctrlsW );
988 controlarrayfreeW( clientctrlsW );
993 static inline ULONG my_win_ldap_sasl_bindA( LDAP *ld,
const PCHAR dn,
994 const PCHAR mechanism,
const BERVAL *cred, PLDAPControlA *serverctrls,
995 PLDAPControlA *clientctrls,
int *message )
997 ULONG ret = LDAP_NOT_SUPPORTED;
999 WCHAR *dnW, *mechanismW = NULL;
1000 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
1002 ret = LDAP_NO_MEMORY;
1004 if (!ld || !dn || !mechanism || !cred || !message)
1005 return LDAP_PARAM_ERROR;
1007 dnW = strAtoW( dn );
1008 if (!dnW)
goto exit;
1010 mechanismW = strAtoW( mechanism );
1011 if (!mechanismW)
goto exit;
1014 serverctrlsW = controlarrayAtoW( serverctrls );
1015 if (!serverctrlsW)
goto exit;
1018 clientctrlsW = controlarrayAtoW( clientctrls );
1019 if (!clientctrlsW)
goto exit;
1022 ret = ldap_sasl_bindW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, message );
1027 controlarrayfreeW( serverctrlsW );
1028 controlarrayfreeW( clientctrlsW );
1033 static inline PCHAR my_win_ldap_get_dnA( LDAP *ld, LDAPMessage *entry )
1038 if (!ld || !entry)
return NULL;
1040 retW = ldap_get_dnW( ld, entry );
1042 ret = strWtoA( retW );
1043 ldap_memfreeW( retW );
1048 static inline ULONG my_win_ldap_parse_extended_resultA( LDAP *ld,
1049 LDAPMessage *result,
1050 PCHAR *oid,
struct berval **data, BOOLEAN free )
1052 ULONG ret = LDAP_NOT_SUPPORTED;
1055 if (!ld)
return LDAP_PARAM_ERROR;
1056 if (!result)
return LDAP_NO_RESULTS_RETURNED;
1058 ret = ldap_parse_extended_resultW( ld, result, &oidW, data, free );
1061 *oid = strWtoA( oidW );
1062 if (!*oid) ret = LDAP_NO_MEMORY;
1063 ldap_memfreeW( oidW );
1069 static inline LDAP *
1070 my_win_ldap_initA (
const char *host,
unsigned short port)
1073 wchar_t *whost = NULL;
1077 whost = strAtoW (host);
1081 ld = ldap_initW (whost, port);
1087 my_win_ldap_simple_bind_sA (LDAP *ld,
const char *user,
const char *pass)
1090 wchar_t *wuser, *wpass;
1092 wuser = user? strAtoW (user) : NULL;
1093 wpass = pass? strAtoW (pass) : NULL;
1096 ret = ldap_simple_bind_sW (ld, wuser, wpass);
1102 static inline ULONG my_win_ldap_search_extA( LDAP *ld, PCHAR base, ULONG scope,
1103 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
1104 PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit,
int *message )
1106 ULONG ret = LDAP_NOT_SUPPORTED;
1107 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
1108 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
1110 ret = LDAP_NO_MEMORY;
1112 if (!ld)
return LDAP_PARAM_ERROR;
1115 baseW = strAtoW( base );
1116 if (!baseW)
goto exit;
1120 filterW = strAtoW( filter );
1121 if (!filterW)
goto exit;
1124 attrsW = strarrayAtoW( attrs );
1125 if (!attrsW)
goto exit;
1128 serverctrlsW = controlarrayAtoW( serverctrls );
1129 if (!serverctrlsW)
goto exit;
1132 clientctrlsW = controlarrayAtoW( clientctrls );
1133 if (!clientctrlsW)
goto exit;
1136 ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly,
1137 serverctrlsW, clientctrlsW, timelimit, sizelimit, ( ULONG* )message );
1142 strarrayfreeW( attrsW );
1143 controlarrayfreeW( serverctrlsW );
1144 controlarrayfreeW( clientctrlsW );
1149 static inline ULONG my_win_ldap_search_stA( LDAP *ld,
const PCHAR base, ULONG scope,
1150 const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
1151 struct l_timeval *timeout, LDAPMessage **res )
1153 ULONG ret = LDAP_NOT_SUPPORTED;
1154 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
1156 ret = LDAP_NO_MEMORY;
1158 if (!ld || !res)
return LDAP_PARAM_ERROR;
1161 baseW = strAtoW( base );
1162 if (!baseW)
goto exit;
1165 filterW = strAtoW( filter );
1166 if (!filterW)
goto exit;
1169 attrsW = strarrayAtoW( attrs );
1170 if (!attrsW)
goto exit;
1173 ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
1179 strarrayfreeW( attrsW );
1184 static inline char *
1185 my_win_ldap_first_attributeA (LDAP *ld, LDAPMessage *msg, BerElement **elem)
1190 wattr = ldap_first_attributeW (ld, msg, elem);
1193 attr = strWtoA (wattr);
1194 ldap_memfreeW (wattr);
1199 static inline char *
1200 my_win_ldap_next_attributeA (LDAP *ld, LDAPMessage *msg, BerElement *elem)
1205 wattr = ldap_next_attributeW (ld, msg, elem);
1208 attr = strWtoA (wattr);
1209 ldap_memfreeW (wattr);
1213 static inline BerValue **
1214 my_win_ldap_get_values_lenA (LDAP *ld, LDAPMessage *msg,
const char *attr)
1221 wattr = strAtoW (attr);
1228 ret = ldap_get_values_lenW (ld, msg, wattr);
1234 #endif // WCE_LDAP_HELP_H