Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

disable.c File Reference

#include "libmsrpc.h"
#include "test_util.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main int  argc,
char **  argv
 

Definition at line 5 of file disable.c.

References cac_Connect(), cac_FreeHandle(), cac_NewServerHandle(), cac_parse_cmd_line(), cac_SamClose(), cac_SamDisableUser(), 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.

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


© sourcejam.com 2005-2008