Exemplo n.º 1
0
int main(int argc, char *argv[]){
    
    int i = 0;

    if(opt_parse(argc, argv, "d:f:u:p:n:o:csg")){
        fprintf(stderr, "bad cmdline arguments. please retry!\n");
        exit(2);
    }
    
    if(get_stdin_passwd)
        get_real_passwd(); 

    if(!conf_filepath)
        conf_filepath = AD_CONF_FILE;

    if(get_cond_from_file(conf_filepath) && !isvalid_ad_cond()){
        fprintf(stderr, "initialize from file failed. please retry!\n");
        exit(1);
    }

    if(!isvalid_ad_cond()){
        fprintf(stderr, "can't get fully informations to connect WIN_AD.\n"
                        "please specify it again on cmdline or conf_file and retry!\n");
        exit(2);
    }
    get_domain_info(&ad);

    dump_ad_cond();
    free_ad_cond();

    return 0;
}
Exemplo n.º 2
0
static NTSTATUS connect_and_get_info(TALLOC_CTX *mem_ctx,
				     struct net_context *net_ctx,
				     struct cli_state **cli,
				     struct rpc_pipe_client **pipe_hnd,
				     struct policy_handle *pol_hnd,
				     struct dom_data *dom_data)
{
	NTSTATUS status;
	NTSTATUS result;

	status = net_make_ipc_connection_ex(net_ctx, NULL, NULL, NULL,
					    NET_FLAGS_PDC, cli);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("Failed to connect to [%s] with error [%s]\n",
			  net_ctx->opt_host, nt_errstr(status)));
		return status;
	}

	status = cli_rpc_pipe_open_noauth(*cli, &ndr_table_lsarpc.syntax_id, pipe_hnd);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("Failed to initialise lsa pipe with error [%s]\n",
			  nt_errstr(status)));
		return status;
	}

	status = dcerpc_lsa_open_policy2((*pipe_hnd)->binding_handle,
					 mem_ctx,
					 (*pipe_hnd)->srv_name_slash,
					 false,
					 (LSA_POLICY_VIEW_LOCAL_INFORMATION |
					  LSA_POLICY_TRUST_ADMIN |
					  LSA_POLICY_CREATE_SECRET),
					 pol_hnd,
					 &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("Failed to open policy handle with error [%s]\n",
			  nt_errstr(status)));
		return status;
	}
	if (!NT_STATUS_IS_OK(result)) {
		DEBUG(0, ("lsa_open_policy2 with error [%s]\n",
			  nt_errstr(result)));
		return result;
	}

	status = get_domain_info(mem_ctx, (*pipe_hnd)->binding_handle,
				 pol_hnd, dom_data);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("get_domain_info failed with error [%s].\n",
			  nt_errstr(status)));
		return status;
	}

	return NT_STATUS_OK;
}