2 Unix SMB/CIFS implementation.
4 Copyright (C) Guenther Deschner 2009-2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "lib/replace/replace.h"
21 #include "libcli/util/ntstatus.h"
22 #include "libcli/util/werror.h"
23 #include "lib/util/data_blob.h"
24 #include "lib/util/time.h"
25 #include "nsswitch/libwbclient/wbclient.h"
26 #include "torture/smbtorture.h"
27 #include "torture/winbind/proto.h"
28 #include "lib/util/util_net.h"
29 #include "lib/util/charset/charset.h"
30 #include "libcli/auth/libcli_auth.h"
31 #include "lib/param/param.h"
32 #include "lib/util/samba_util.h"
33 #include "lib/crypto/arcfour.h"
35 #define WBC_ERROR_EQUAL(x,y) (x == y)
37 #define torture_assert_wbc_equal(torture_ctx, got, expected, cmt, cmt_arg) \
38 do { wbcErr __got = got, __expected = expected; \
39 if (!WBC_ERROR_EQUAL(__got, __expected)) { \
40 torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: " cmt, wbcErrorString(__got), wbcErrorString(__expected), cmt_arg); \
45 #define torture_assert_wbc_ok(torture_ctx,expr,cmt,cmt_arg) \
46 torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt,cmt_arg)
48 static bool test_wbc_ping(struct torture_context
*tctx
)
50 torture_assert_wbc_ok(tctx
, wbcPing(),
51 "%s", "wbcPing failed");
56 static bool test_wbc_pingdc(struct torture_context
*tctx
)
58 torture_assert_wbc_equal(tctx
, wbcPingDc("random_string", NULL
), WBC_ERR_NOT_IMPLEMENTED
,
59 "%s", "wbcPingDc failed");
60 torture_assert_wbc_ok(tctx
, wbcPingDc(NULL
, NULL
),
61 "%s", "wbcPingDc failed");
66 static bool test_wbc_pingdc2(struct torture_context
*tctx
)
70 torture_assert_wbc_equal(tctx
, wbcPingDc2("random_string", NULL
, &name
),
71 WBC_ERR_NOT_IMPLEMENTED
, "%s",
73 torture_assert_wbc_ok(tctx
, wbcPingDc2(NULL
, NULL
, &name
), "%s",
79 static bool test_wbc_library_details(struct torture_context
*tctx
)
81 struct wbcLibraryDetails
*details
;
83 torture_assert_wbc_ok(tctx
, wbcLibraryDetails(&details
),
84 "%s", "wbcLibraryDetails failed");
85 torture_assert(tctx
, details
,
86 "wbcLibraryDetails returned NULL pointer");
88 wbcFreeMemory(details
);
93 static bool test_wbc_interface_details(struct torture_context
*tctx
)
95 struct wbcInterfaceDetails
*details
;
97 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
98 "%s", "wbcInterfaceDetails failed");
99 torture_assert(tctx
, details
,
100 "wbcInterfaceDetails returned NULL pointer");
102 wbcFreeMemory(details
);
107 static bool test_wbc_sidtypestring(struct torture_context
*tctx
)
109 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_USE_NONE
),
110 "SID_NONE", "SID_NONE failed");
111 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_USER
),
112 "SID_USER", "SID_USER failed");
113 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_DOM_GRP
),
114 "SID_DOM_GROUP", "SID_DOM_GROUP failed");
115 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_DOMAIN
),
116 "SID_DOMAIN", "SID_DOMAIN failed");
117 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_ALIAS
),
118 "SID_ALIAS", "SID_ALIAS failed");
119 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_WKN_GRP
),
120 "SID_WKN_GROUP", "SID_WKN_GROUP failed");
121 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_DELETED
),
122 "SID_DELETED", "SID_DELETED failed");
123 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_INVALID
),
124 "SID_INVALID", "SID_INVALID failed");
125 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_UNKNOWN
),
126 "SID_UNKNOWN", "SID_UNKNOWN failed");
127 torture_assert_str_equal(tctx
, wbcSidTypeString(WBC_SID_NAME_COMPUTER
),
128 "SID_COMPUTER", "SID_COMPUTER failed");
132 static bool test_wbc_sidtostring(struct torture_context
*tctx
)
134 struct wbcDomainSid sid
;
135 const char *sid_string
= "S-1-5-32";
138 torture_assert_wbc_ok(tctx
, wbcStringToSid(sid_string
, &sid
),
139 "wbcStringToSid of %s failed", sid_string
);
140 torture_assert_wbc_ok(tctx
, wbcSidToString(&sid
, &sid_string2
),
141 "wbcSidToString of %s failed", sid_string
);
142 torture_assert_str_equal(tctx
, sid_string
, sid_string2
,
143 "sid strings differ");
144 wbcFreeMemory(sid_string2
);
149 static bool test_wbc_guidtostring(struct torture_context
*tctx
)
152 const char *guid_string
= "f7cf07b4-1487-45c7-824d-8b18cc580811";
155 torture_assert_wbc_ok(tctx
, wbcStringToGuid(guid_string
, &guid
),
156 "wbcStringToGuid of %s failed", guid_string
);
157 torture_assert_wbc_ok(tctx
, wbcGuidToString(&guid
, &guid_string2
),
158 "wbcGuidToString of %s failed", guid_string
);
159 torture_assert_str_equal(tctx
, guid_string
, guid_string2
,
160 "guid strings differ");
161 wbcFreeMemory(guid_string2
);
166 static bool test_wbc_domain_info(struct torture_context
*tctx
)
168 struct wbcDomainInfo
*info
;
169 struct wbcInterfaceDetails
*details
;
171 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
172 "%s", "wbcInterfaceDetails failed");
173 torture_assert_wbc_ok(
174 tctx
, wbcDomainInfo(details
->netbios_domain
, &info
),
175 "%s", "wbcDomainInfo failed");
176 wbcFreeMemory(details
);
178 torture_assert(tctx
, info
,
179 "wbcDomainInfo returned NULL pointer");
185 static bool test_wbc_users(struct torture_context
*tctx
)
187 const char *domain_name
= NULL
;
191 struct wbcInterfaceDetails
*details
;
193 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
194 "%s", "wbcInterfaceDetails failed");
196 domain_name
= talloc_strdup(tctx
, details
->netbios_domain
);
197 wbcFreeMemory(details
);
199 torture_assert_wbc_ok(tctx
, wbcListUsers(domain_name
, &num_users
, &users
),
200 "%s", "wbcListUsers failed");
201 torture_assert(tctx
, !(num_users
> 0 && !users
),
202 "wbcListUsers returned invalid results");
204 for (i
=0; i
< MIN(num_users
,100); i
++) {
206 struct wbcDomainSid sid
, *sids
;
207 enum wbcSidType name_type
;
213 torture_assert_wbc_ok(tctx
, wbcLookupName(domain_name
, users
[i
], &sid
, &name_type
),
214 "wbcLookupName of %s failed", users
[i
]);
215 torture_assert_int_equal(tctx
, name_type
, WBC_SID_NAME_USER
,
216 "wbcLookupName expected WBC_SID_NAME_USER");
217 wbcSidToString(&sid
, &sid_string
);
218 torture_assert_wbc_ok(tctx
, wbcLookupSid(&sid
, &domain
, &name
, &name_type
),
219 "wbcLookupSid of %s failed", sid_string
);
220 torture_assert_int_equal(tctx
, name_type
, WBC_SID_NAME_USER
,
221 "wbcLookupSid of expected WBC_SID_NAME_USER");
222 torture_assert(tctx
, name
,
223 "wbcLookupSid returned no name");
224 wbcFreeMemory(domain
);
226 torture_assert_wbc_ok(tctx
, wbcLookupUserSids(&sid
, true, &num_sids
, &sids
),
227 "wbcLookupUserSids of %s failed", sid_string
);
228 torture_assert_wbc_ok(
229 tctx
, wbcGetDisplayName(&sid
, &domain
, &name
,
231 "wbcGetDisplayName of %s failed", sid_string
);
232 wbcFreeMemory(domain
);
235 wbcFreeMemory(sid_string
);
237 wbcFreeMemory(users
);
242 static bool test_wbc_groups(struct torture_context
*tctx
)
244 const char *domain_name
= NULL
;
248 struct wbcInterfaceDetails
*details
;
250 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
251 "%s", "wbcInterfaceDetails failed");
253 domain_name
= talloc_strdup(tctx
, details
->netbios_domain
);
254 wbcFreeMemory(details
);
256 torture_assert_wbc_ok(tctx
, wbcListGroups(domain_name
, &num_groups
, &groups
),
257 "wbcListGroups in %s failed", domain_name
);
258 torture_assert(tctx
, !(num_groups
> 0 && !groups
),
259 "wbcListGroups returned invalid results");
261 for (i
=0; i
< MIN(num_groups
,100); i
++) {
263 struct wbcDomainSid sid
;
264 enum wbcSidType name_type
;
269 torture_assert_wbc_ok(tctx
, wbcLookupName(domain_name
, groups
[i
], &sid
, &name_type
),
270 "wbcLookupName for %s failed", domain_name
);
271 wbcSidToString(&sid
, &sid_string
);
272 torture_assert_wbc_ok(tctx
, wbcLookupSid(&sid
, &domain
, &name
, &name_type
),
273 "wbcLookupSid of %s failed", sid_string
);
274 wbcFreeMemory(sid_string
);
275 torture_assert(tctx
, name
,
276 "wbcLookupSid returned no name");
278 wbcFreeMemory(groups
);
283 static bool test_wbc_trusts(struct torture_context
*tctx
)
285 struct wbcDomainInfo
*domains
;
289 torture_assert_wbc_ok(tctx
, wbcListTrusts(&domains
, &num_domains
),
290 "%s", "wbcListTrusts failed");
291 torture_assert(tctx
, !(num_domains
> 0 && !domains
),
292 "wbcListTrusts returned invalid results");
294 for (i
=0; i
< MIN(num_domains
,100); i
++) {
296 struct wbcAuthErrorInfo
*error
;
298 struct wbcDomainSid sid;
299 enum wbcSidType name_type;
303 torture_assert_wbc_ok(tctx
, wbcCheckTrustCredentials(domains
[i
].short_name
, &error
),
304 "%s", "wbcCheckTrustCredentials failed");
306 torture_assert_wbc_ok(tctx, wbcLookupName(domains[i].short_name, NULL, &sid, &name_type),
307 "wbcLookupName failed");
308 torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_DOMAIN,
309 "wbcLookupName expected WBC_SID_NAME_DOMAIN");
310 torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
311 "wbcLookupSid failed");
312 torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_DOMAIN,
313 "wbcLookupSid expected WBC_SID_NAME_DOMAIN");
314 torture_assert(tctx, name,
315 "wbcLookupSid returned no name");
318 wbcFreeMemory(domains
);
323 static bool test_wbc_lookupdc(struct torture_context
*tctx
)
325 const char *domain_name
= NULL
;
326 struct wbcInterfaceDetails
*details
;
327 struct wbcDomainControllerInfo
*dc_info
;
329 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
330 "%s", "wbcInterfaceDetails failed");
332 domain_name
= talloc_strdup(tctx
, details
->netbios_domain
);
333 wbcFreeMemory(details
);
335 torture_assert_wbc_ok(tctx
, wbcLookupDomainController(domain_name
, 0, &dc_info
),
336 "wbcLookupDomainController for %s failed", domain_name
);
337 wbcFreeMemory(dc_info
);
342 static bool test_wbc_lookupdcex(struct torture_context
*tctx
)
344 const char *domain_name
= NULL
;
345 struct wbcInterfaceDetails
*details
;
346 struct wbcDomainControllerInfoEx
*dc_info
;
348 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
349 "%s", "wbcInterfaceDetails failed");
351 domain_name
= talloc_strdup(tctx
, details
->netbios_domain
);
352 wbcFreeMemory(details
);
354 torture_assert_wbc_ok(tctx
, wbcLookupDomainControllerEx(domain_name
, NULL
, NULL
, 0, &dc_info
),
355 "wbcLookupDomainControllerEx for %s failed", domain_name
);
356 wbcFreeMemory(dc_info
);
361 static bool test_wbc_resolve_winsbyname(struct torture_context
*tctx
)
367 name
= torture_setting_string(tctx
, "host", NULL
);
369 ret
= wbcResolveWinsByName(name
, &ip
);
371 if (is_ipaddress(name
)) {
372 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_DOMAIN_NOT_FOUND
, "wbcResolveWinsByName of %s failed", name
);
374 torture_assert_wbc_ok(tctx
, ret
, "wbcResolveWinsByName for %s failed", name
);
380 static bool test_wbc_resolve_winsbyip(struct torture_context
*tctx
)
386 ip
= torture_setting_string(tctx
, "host", NULL
);
388 ret
= wbcResolveWinsByIP(ip
, &name
);
390 torture_assert_wbc_ok(tctx
, ret
, "wbcResolveWinsByIP for %s failed", ip
);
397 static bool test_wbc_lookup_rids(struct torture_context
*tctx
)
399 struct wbcDomainSid builtin
;
400 uint32_t rids
[2] = { 544, 545 };
401 const char *domain_name
, **names
;
402 enum wbcSidType
*types
;
405 wbcStringToSid("S-1-5-32", &builtin
);
407 ret
= wbcLookupRids(&builtin
, 2, rids
, &domain_name
, &names
,
409 torture_assert_wbc_ok(tctx
, ret
, "%s", "wbcLookupRids for 544 and 545 failed");
411 torture_assert_str_equal(
412 tctx
, names
[0], "Administrators",
413 "S-1-5-32-544 not mapped to 'Administrators'");
414 torture_assert_str_equal(
415 tctx
, names
[1], "Users", "S-1-5-32-545 not mapped to 'Users'");
417 wbcFreeMemory(discard_const_p(char ,domain_name
));
418 wbcFreeMemory(names
);
419 wbcFreeMemory(types
);
424 static bool test_wbc_get_sidaliases(struct torture_context
*tctx
)
426 struct wbcDomainSid builtin
;
427 struct wbcDomainInfo
*info
;
428 struct wbcInterfaceDetails
*details
;
429 struct wbcDomainSid sids
[2];
434 torture_assert_wbc_ok(tctx
, wbcInterfaceDetails(&details
),
435 "%s", "wbcInterfaceDetails failed");
436 torture_assert_wbc_ok(
437 tctx
, wbcDomainInfo(details
->netbios_domain
, &info
),
438 "wbcDomainInfo of %s failed", details
->netbios_domain
);
439 wbcFreeMemory(details
);
442 sids
[0].sub_auths
[sids
[0].num_auths
++] = 500;
444 sids
[1].sub_auths
[sids
[1].num_auths
++] = 512;
447 torture_assert_wbc_ok(
448 tctx
, wbcStringToSid("S-1-5-32", &builtin
),
449 "wbcStringToSid of %s failed", "S-1-5-32");
451 ret
= wbcGetSidAliases(&builtin
, sids
, 2, &rids
, &num_rids
);
452 torture_assert_wbc_ok(tctx
, ret
, "%s", "wbcGetSidAliases failed");
459 static bool test_wbc_authenticate_user_int(struct torture_context
*tctx
,
460 const char *correct_password
)
462 struct wbcAuthUserParams params
;
463 struct wbcAuthUserInfo
*info
= NULL
;
464 struct wbcAuthErrorInfo
*error
= NULL
;
467 ret
= wbcAuthenticateUser(getenv("USERNAME"), correct_password
);
468 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
469 "wbcAuthenticateUser of %s failed", getenv("USERNAME"));
472 params
.account_name
= getenv("USERNAME");
473 params
.level
= WBC_AUTH_USER_LEVEL_PLAIN
;
474 params
.password
.plaintext
= correct_password
;
476 ret
= wbcAuthenticateUserEx(¶ms
, &info
, &error
);
477 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
478 "wbcAuthenticateUserEx of %s failed", params
.account_name
);
482 wbcFreeMemory(error
);
485 params
.password
.plaintext
= "wrong";
486 ret
= wbcAuthenticateUserEx(¶ms
, &info
, &error
);
487 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_AUTH_ERROR
,
488 "wbcAuthenticateUserEx for %s succeeded where it "
489 "should have failed", params
.account_name
);
493 wbcFreeMemory(error
);
499 static bool test_wbc_authenticate_user(struct torture_context
*tctx
)
501 return test_wbc_authenticate_user_int(tctx
, getenv("PASSWORD"));
504 static bool test_wbc_change_password(struct torture_context
*tctx
)
507 const char *oldpass
= getenv("PASSWORD");
508 const char *newpass
= "Koo8irei";
510 struct samr_CryptPassword new_nt_password
;
511 struct samr_CryptPassword new_lm_password
;
512 struct samr_Password old_nt_hash_enc
;
513 struct samr_Password old_lanman_hash_enc
;
515 uint8_t old_nt_hash
[16];
516 uint8_t old_lanman_hash
[16];
517 uint8_t new_nt_hash
[16];
518 uint8_t new_lanman_hash
[16];
520 struct wbcChangePasswordParams params
;
522 if (oldpass
== NULL
) {
524 "skipping wbcChangeUserPassword test as old password cannot be retrieved\n");
529 E_md4hash(oldpass
, old_nt_hash
);
530 E_md4hash(newpass
, new_nt_hash
);
532 if (lpcfg_client_lanman_auth(tctx
->lp_ctx
) &&
533 E_deshash(newpass
, new_lanman_hash
) &&
534 E_deshash(oldpass
, old_lanman_hash
)) {
536 /* E_deshash returns false for 'long' passwords (> 14
537 DOS chars). This allows us to match Win2k, which
538 does not store a LM hash for these passwords (which
539 would reduce the effective password length to 14) */
541 encode_pw_buffer(new_lm_password
.data
, newpass
, STR_UNICODE
);
542 arcfour_crypt(new_lm_password
.data
, old_nt_hash
, 516);
543 E_old_pw_hash(new_nt_hash
, old_lanman_hash
,
544 old_lanman_hash_enc
.hash
);
546 params
.old_password
.response
.old_lm_hash_enc_length
=
547 sizeof(old_lanman_hash_enc
.hash
);
548 params
.old_password
.response
.old_lm_hash_enc_data
=
549 old_lanman_hash_enc
.hash
;
550 params
.new_password
.response
.lm_length
=
551 sizeof(new_lm_password
.data
);
552 params
.new_password
.response
.lm_data
=
553 new_lm_password
.data
;
555 ZERO_STRUCT(new_lm_password
);
556 ZERO_STRUCT(old_lanman_hash_enc
);
559 encode_pw_buffer(new_nt_password
.data
, newpass
, STR_UNICODE
);
561 arcfour_crypt(new_nt_password
.data
, old_nt_hash
, 516);
562 E_old_pw_hash(new_nt_hash
, old_nt_hash
, old_nt_hash_enc
.hash
);
564 params
.old_password
.response
.old_nt_hash_enc_length
=
565 sizeof(old_nt_hash_enc
.hash
);
566 params
.old_password
.response
.old_nt_hash_enc_data
=
567 old_nt_hash_enc
.hash
;
568 params
.new_password
.response
.nt_length
= sizeof(new_nt_password
.data
);
569 params
.new_password
.response
.nt_data
= new_nt_password
.data
;
571 params
.level
= WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
;
572 params
.account_name
= getenv("USERNAME");
573 params
.domain_name
= "SAMBA-TEST";
575 ret
= wbcChangeUserPasswordEx(¶ms
, NULL
, NULL
, NULL
);
576 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
577 "wbcChangeUserPassword for %s failed", params
.account_name
);
579 if (!test_wbc_authenticate_user_int(tctx
, "Koo8irei")) {
583 ret
= wbcChangeUserPassword(getenv("USERNAME"), "Koo8irei",
585 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
586 "wbcChangeUserPassword for %s failed", params
.account_name
);
588 return test_wbc_authenticate_user_int(tctx
, getenv("PASSWORD"));
591 static bool test_wbc_logon_user(struct torture_context
*tctx
)
593 struct wbcLogonUserParams params
;
594 struct wbcLogonUserInfo
*info
= NULL
;
595 struct wbcAuthErrorInfo
*error
= NULL
;
596 struct wbcUserPasswordPolicyInfo
*policy
= NULL
;
597 struct wbcInterfaceDetails
*iface
;
598 struct wbcDomainSid sid
;
599 enum wbcSidType sidtype
;
605 ret
= wbcLogonUser(¶ms
, &info
, &error
, &policy
);
606 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_INVALID_PARAM
,
607 "%s", "wbcLogonUser succeeded for NULL where it should "
610 params
.username
= getenv("USERNAME");
611 params
.password
= getenv("PASSWORD");
613 ret
= wbcAddNamedBlob(¶ms
.num_blobs
, ¶ms
.blobs
,
614 "foo", 0, discard_const_p(uint8_t, "bar"), 4);
615 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
616 "%s", "wbcAddNamedBlob failed");
618 ret
= wbcLogonUser(¶ms
, &info
, &error
, &policy
);
619 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
620 "wbcLogonUser for %s failed", params
.username
);
621 wbcFreeMemory(info
); info
= NULL
;
622 wbcFreeMemory(error
); error
= NULL
;
623 wbcFreeMemory(policy
); policy
= NULL
;
625 params
.password
= "wrong";
627 ret
= wbcLogonUser(¶ms
, &info
, &error
, &policy
);
628 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_AUTH_ERROR
,
629 "wbcLogonUser for %s should have failed with "
630 "WBC_ERR_AUTH_ERROR", params
.username
);
631 wbcFreeMemory(info
); info
= NULL
;
632 wbcFreeMemory(error
); error
= NULL
;
633 wbcFreeMemory(policy
); policy
= NULL
;
635 ret
= wbcAddNamedBlob(¶ms
.num_blobs
, ¶ms
.blobs
,
637 discard_const_p(uint8_t, "S-1-2-3-4"),
638 strlen("S-1-2-3-4")+1);
639 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
640 "%s", "wbcAddNamedBlob failed");
641 params
.password
= getenv("PASSWORD");
642 ret
= wbcLogonUser(¶ms
, &info
, &error
, &policy
);
643 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_AUTH_ERROR
,
644 "wbcLogonUser for %s should have failed with "
645 "WBC_ERR_AUTH_ERROR", params
.username
);
646 wbcFreeMemory(info
); info
= NULL
;
647 wbcFreeMemory(error
); error
= NULL
;
648 wbcFreeMemory(policy
); policy
= NULL
;
649 wbcFreeMemory(params
.blobs
);
650 params
.blobs
= NULL
; params
.num_blobs
= 0;
652 ret
= wbcInterfaceDetails(&iface
);
653 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
654 "%s", "wbcInterfaceDetails failed");
656 ret
= wbcLookupName(iface
->netbios_domain
, getenv("USERNAME"), &sid
,
658 wbcFreeMemory(iface
);
659 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
660 "wbcLookupName for %s failed", getenv("USERNAME"));
662 ret
= wbcSidToString(&sid
, &sidstr
);
663 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
664 "%s", "wbcSidToString failed");
666 ret
= wbcAddNamedBlob(¶ms
.num_blobs
, ¶ms
.blobs
,
668 (uint8_t *)sidstr
, strlen(sidstr
)+1);
669 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
670 "%s", "wbcAddNamedBlob failed");
671 wbcFreeMemory(sidstr
);
672 params
.password
= getenv("PASSWORD");
673 ret
= wbcLogonUser(¶ms
, &info
, &error
, &policy
);
674 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
675 "wbcLogonUser for %s failed", params
.username
);
676 wbcFreeMemory(info
); info
= NULL
;
677 wbcFreeMemory(error
); error
= NULL
;
678 wbcFreeMemory(policy
); policy
= NULL
;
679 wbcFreeMemory(params
.blobs
);
680 params
.blobs
= NULL
; params
.num_blobs
= 0;
685 static bool test_wbc_getgroups(struct torture_context
*tctx
)
691 ret
= wbcGetGroups(getenv("USERNAME"), &num_groups
, &groups
);
692 torture_assert_wbc_equal(tctx
, ret
, WBC_ERR_SUCCESS
,
693 "wbcGetGroups for %s failed", getenv("USERNAME"));
694 wbcFreeMemory(groups
);
698 struct torture_suite
*torture_wbclient(void)
700 struct torture_suite
*suite
= torture_suite_create(talloc_autofree_context(), "wbclient");
702 torture_suite_add_simple_test(suite
, "wbcPing", test_wbc_ping
);
703 torture_suite_add_simple_test(suite
, "wbcPingDc", test_wbc_pingdc
);
704 torture_suite_add_simple_test(suite
, "wbcPingDc2", test_wbc_pingdc
);
705 torture_suite_add_simple_test(suite
, "wbcLibraryDetails", test_wbc_library_details
);
706 torture_suite_add_simple_test(suite
, "wbcInterfaceDetails", test_wbc_interface_details
);
707 torture_suite_add_simple_test(suite
, "wbcSidTypeString", test_wbc_sidtypestring
);
708 torture_suite_add_simple_test(suite
, "wbcSidToString", test_wbc_sidtostring
);
709 torture_suite_add_simple_test(suite
, "wbcGuidToString", test_wbc_guidtostring
);
710 torture_suite_add_simple_test(suite
, "wbcDomainInfo", test_wbc_domain_info
);
711 torture_suite_add_simple_test(suite
, "wbcListUsers", test_wbc_users
);
712 torture_suite_add_simple_test(suite
, "wbcListGroups", test_wbc_groups
);
713 torture_suite_add_simple_test(suite
, "wbcListTrusts", test_wbc_trusts
);
714 torture_suite_add_simple_test(suite
, "wbcLookupDomainController", test_wbc_lookupdc
);
715 torture_suite_add_simple_test(suite
, "wbcLookupDomainControllerEx", test_wbc_lookupdcex
);
716 torture_suite_add_simple_test(suite
, "wbcResolveWinsByName", test_wbc_resolve_winsbyname
);
717 torture_suite_add_simple_test(suite
, "wbcResolveWinsByIP", test_wbc_resolve_winsbyip
);
718 torture_suite_add_simple_test(suite
, "wbcLookupRids",
719 test_wbc_lookup_rids
);
720 torture_suite_add_simple_test(suite
, "wbcGetSidAliases",
721 test_wbc_get_sidaliases
);
722 torture_suite_add_simple_test(suite
, "wbcAuthenticateUser",
723 test_wbc_authenticate_user
);
724 torture_suite_add_simple_test(suite
, "wbcLogonUser",
725 test_wbc_logon_user
);
726 torture_suite_add_simple_test(suite
, "wbcChangeUserPassword",
727 test_wbc_change_password
);
728 torture_suite_add_simple_test(suite
, "wbcGetGroups",