#include "libmsrpc.h"#include "test_util.h"Go to the source code of this file.
Functions | |
| int | main (int argc, char **argv) |
|
||||||||||||
|
Definition at line 6 of file enable.c. References cac_Connect(), cac_FreeHandle(), cac_NewServerHandle(), cac_parse_cmd_line(), cac_SamClose(), cac_SamEnableUser(), cac_SamOpenDomain(), cac_SamOpenUser(), cac_SetAuthDataFn(), cactest_GetAuthDataFn(), cactest_readline(), fprintf(), SamOpenUser::in, SamOpenDomain::in, MAXIMUM_ALLOWED_ACCESS, nt_errstr(), SamOpenUser::out, SamOpenDomain::out, printf(), _CACSERVERHANDLE::server, _CACSERVERHANDLE::status, talloc_destroy, talloc_init(), talloc_strdup(), True, and ZERO_STRUCT. 00006 { 00007 CacServerHandle *hnd = NULL; 00008 TALLOC_CTX *mem_ctx = NULL; 00009 00010 struct SamOpenUser ou; 00011 00012 fstring tmp; 00013 00014 mem_ctx = talloc_init("cac_samgroup"); 00015 00016 hnd = cac_NewServerHandle(True); 00017 00018 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); 00019 00020 cac_parse_cmd_line(argc, argv, hnd); 00021 00022 if(!cac_Connect(hnd, NULL)) { 00023 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); 00024 exit(-1); 00025 } 00026 00027 struct SamOpenDomain sod; 00028 ZERO_STRUCT(sod); 00029 00030 sod.in.access = MAXIMUM_ALLOWED_ACCESS; 00031 00032 if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { 00033 fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); 00034 goto done; 00035 } 00036 00037 ZERO_STRUCT(ou); 00038 printf("Enter username: "); 00039 cactest_readline(stdin, tmp); 00040 00041 ou.in.name = talloc_strdup(mem_ctx, tmp); 00042 ou.in.access = MAXIMUM_ALLOWED_ACCESS; 00043 ou.in.dom_hnd = sod.out.dom_hnd; 00044 00045 if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) { 00046 fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status)); 00047 goto done; 00048 } 00049 00050 /*enable the user*/ 00051 if(!cac_SamEnableUser(hnd, mem_ctx, ou.out.user_hnd)) { 00052 fprintf(stderr, "Could not enable user: %s\n", nt_errstr(hnd->status)); 00053 } 00054 00055 done: 00056 cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); 00057 00058 cac_FreeHandle(hnd); 00059 00060 talloc_destroy(mem_ctx); 00061 00062 return 0; 00063 }
|