2 * test parsing functions
4 * Copyright 2008 Hans Leidekker for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 static void test_ldap_parse_sort_control( LDAP
*ld
)
32 LDAPSortKeyA
*sortkeys
[2], key
;
33 LDAPControlA
*sort
, *ctrls
[2], **server_ctrls
;
34 LDAPMessage
*res
= NULL
;
35 struct l_timeval timeout
;
37 key
.sk_attrtype
= (char *)"ou";
38 key
.sk_matchruleoid
= NULL
;
39 key
.sk_reverseorder
= FALSE
;
43 ret
= ldap_create_sort_controlA( ld
, sortkeys
, 0, &sort
);
44 ok( !ret
, "ldap_create_sort_controlA failed 0x%x\n", ret
);
50 ret
= ldap_search_ext_sA( ld
, (char *)"", LDAP_SCOPE_ONELEVEL
, (char *)"(ou=*)", NULL
, 0, ctrls
, NULL
, &timeout
, 10, &res
);
51 if (ret
== LDAP_SERVER_DOWN
)
53 skip("test server can't be reached\n");
54 ldap_control_free( sort
);
57 ok( !ret
, "ldap_search_ext_sA failed 0x%x\n", ret
);
58 ok( res
!= NULL
, "expected res != NULL\n" );
60 if (GetProcAddress(GetModuleHandle("wldap32.dll"), "ber_init"))
62 ret
= ldap_parse_resultA( NULL
, res
, &result
, NULL
, NULL
, NULL
, &server_ctrls
, 1 );
63 ok( ret
== LDAP_PARAM_ERROR
, "ldap_parse_resultA failed 0x%x\n", ret
);
66 win_skip("Test would crash on older wldap32 versions\n");
69 ret
= ldap_parse_resultA( ld
, res
, &result
, NULL
, NULL
, NULL
, &server_ctrls
, 1 );
70 ok( !ret
, "ldap_parse_resultA failed 0x%x\n", ret
);
71 ok( !result
, "got 0x%x expected 0\n", result
);
73 ret
= ldap_parse_sort_controlA( NULL
, NULL
, NULL
, NULL
);
74 ok( ret
== LDAP_PARAM_ERROR
, "ldap_parse_sort_controlA failed 0x%d\n", ret
);
76 ret
= ldap_parse_sort_controlA( ld
, NULL
, NULL
, NULL
);
77 ok( ret
== LDAP_CONTROL_NOT_FOUND
, "ldap_parse_sort_controlA failed 0x%x\n", ret
);
79 ret
= ldap_parse_sort_controlA( ld
, NULL
, &result
, NULL
);
80 ok( ret
== LDAP_CONTROL_NOT_FOUND
, "ldap_parse_sort_controlA failed 0x%x\n", ret
);
82 ret
= ldap_parse_sort_controlA( ld
, server_ctrls
, &result
, NULL
);
83 ok( ret
== LDAP_CONTROL_NOT_FOUND
, "ldap_parse_sort_controlA failed 0x%x\n", ret
);
85 ldap_control_free( sort
);
86 ldap_controls_free( server_ctrls
);
89 static void test_ldap_search_extW( LDAP
*ld
)
91 ULONG ret
, message
, timelimit
;
92 WCHAR base
[] = {0}, filter
[] = {'o','u','=','*',0};
95 ret
= ldap_search_extW( ld
, base
, LDAP_SCOPE_SUBTREE
, filter
, NULL
, 0, NULL
, NULL
, timelimit
, 0, &message
);
96 if (ret
== LDAP_SERVER_DOWN
|| ret
== LDAP_UNAVAILABLE
)
98 skip("test server can't be reached\n");
101 ok( !ret
, "ldap_search_extW failed 0x%08x\n", ret
);
104 ret
= ldap_search_extW( ld
, base
, LDAP_SCOPE_SUBTREE
, filter
, NULL
, 0, NULL
, NULL
, timelimit
, 0, &message
);
105 ok( !ret
, "ldap_search_extW failed 0x%08x\n", ret
);
108 static void test_ldap_set_optionW( LDAP
*ld
)
112 ret
= ldap_get_optionW( ld
, LDAP_OPT_REFERRALS
, &oldvalue
);
113 if (ret
== LDAP_SERVER_DOWN
|| ret
== LDAP_UNAVAILABLE
)
115 skip("test server can't be reached\n");
119 ret
= ldap_set_optionW( ld
, LDAP_OPT_REFERRALS
, LDAP_OPT_OFF
);
120 ok( !ret
|| broken(ret
== LDAP_PARAM_ERROR
) /* nt4, win2k */, "ldap_set_optionW failed 0x%08x\n", ret
);
122 ret
= ldap_set_optionW( ld
, LDAP_OPT_REFERRALS
, (void *)&oldvalue
);
123 ok( !ret
, "ldap_set_optionW failed 0x%08x\n", ret
);
130 ld
= ldap_initA((char *)"ldap.itd.umich.edu", 389 );
131 ok( ld
!= NULL
, "ldap_init failed\n" );
133 test_ldap_parse_sort_control( ld
);
134 test_ldap_search_extW( ld
);
135 test_ldap_set_optionW( ld
);