5 int main(int argc, char **argv) {
6 CacServerHandle *hnd = NULL;
7 TALLOC_CTX *mem_ctx = NULL;
13 mem_ctx = talloc_init("cac_disable");
15 hnd = cac_NewServerHandle(True);
17 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
19 cac_parse_cmd_line(argc, argv, hnd);
21 if(!cac_Connect(hnd, NULL)) {
22 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
26 struct SamOpenDomain sod;
29 sod.in.access = MAXIMUM_ALLOWED_ACCESS;
31 if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
32 fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
37 printf("Enter username: ");
38 cactest_readline(stdin, tmp);
40 ou.in.name = talloc_strdup(mem_ctx, tmp);
41 ou.in.access = MAXIMUM_ALLOWED_ACCESS;
42 ou.in.dom_hnd = sod.out.dom_hnd;
44 if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
45 fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status));
50 if(!cac_SamDisableUser(hnd, mem_ctx, ou.out.user_hnd)) {
51 fprintf(stderr, "Could not disable user: %s\n", nt_errstr(hnd->status));
55 cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
59 talloc_destroy(mem_ctx);