1 /*simple test for libsmbclient compatibility. initialize a smbc context, open sessions on a couple pipes and quit*/
4 #include "libsmbclient.h"
7 int main(int argc, char **argv) {
9 CacServerHandle *hnd = NULL;
10 TALLOC_CTX *mem_ctx = NULL;
12 struct LsaOpenPolicy lop;
14 struct SamOpenDomain sod;
20 mem_ctx = talloc_init("cac_smbc");
22 printf("Could not initialize talloc context\n");
26 hnd = cac_NewServerHandle(True);
28 cac_parse_cmd_line(argc, argv, hnd);
30 /*initialize smbc context*/
31 if( (ctx = smbc_new_context()) == NULL) {
35 /*this probably isn't what someone would want to do, but it initializes the values we need*/
36 ctx->debug = hnd->debug;
37 ctx->callbacks.auth_fn = cac_GetAuthDataFn;
40 if(smbc_init_context(ctx) == NULL)
43 cac_SetSmbcContext(hnd, ctx);
45 /*still have to call cac_Connect()*/
46 if(!cac_Connect(hnd, NULL)) {
47 printf("Could not connect to server\n");
51 lop.in.access = MAXIMUM_ALLOWED_ACCESS;
52 if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop))
53 printf("Could not open LSA policy. Error: %s\n", nt_errstr(hnd->status));
55 printf("Opened LSA policy.\n");
57 rc.in.access = MAXIMUM_ALLOWED_ACCESS;
58 rc.in.root = HKEY_LOCAL_MACHINE;
59 if(!cac_RegConnect(hnd, mem_ctx, &rc))
60 printf("Could not connect to registry. Error: %s\n", nt_errstr(hnd->status));
62 printf("Connceted to Registry.\n");
64 sod.in.access = MAXIMUM_ALLOWED_ACCESS;
66 if(!cac_SamOpenDomain(hnd, mem_ctx, &sod))
67 printf("Could not open domain SAM. Error: %s\n", nt_errstr(hnd->status));
69 printf("Opened domain.\n");
72 cac_LsaClosePolicy(hnd, mem_ctx, lop.out.pol);
75 cac_RegClose(hnd, mem_ctx, rc.out.key);
78 cac_SamClose(hnd, mem_ctx, sod.out.sam);
81 cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
84 talloc_destroy(mem_ctx);