1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /* Copyright (C) 2003, 2004 Novell, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 /* Autoconfig test program */
31 #include "e2k-autoconfig.h"
32 #include "test-utils.h"
34 const char *test_program_name = "actest";
36 static E2kOperation op;
41 e2k_operation_cancel (&op);
48 static pthread_t cancel_thread;
51 pthread_create (&cancel_thread, NULL, cancel, NULL);
57 test_main (int argc, char **argv)
60 E2kAutoconfigResult result;
61 const char *username, *password, *owa_uri, *gc_server;
63 signal (SIGINT, quit);
65 if (argc < 2 || argc > 4) {
66 fprintf (stderr, "Usage: %s username [OWA URL] [Global Catalog server]\n", argv[0]);
71 password = test_get_password (username, NULL);
73 owa_uri = argc > 2 ? argv[2] : NULL;
74 gc_server = argc > 3 ? argv[3] : NULL;
76 e2k_operation_init (&op);
77 ac = e2k_autoconfig_new (owa_uri, username, password,
78 E2K_AUTOCONFIG_USE_EITHER);
82 printf ("[Default OWA URI: %s]\n", ac->owa_uri);
84 printf ("No default OWA URI available. Must specify on commandline.\n");
89 printf ("[Default GC: %s]\n", ac->gc_server);
91 printf ("[Default NT Domain: %s]\n", ac->nt_domain);
93 printf ("[Default W2k Domain: %s]\n", ac->w2k_domain);
97 e2k_autoconfig_set_gc_server (ac, gc_server, -1);
99 result = e2k_autoconfig_check_exchange (ac, &op);
100 if (result != E2K_AUTOCONFIG_OK) {
103 case E2K_AUTOCONFIG_CANT_RESOLVE:
104 msg = "Could not resolve hostname";
106 case E2K_AUTOCONFIG_CANT_CONNECT:
107 msg = "Could not connect to server";
109 case E2K_AUTOCONFIG_REDIRECT:
110 msg = "Multiple redirection";
112 case E2K_AUTOCONFIG_AUTH_ERROR:
113 msg = "Authentication error. Password incorrect?";
115 case E2K_AUTOCONFIG_AUTH_ERROR_TRY_DOMAIN:
116 msg = "Authentication error. Password incorrect, or try DOMAIN\\username?";
118 case E2K_AUTOCONFIG_AUTH_ERROR_TRY_BASIC:
119 msg = "Authentication error. Password incorrect, or try Basic auth?";
121 case E2K_AUTOCONFIG_AUTH_ERROR_TRY_NTLM:
122 msg = "Authentication error. Password incorrect, or try NTLM auth?";
124 case E2K_AUTOCONFIG_TRY_SSL:
125 msg = "Need to use SSL";
127 case E2K_AUTOCONFIG_EXCHANGE_5_5:
128 msg = "This is an Exchange 5.5 server";
130 case E2K_AUTOCONFIG_NOT_EXCHANGE:
131 msg = "Server does not appear to be Exchange";
133 case E2K_AUTOCONFIG_NO_OWA:
134 msg = "Did not find OWA at given URL";
136 case E2K_AUTOCONFIG_NO_MAILBOX:
137 msg = "You don't seem to have a mailbox here";
139 case E2K_AUTOCONFIG_CANT_BPROPFIND:
140 msg = "Server does not allow BPROPFIND";
142 case E2K_AUTOCONFIG_CANCELLED:
145 case E2K_AUTOCONFIG_FAILED:
147 msg = "Unknown error";
151 printf ("Exchange check to %s failed:\n %s\n",
156 result = e2k_autoconfig_check_global_catalog (ac, &op);
157 if (result != E2K_AUTOCONFIG_OK) {
160 case E2K_AUTOCONFIG_CANT_RESOLVE:
161 msg = "Could not resolve GC server";
163 case E2K_AUTOCONFIG_NO_MAILBOX:
164 msg = "No data for user";
166 case E2K_AUTOCONFIG_AUTH_ERROR_TRY_DOMAIN:
167 msg = "Authentication error. Try DOMAIN\\username?";
169 case E2K_AUTOCONFIG_CANCELLED:
172 case E2K_AUTOCONFIG_FAILED:
174 msg = "Unknown error";
178 printf ("\nGlobal Catalog check failed: %s\n", msg);
179 if (!ac->gc_server) {
181 printf ("got domain=%s but ", ac->w2k_domain);
182 printf ("could not autodetect.\nSpecify GC on command-line.\n");
187 printf ("%s is an Exchange Server %s\n\n", ac->exchange_server,
188 ac->version == E2K_EXCHANGE_2000 ? "2000" :
189 ac->version == E2K_EXCHANGE_2003 ? "2003" :
190 "[Unknown version]");
192 printf ("Name: %s\nEmail: %s\nTimezone: %s\nAccount URL: %s\n\n",
193 ac->display_name, ac->email, ac->timezone, ac->account_uri);
196 printf ("Warning: public folder server was defaulted\n\n");
198 e2k_operation_free (&op);
199 e2k_autoconfig_free (ac);