2
Wrapper over the MAPI Profile API
6
Copyright (C) Julien Kerihuel 2007-2009
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#include "libmapi/libmapi.h"
23
#include <samba/popt.h>
25
#include "openchange-tools.h"
28
#include <sys/types.h>
32
#define DEFAULT_DIR "%s/.openchange"
33
#define DEFAULT_PROFDB "%s/.openchange/profiles.ldb"
34
#define DEFAULT_EXCHANGE_VERSION "2000"
38
#- 0: use EcDoConnect (0x0) / EcDoRpc (0x2) RPC calls
39
#- 1: use EcDoConnectEx (0xA) / EcDoRpcExt2 (0xB) RPC calls
40
#- 2: Same as 1, but require sealed pipe
42
struct exchange_version {
47
static const struct exchange_version exchange_version[] = {
48
{ DEFAULT_EXCHANGE_VERSION, 0 },
55
static bool mapiprofile_createdb(const char *profdb, const char *ldif_path)
57
enum MAPISTATUS retval;
59
if (access(profdb, F_OK) == 0) {
60
fprintf(stderr, "[ERROR] mapiprofile: %s already exists\n", profdb);
64
retval = CreateProfileStore(profdb, ldif_path);
65
if (retval != MAPI_E_SUCCESS) {
66
mapi_errstr("CreateProfileStore", retval);
73
static uint32_t callback(struct SRowSet *rowset, void *private)
76
struct SPropValue *lpProp;
80
const char *label = (const char *)private;
82
printf("%s:\n", label);
83
for (i = 0; i < rowset->cRows; i++) {
84
lpProp = get_SPropValue_SRow(&(rowset->aRow[i]), PR_DISPLAY_NAME);
85
if (lpProp && lpProp->value.lpszA) {
86
printf("\t[%u] %s\n", i, lpProp->value.lpszA);
89
printf("\t[%u] cancel operation\n", i);
92
printf("Enter username id [0]: ");
93
if (fgets(entry, 10, fd) == NULL) {
94
printf("Failed to read string\n");
100
printf("Invalid id - Must be a value between 0 and %u\n", i);
108
const char *g_profname;
109
struct mapi_context *g_mapi_ctx;
111
static void signal_delete_profile(void)
113
enum MAPISTATUS retval;
115
fprintf(stderr, "CTRL-C caught ... Deleting profile\n");
116
if ((retval = DeleteProfile(g_mapi_ctx, g_profname)) != MAPI_E_SUCCESS) {
117
mapi_errstr("DeleteProfile", retval);
120
(void) signal(SIGINT, SIG_DFL);
124
static bool mapiprofile_create(struct mapi_context *mapi_ctx,
125
const char *profdb, const char *profname,
126
const char *pattern, const char *username,
127
const char *password, const char *address,
128
const char *language, const char *workstation,
129
const char *domain, const char *realm,
130
uint32_t flags, bool seal,
131
bool opt_dumpdata, const char *opt_debuglevel,
132
uint8_t exchange_version, const char *kerberos)
134
enum MAPISTATUS retval;
135
struct mapi_session *session = NULL;
137
struct mapi_profile profile;
141
char *exchange_version_str;
145
mem_ctx = talloc_named(mapi_ctx->mem_ctx, 0, "mapiprofile_create");
148
g_profname = profname;
149
g_mapi_ctx = mapi_ctx;
151
#if defined (__FreeBSD__)
152
(void) signal(SIGINT, (sig_t) signal_delete_profile);
153
#elif defined (__SunOS)
154
(void) signal(SIGINT, signal_delete_profile);
156
(void) signal(SIGINT, (sighandler_t) signal_delete_profile);
160
SetMAPIDumpData(mapi_ctx, opt_dumpdata);
162
if (opt_debuglevel) {
163
SetMAPIDebugLevel(mapi_ctx, atoi(opt_debuglevel));
167
retval = OpenProfile(mapi_ctx, &profile, profname, NULL);
168
if (retval == MAPI_E_SUCCESS) {
169
fprintf(stderr, "[ERROR] mapiprofile: profile \"%s\" already exists\n", profname);
170
talloc_free(mem_ctx);
174
retval = CreateProfile(mapi_ctx, profname, username, password, flags);
175
if (retval != MAPI_E_SUCCESS) {
176
mapi_errstr("CreateProfile", retval);
177
talloc_free(mem_ctx);
181
mapi_profile_add_string_attr(mapi_ctx, profname, "binding", address);
182
mapi_profile_add_string_attr(mapi_ctx, profname, "workstation", workstation);
183
mapi_profile_add_string_attr(mapi_ctx, profname, "domain", domain);
184
mapi_profile_add_string_attr(mapi_ctx, profname, "seal", (seal == true) ? "true" : "false");
186
exchange_version_str = talloc_asprintf(mem_ctx, "%d", exchange_version);
187
mapi_profile_add_string_attr(mapi_ctx, profname, "exchange_version", exchange_version_str);
188
talloc_free(exchange_version_str);
191
mapi_profile_add_string_attr(mapi_ctx, profname, "realm", realm);
194
locale = (const char *) (language) ? mapi_get_locale_from_language(language) : mapi_get_system_locale();
197
cpid = mapi_get_cpid_from_locale(locale);
198
lcid = mapi_get_lcid_from_locale(locale);
201
if (!locale || !cpid || !lcid) {
202
printf("Invalid Language supplied or unknown system language '%s\n'", language);
203
printf("Deleting profile\n");
204
if ((retval = DeleteProfile(mapi_ctx, profname)) != MAPI_E_SUCCESS) {
205
mapi_errstr("DeleteProfile", retval);
207
talloc_free(mem_ctx);
211
cpid_str = talloc_asprintf(mem_ctx, "%d", cpid);
212
lcid_str = talloc_asprintf(mem_ctx, "%d", lcid);
214
mapi_profile_add_string_attr(mapi_ctx, profname, "codepage", cpid_str);
215
mapi_profile_add_string_attr(mapi_ctx, profname, "language", lcid_str);
216
mapi_profile_add_string_attr(mapi_ctx, profname, "method", lcid_str);
218
talloc_free(cpid_str);
219
talloc_free(lcid_str);
222
mapi_profile_add_string_attr(mapi_ctx, profname, "kerberos", kerberos);
225
retval = MapiLogonProvider(mapi_ctx, &session, profname, password, PROVIDER_ID_NSPI);
226
if (retval != MAPI_E_SUCCESS) {
227
mapi_errstr("MapiLogonProvider", retval);
228
printf("Deleting profile\n");
229
if ((retval = DeleteProfile(mapi_ctx, profname)) != MAPI_E_SUCCESS) {
230
mapi_errstr("DeleteProfile", retval);
232
talloc_free(mem_ctx);
240
retval = ProcessNetworkProfile(session, username, (mapi_profile_callback_t) callback, "Select a user id");
241
if (retval != MAPI_E_SUCCESS && retval != 0x1) {
242
mapi_errstr("ProcessNetworkProfile", retval);
243
printf("Deleting profile\n");
244
if ((retval = DeleteProfile(mapi_ctx, profname)) != MAPI_E_SUCCESS) {
245
mapi_errstr("DeleteProfile", retval);
247
talloc_free(mem_ctx);
251
printf("Profile %s completed and added to database %s\n", profname, profdb);
253
talloc_free(mem_ctx);
258
static void mapiprofile_delete(struct mapi_context *mapi_ctx, const char *profdb, const char *profname)
260
enum MAPISTATUS retval;
262
if ((retval = DeleteProfile(mapi_ctx, profname)) != MAPI_E_SUCCESS) {
263
mapi_errstr("DeleteProfile", retval);
267
printf("Profile %s deleted from database %s\n", profname, profdb);
271
static void mapiprofile_rename(struct mapi_context *mapi_ctx, const char *profdb, const char *old_profname, const char *new_profname)
274
enum MAPISTATUS retval;
277
mem_ctx = talloc_named(mapi_ctx->mem_ctx, 0, "mapiprofile_rename");
280
if ((retval = GetDefaultProfile(mapi_ctx, &profname)) != MAPI_E_SUCCESS) {
281
mapi_errstr("GetDefaultProfile", retval);
282
talloc_free(mem_ctx);
286
profname = talloc_strdup(mem_ctx, old_profname);
289
if ((retval = RenameProfile(mapi_ctx, profname, new_profname)) != MAPI_E_SUCCESS) {
290
mapi_errstr("RenameProfile", retval);
291
talloc_free(profname);
292
talloc_free(mem_ctx);
296
talloc_free(profname);
297
talloc_free(mem_ctx);
301
static void mapiprofile_set_default(struct mapi_context *mapi_ctx, const char *profdb, const char *profname)
303
enum MAPISTATUS retval;
305
if ((retval = SetDefaultProfile(mapi_ctx, profname)) != MAPI_E_SUCCESS) {
306
mapi_errstr("SetDefaultProfile", retval);
310
printf("Profile %s is now set the default one\n", profname);
313
static void mapiprofile_get_default(struct mapi_context *mapi_ctx, const char *profdb)
315
enum MAPISTATUS retval;
318
if ((retval = GetDefaultProfile(mapi_ctx, &profname)) != MAPI_E_SUCCESS) {
319
mapi_errstr("GetDefaultProfile", retval);
323
printf("Default profile is set to %s\n", profname);
325
talloc_free(profname);
328
static void mapiprofile_get_fqdn(struct mapi_context *mapi_ctx,
330
const char *opt_profname,
331
const char *password,
335
enum MAPISTATUS retval;
336
struct mapi_session *session = NULL;
337
const char *serverFQDN;
340
SetMAPIDumpData(mapi_ctx, opt_dumpdata);
342
mem_ctx = talloc_named(mapi_ctx->mem_ctx, 0, "mapiprofile_get_fqdn");
345
if ((retval = GetDefaultProfile(mapi_ctx, &profname)) != MAPI_E_SUCCESS) {
346
mapi_errstr("GetDefaultProfile", retval);
347
talloc_free(mem_ctx);
351
profname = talloc_strdup(mem_ctx, (char *)opt_profname);
354
retval = MapiLogonProvider(mapi_ctx, &session, profname, password, PROVIDER_ID_NSPI);
355
talloc_free(profname);
356
talloc_free(mem_ctx);
357
if (retval != MAPI_E_SUCCESS) {
358
mapi_errstr("MapiLogonProvider", retval);
362
retval = RfrGetFQDNFromLegacyDN(mapi_ctx, session, &serverFQDN);
363
if (retval != MAPI_E_SUCCESS) {
364
mapi_errstr("RfrGetFQDNFromLegacyDN", retval);
368
printf("%s is at %s\n", mapi_ctx->session->profile->homemdb, serverFQDN);
371
static void mapiprofile_list(struct mapi_context *mapi_ctx, const char *profdb)
373
enum MAPISTATUS retval;
374
struct SRowSet proftable;
377
memset(&proftable, 0, sizeof (struct SRowSet));
378
if ((retval = GetProfileTable(mapi_ctx, &proftable)) != MAPI_E_SUCCESS) {
379
mapi_errstr("GetProfileTable", retval);
383
printf("We have %u profiles in the database:\n", proftable.cRows);
385
for (count = 0; count != proftable.cRows; count++) {
386
const char *name = NULL;
389
name = proftable.aRow[count].lpProps[0].value.lpszA;
390
dflt = proftable.aRow[count].lpProps[1].value.l;
393
printf("\tProfile = %s [default]\n", name);
395
printf("\tProfile = %s\n", name);
401
static void mapiprofile_dump(struct mapi_context *mapi_ctx, const char *profdb, const char *opt_profname)
404
enum MAPISTATUS retval;
405
struct mapi_profile profile;
407
char *exchange_version = NULL;
409
mem_ctx = talloc_named(mapi_ctx->mem_ctx, 0, "mapiprofile_dump");
412
if ((retval = GetDefaultProfile(mapi_ctx, &profname)) != MAPI_E_SUCCESS) {
413
mapi_errstr("GetDefaultProfile", retval);
414
talloc_free(mem_ctx);
418
profname = talloc_strdup(mem_ctx, (const char *)opt_profname);
421
retval = OpenProfile(mapi_ctx, &profile, profname, NULL);
422
talloc_free(profname);
424
if (retval && (retval != MAPI_E_INVALID_PARAMETER)) {
425
talloc_free(mem_ctx);
426
mapi_errstr("OpenProfile", retval);
430
switch (profile.exchange_version) {
432
exchange_version = talloc_strdup(mem_ctx, "exchange 2000");
435
exchange_version = talloc_strdup(mem_ctx, "exchange 2003/2007");
438
exchange_version = talloc_strdup(mem_ctx, "exchange 2010");
441
printf("Error: unknown Exchange server\n");
445
printf("Profile: %s\n", profile.profname);
446
printf("\texchange server == %s\n", exchange_version);
447
printf("\tencryption == %s\n", (profile.seal == true) ? "yes" : "no");
448
printf("\tusername == %s\n", profile.username);
449
printf("\tpassword == %s\n", profile.password);
450
printf("\tmailbox == %s\n", profile.mailbox);
451
printf("\tworkstation == %s\n", profile.workstation);
452
printf("\tdomain == %s\n", profile.domain);
453
printf("\tserver == %s\n", profile.server);
456
talloc_free(mem_ctx);
459
static void mapiprofile_attribute(struct mapi_context *mapi_ctx, const char *profdb, const char *opt_profname,
460
const char *attribute)
463
enum MAPISTATUS retval;
464
struct mapi_profile profile;
465
char *profname = NULL;
467
unsigned int count = 0;
470
mem_ctx = talloc_named(mapi_ctx->mem_ctx, 0, "mapiprofile_attribute");
473
if ((retval = GetDefaultProfile(mapi_ctx, &profname)) != MAPI_E_SUCCESS) {
474
mapi_errstr("GetDefaultProfile", retval);
478
profname = talloc_strdup(mem_ctx, (const char *)opt_profname);
481
retval = OpenProfile(mapi_ctx, &profile, profname, NULL);
482
if (retval && (retval != MAPI_E_INVALID_PARAMETER)) {
483
mapi_errstr("OpenProfile", retval);
484
talloc_free(profname);
485
talloc_free(mem_ctx);
489
if ((retval = GetProfileAttr(&profile, attribute, &count, &value))) {
490
mapi_errstr("ProfileGetAttr", retval);
491
talloc_free(profname);
492
talloc_free(mem_ctx);
496
printf("Profile %s: results(%u)\n", profname, count);
497
for (i = 0; i < count; i++) {
498
printf("\t%s = %s\n", attribute, value[i]);
500
MAPIFreeBuffer(value);
501
talloc_free(profname);
502
talloc_free(mem_ctx);
505
static void show_help(poptContext pc, const char *param)
507
printf("%s argument missing\n", param);
508
poptPrintUsage(pc, stderr, 0);
512
int main(int argc, const char *argv[])
515
struct mapi_context *mapi_ctx = NULL;
525
bool listlangs = false;
528
bool setdflt = false;
529
bool getdflt = false;
530
bool getfqdn = false;
531
bool opt_dumpdata = false;
532
bool opt_seal = false;
533
const char *opt_debuglevel = NULL;
534
const char *ldif = NULL;
535
const char *address = NULL;
536
const char *workstation = NULL;
537
const char *domain = NULL;
538
const char *realm = NULL;
539
const char *username = NULL;
540
const char *language = NULL;
541
const char *pattern = NULL;
542
const char *password = NULL;
543
const char *profdb = NULL;
544
const char *profname = NULL;
545
const char *rename = NULL;
546
const char *attribute = NULL;
547
const char *opt_tmp = NULL;
548
const char *opt_krb = NULL;
549
const char *version = NULL;
552
int retcode = EXIT_SUCCESS;
554
enum {OPT_PROFILE_DB=1000, OPT_PROFILE, OPT_ADDRESS, OPT_WORKSTATION,
555
OPT_DOMAIN, OPT_REALM, OPT_USERNAME, OPT_LANGUAGE, OPT_PASSWORD,
556
OPT_CREATE_PROFILE, OPT_DELETE_PROFILE, OPT_LIST_PROFILE, OPT_DUMP_PROFILE,
557
OPT_DUMP_ATTR, OPT_PROFILE_NEWDB, OPT_PROFILE_LDIF, OPT_LIST_LANGS,
558
OPT_PROFILE_SET_DFLT, OPT_PROFILE_GET_DFLT, OPT_PATTERN, OPT_GETFQDN,
559
OPT_NOPASS, OPT_RENAME_PROFILE, OPT_DUMPDATA, OPT_DEBUGLEVEL,
560
OPT_ENCRYPT_CONN, OPT_EXCHANGE_VERSION, OPT_KRB};
562
struct poptOption long_options[] = {
564
{"ldif", 'L', POPT_ARG_STRING, NULL, OPT_PROFILE_LDIF, "set the ldif path", "PATH"},
565
{"getdefault", 'G', POPT_ARG_NONE, NULL, OPT_PROFILE_GET_DFLT, "get the default profile", NULL},
566
{"default", 'S', POPT_ARG_NONE, NULL, OPT_PROFILE_SET_DFLT, "set the default profile", NULL},
567
{"newdb", 'n', POPT_ARG_NONE, NULL, OPT_PROFILE_NEWDB, "create a new profile store", NULL},
568
{"database", 'f', POPT_ARG_STRING, NULL, OPT_PROFILE_DB, "set the profile database path", "PATH"},
569
{"profile", 'P', POPT_ARG_STRING, NULL, OPT_PROFILE, "set the profile name", "PROFILE"},
570
{"address", 'I', POPT_ARG_STRING, NULL, OPT_ADDRESS, "set the exchange server IP address", "xxx.xxx.xxx.xxx"},
571
{"workstation", 'M', POPT_ARG_STRING, NULL, OPT_WORKSTATION, "set the workstation", "WORKSTATION_NAME"},
572
{"domain", 'D', POPT_ARG_STRING, NULL, OPT_DOMAIN, "set the domain/workgroup", "DOMAIN"},
573
{"realm", 'R', POPT_ARG_STRING, NULL, OPT_REALM, "set the realm", "REALM"},
574
{"encrypt", 'E', POPT_ARG_NONE, NULL, OPT_ENCRYPT_CONN, "enable encryption with Exchange server", NULL },
575
{"exchange-version", 'v', POPT_ARG_STRING, NULL, OPT_EXCHANGE_VERSION, "specify Exchange server version", "2000" },
576
{"username", 'u', POPT_ARG_STRING, NULL, OPT_USERNAME, "set the profile username", "USERNAME"},
577
{"language", 'C', POPT_ARG_STRING, NULL, OPT_LANGUAGE, "set the user's language (if different from system one)", "LANGUAGE"},
578
{"pattern", 's', POPT_ARG_STRING, NULL, OPT_PATTERN, "username to search for", "USERNAME"},
579
{"password", 'p', POPT_ARG_STRING, NULL, OPT_PASSWORD, "set the profile password", "PASSWORD"},
580
{"nopass", 0, POPT_ARG_NONE, NULL, OPT_NOPASS, "do not save password in the profile", NULL},
581
{"create", 'c', POPT_ARG_NONE, NULL, OPT_CREATE_PROFILE, "create a profile in the database", NULL},
582
{"delete", 'r', POPT_ARG_NONE, NULL, OPT_DELETE_PROFILE, "delete a profile in the database", NULL},
583
{"rename", 'R', POPT_ARG_STRING, NULL, OPT_RENAME_PROFILE, "rename a profile in the database", NULL},
584
{"list", 'l', POPT_ARG_NONE, NULL, OPT_LIST_PROFILE, "list existing profiles in the database", NULL},
585
{"listlangs", 0, POPT_ARG_NONE, NULL, OPT_LIST_LANGS, "list all recognised languages", NULL},
586
{"dump", 0, POPT_ARG_NONE, NULL, OPT_DUMP_PROFILE, "dump a profile entry", NULL},
587
{"attr", 'a', POPT_ARG_STRING, NULL, OPT_DUMP_ATTR, "print an attribute value", "VALUE"},
588
{"dump-data", 0, POPT_ARG_NONE, NULL, OPT_DUMPDATA, "dump the hex data", NULL},
589
{"debuglevel", 'd', POPT_ARG_STRING, NULL, OPT_DEBUGLEVEL, "set the debug level", "LEVEL"},
590
{"getfqdn", 0, POPT_ARG_NONE, NULL, OPT_GETFQDN, "returns the DNS FQDN of the NSPI server matching the legacyDN", NULL},
591
{"kerberos", 'k', POPT_ARG_STRING, NULL, OPT_KRB, "specify kerberos behavior (guess by default)", "{yes|no}"},
592
POPT_OPENCHANGE_VERSION
593
{ NULL, 0, POPT_ARG_NONE, NULL, 0, NULL, NULL }
596
mem_ctx = talloc_named(NULL, 0, "mapiprofile");
598
pc = poptGetContext("mapiprofile", argc, argv, long_options, 0);
600
while ((opt = poptGetNextOpt(pc)) != -1) {
606
opt_debuglevel = poptGetOptArg(pc);
608
case OPT_PROFILE_LDIF:
609
opt_tmp = poptGetOptArg(pc);
610
ldif = talloc_strdup(mem_ctx, opt_tmp);
611
free((void*)opt_tmp);
614
case OPT_PROFILE_NEWDB:
617
case OPT_PROFILE_SET_DFLT:
620
case OPT_PROFILE_GET_DFLT:
624
opt_tmp = poptGetOptArg(pc);
625
profdb = talloc_strdup(mem_ctx, opt_tmp);
626
free((void*)opt_tmp);
630
profname = poptGetOptArg(pc);
633
address = poptGetOptArg(pc);
635
case OPT_WORKSTATION:
636
opt_tmp = poptGetOptArg(pc);
637
workstation = talloc_strdup(mem_ctx, opt_tmp);
638
free((void*)opt_tmp);
642
domain = poptGetOptArg(pc);
645
realm = poptGetOptArg(pc);
647
case OPT_ENCRYPT_CONN:
650
case OPT_EXCHANGE_VERSION:
651
opt_tmp = poptGetOptArg(pc);
652
version = talloc_strdup(mem_ctx, opt_tmp);
653
free((void *)opt_tmp);
657
username = poptGetOptArg(pc);
660
opt_tmp = poptGetOptArg(pc);
661
language = talloc_strdup(mem_ctx, opt_tmp);
662
free((void*)opt_tmp);
666
pattern = poptGetOptArg(pc);
669
password = poptGetOptArg(pc);
674
case OPT_CREATE_PROFILE:
677
case OPT_DELETE_PROFILE:
680
case OPT_RENAME_PROFILE:
681
rename = poptGetOptArg(pc);
683
case OPT_LIST_PROFILE:
689
case OPT_DUMP_PROFILE:
693
attribute = poptGetOptArg(pc);
699
opt_krb = poptGetOptArg(pc);
704
/* Sanity check on options */
706
default_path = talloc_asprintf(mem_ctx, DEFAULT_DIR, getenv("HOME"));
707
error = mkdir(default_path, 0700);
708
talloc_free(default_path);
709
if ((error == -1) && (errno != EEXIST)) {
711
retcode = EXIT_FAILURE;
714
profdb = talloc_asprintf(mem_ctx, DEFAULT_PROFDB,
718
if ((list == false) && (getfqdn == false) && (newdb == false) && (listlangs == false)
719
&& (getdflt == false) && (dump == false) && (rename == NULL) &&
720
(!attribute) && (!profname || !profdb)) {
721
poptPrintUsage(pc, stderr, 0);
722
retcode = EXIT_FAILURE;
728
ldif = talloc_strdup(mem_ctx, mapi_profile_get_ldif_path());
730
if (!ldif) show_help(pc, "ldif");
731
if (!mapiprofile_createdb(profdb, ldif)) {
732
retcode = EXIT_FAILURE;
737
if (MAPIInitialize(&mapi_ctx, profdb) != MAPI_E_SUCCESS) {
738
mapi_errstr("MAPIInitialize", GetLastError());
743
if (strncmp(opt_krb, "yes", 3) && strncmp(opt_krb, "no", 2)) {
745
"kerberos value must be 'yes' or 'no'\n");
746
poptPrintUsage(pc, stderr, 0);
747
retcode = EXIT_FAILURE;
752
/* Process the code here */
755
gethostname(hostname, sizeof(hostname) - 1);
756
hostname[sizeof(hostname) - 1] = 0;
757
workstation = hostname;
760
if (create == true) {
761
if (!profname) show_help(pc, "profile");
762
if (!password && !nopass) show_help(pc, "password");
763
if (!username) show_help(pc, "username");
764
if (!address) show_help(pc, "address");
767
version = talloc_strdup(mem_ctx, DEFAULT_EXCHANGE_VERSION);
770
for (i = 0; exchange_version[i].name; i++) {
771
if (!strcasecmp(version, exchange_version[i].name)) {
772
version = talloc_strdup(mem_ctx, exchange_version[i].name);
777
if (found == false) {
778
printf("Invalid Exchange server version. Possible values are:\n");
779
for (i = 0; exchange_version[i].name; i++) {
780
printf("\t[*] %s\n", exchange_version[i].name);
785
/* Force encrypt parameter if exchange2010 is specified */
786
if (!strcasecmp(version, "2010")) {
789
talloc_free((void *)version);
791
if (! mapiprofile_create(mapi_ctx, profdb, profname, pattern, username, password, address,
792
language, workstation, domain, realm, nopass, opt_seal,
793
opt_dumpdata, opt_debuglevel,
794
exchange_version[i].version,
796
retcode = EXIT_FAILURE;
802
mapiprofile_rename(mapi_ctx, profdb, profname, rename);
805
if (getfqdn == true) {
806
mapiprofile_get_fqdn(mapi_ctx, profdb, profname, password, opt_dumpdata);
809
if (listlangs == true) {
810
mapidump_languages_list();
813
if (setdflt == true) {
814
mapiprofile_set_default(mapi_ctx, profdb, profname);
817
if (getdflt == true) {
818
mapiprofile_get_default(mapi_ctx, profdb);
821
if (delete == true) {
822
mapiprofile_delete(mapi_ctx, profdb, profname);
826
mapiprofile_list(mapi_ctx, profdb);
830
mapiprofile_dump(mapi_ctx, profdb, profname);
834
mapiprofile_attribute(mapi_ctx, profdb, profname, attribute);
838
free((void*)opt_debuglevel);
839
free((void*)profname);
840
free((void*)address);
843
free((void*)username);
844
free((void*)pattern);
845
free((void*)password);
847
free((void*)attribute);
850
MAPIUninitialize(mapi_ctx);
852
talloc_free(mem_ctx);