aboutsummaryrefslogtreecommitdiff
path: root/src/freerdp-auth-check.c
blob: 5b29cf1ef0125703231d05d320ea4350bb989bc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <freerdp/freerdp.h>
#include <freerdp/channels/channels.h>
#include <string.h>

void
auth_context_new (freerdp * instance, rdpContext * context)
{
	context->channels = freerdp_channels_new();
	return;
}

void
auth_context_free (freerdp * instance, rdpContext * context)
{
	return;
}

boolean
auth_pre_connect (freerdp * instance)
{
	freerdp_channels_pre_connect(instance->context->channels, instance);
	return true;
}

boolean
auth_post_connect (freerdp * instance)
{
	freerdp_channels_post_connect(instance->context->channels, instance);
	return true;
}

int
main (int argc, char * argv[])
{
	char password[512];
	if (argc != 4) {
		printf("Not enough params");
		return -1;
	}

	if (scanf("%511s", password) != 1) {
		return -1;
	}

	freerdp_channels_global_init();

	freerdp * instance = freerdp_new();

	instance->PreConnect = auth_pre_connect;
	instance->PostConnect = auth_post_connect;

	instance->context_size = sizeof(rdpContext);
	instance->ContextNew = auth_context_new;
	instance->ContextFree = auth_context_free;

	freerdp_context_new(instance);

	instance->settings->hostname = argv[1];
	instance->settings->username = argv[2];
	instance->settings->domain = argv[3];
	instance->settings->password = password;
	instance->settings->ignore_certificate = true;

	if (freerdp_connect(instance)) {
		freerdp_disconnect(instance);
		return 0;
	} else {
		return -1;
	}
}