6 int main(int argc, char **argv) {
7 CacServerHandle *hnd = NULL;
8 TALLOC_CTX *mem_ctx = NULL;
10 struct SamOpenUser ou;
14 mem_ctx = talloc_init("cac_samgroup");
16 hnd = cac_NewServerHandle(True);
18 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
20 cac_parse_cmd_line(argc, argv, hnd);
22 if(!cac_Connect(hnd, NULL)) {
23 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
27 struct SamOpenDomain sod;
30 sod.in.access = MAXIMUM_ALLOWED_ACCESS;
32 if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
33 fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
38 printf("Enter username: ");
39 cactest_readline(stdin, tmp);
41 ou.in.name = talloc_strdup(mem_ctx, tmp);
42 ou.in.access = MAXIMUM_ALLOWED_ACCESS;
43 ou.in.dom_hnd = sod.out.dom_hnd;
45 if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
46 fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status));
51 if(!cac_SamEnableUser(hnd, mem_ctx, ou.out.user_hnd)) {
52 fprintf(stderr, "Could not enable user: %s\n", nt_errstr(hnd->status));
56 cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
60 talloc_destroy(mem_ctx);