~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to libmapi/IMSProvider.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                return NT_STATUS_INVALID_PARAMETER;
55
55
        }
56
56
 
57
 
        ev = tevent_context_init(talloc_autofree_context());
 
57
        ev = tevent_context_init(parent_ctx);
58
58
        tevent_loop_allow_nesting(ev);
59
59
 
60
60
        status = dcerpc_pipe_connect(parent_ctx, 
123
123
   \param session pointer to the MAPI session context
124
124
   \param server the Exchange server address (IP or FQDN)
125
125
   \param userDN optional user mailbox DN
 
126
   \param dsa pointer to a new dsa (return value), containing
 
127
      a valid allocated string on success, otherwise NULL
126
128
 
127
 
   \return a valid allocated string on success, otherwise NULL.
 
129
   \return MAPI_E_SUCCESS on success, otherwise a MAPI error and
 
130
   serverFQDN content set to NULL.
128
131
 
129
132
   \note The string returned can either be RfrGetNewDSA one on
130
133
   success, or a copy of the server's argument one on failure. If no
133
136
   It is up to the developer to free the returned string when
134
137
   not needed anymore.
135
138
 */
136
 
_PUBLIC_ char *RfrGetNewDSA(struct mapi_context *mapi_ctx,
 
139
_PUBLIC_ enum MAPISTATUS RfrGetNewDSA(struct mapi_context *mapi_ctx,
137
140
                            struct mapi_session *session,
138
141
                            const char *server, 
139
 
                            const char *userDN)
 
142
                            const char *userDN,
 
143
                            char **dsa)
140
144
{
141
145
        NTSTATUS                status;
142
146
        TALLOC_CTX              *mem_ctx;
147
151
        char                    *ppszServer = NULL;
148
152
 
149
153
        /* Sanity Checks */
150
 
        if (!mapi_ctx) return NULL;
151
 
        if (!mapi_ctx->session) return NULL;
 
154
        if (!mapi_ctx) return MAPI_E_NOT_INITIALIZED;
 
155
        if (!mapi_ctx->session) return MAPI_E_NOT_INITIALIZED;
152
156
 
153
 
        mem_ctx = talloc_named(NULL, 0, "RfrGetNewDSA");
 
157
        mem_ctx = talloc_named(session, 0, "RfrGetNewDSA");
154
158
        profile = session->profile;
155
159
 
156
160
        binding = build_binding_string(mapi_ctx, mem_ctx, server, profile);
157
161
        status = provider_rpc_connection(mem_ctx, &pipe, binding, profile->credentials, &ndr_table_exchange_ds_rfr, mapi_ctx->lp_ctx);
158
162
        talloc_free(binding);
159
 
 
 
163
        
160
164
        if (!NT_STATUS_IS_OK(status)) {
161
165
                talloc_free(mem_ctx);
162
 
                return NULL;
 
166
                return MAPI_E_NETWORK_ERROR;
163
167
        }
164
168
 
165
169
 
177
181
 
178
182
        talloc_free(mem_ctx);
179
183
 
180
 
        return ppszServer;
 
184
        *dsa = ppszServer;
 
185
 
 
186
        return MAPI_E_SUCCESS;
181
187
}
182
188
 
183
189
 
214
220
        status = provider_rpc_connection(mem_ctx, &pipe, binding, profile->credentials, &ndr_table_exchange_ds_rfr, mapi_ctx->lp_ctx);
215
221
        talloc_free(binding);
216
222
 
 
223
        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_REFUSED), MAPI_E_NETWORK_ERROR, NULL);
 
224
        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_HOST_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
 
225
        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_PORT_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
 
226
        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT), MAPI_E_NETWORK_ERROR, NULL);
 
227
        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND), MAPI_E_NETWORK_ERROR, NULL);
217
228
        OPENCHANGE_RETVAL_IF(!NT_STATUS_IS_OK(status), MAPI_E_CALL_FAILED, NULL);
218
229
 
219
230
        r.in.ulFlags = 0x0;
264
275
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_HOST_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
265
276
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_PORT_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
266
277
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT), MAPI_E_NETWORK_ERROR, NULL);
 
278
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND), MAPI_E_NETWORK_ERROR, NULL);
267
279
                OPENCHANGE_RETVAL_IF(!NT_STATUS_IS_OK(status), MAPI_E_LOGON_FAILED, NULL);
268
280
                switch (profile->exchange_version) {
269
281
                case 0x0:
288
300
                        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_HOST_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
289
301
                        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_PORT_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
290
302
                        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT), MAPI_E_NETWORK_ERROR, NULL);
 
303
                        OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND), MAPI_E_NETWORK_ERROR, NULL);
291
304
                        OPENCHANGE_RETVAL_IF(!NT_STATUS_IS_OK(status), MAPI_E_LOGON_FAILED, NULL);
292
305
                        mapistatus = emsmdb_async_connect(prov_ctx);
293
306
                        OPENCHANGE_RETVAL_IF(mapistatus, mapistatus, NULL);
296
309
                break;
297
310
        case PROVIDER_ID_NSPI:
298
311
                /* Call RfrGetNewDSA prior any NSPI call */
299
 
                server = RfrGetNewDSA(mapi_ctx, session, profile->server, profile->mailbox);
 
312
                mapistatus = RfrGetNewDSA(mapi_ctx, session, profile->server, profile->mailbox, &server);
 
313
                OPENCHANGE_RETVAL_IF(mapistatus != MAPI_E_SUCCESS, mapistatus, NULL);
300
314
                binding = build_binding_string(mapi_ctx, mem_ctx, server, profile);
301
315
                talloc_free(server);
302
316
                status = provider_rpc_connection(mem_ctx, &pipe, binding, profile->credentials, &ndr_table_exchange_nsp, mapi_ctx->lp_ctx);
305
319
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_HOST_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
306
320
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_PORT_UNREACHABLE), MAPI_E_NETWORK_ERROR, NULL);
307
321
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT), MAPI_E_NETWORK_ERROR, NULL);
 
322
                OPENCHANGE_RETVAL_IF(NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND), MAPI_E_NETWORK_ERROR, NULL);
308
323
                OPENCHANGE_RETVAL_IF(!NT_STATUS_IS_OK(status), MAPI_E_LOGON_FAILED, NULL);
309
324
                provider->ctx = (void *)nspi_bind(provider, pipe, profile->credentials, 
310
325
                                                  profile->codepage, profile->language, profile->method);
394
409
   configures the server to send notifications on this port.
395
410
 
396
411
   \param session the session context to register for notifications on.
397
 
   \param ulEventMask the mask of events to provide notifications for.
398
412
 
399
413
   \return MAPI_E_SUCCESS on success, otherwise MAPI error.
400
414
 
406
420
 
407
421
   \sa RegisterAsyncNotification, Subscribe, Unsubscribe, MonitorNotification, GetLastError 
408
422
*/
409
 
_PUBLIC_ enum MAPISTATUS RegisterNotification(struct mapi_session *session,
410
 
                                              uint16_t ulEventMask)
 
423
_PUBLIC_ enum MAPISTATUS RegisterNotification(struct mapi_session *session)
411
424
{
412
425
        NTSTATUS                status;
413
426
        struct mapi_context     *mapi_ctx;
441
454
retry:
442
455
        lpKey->ab[7] = rand;
443
456
 
444
 
        status = emsmdb_register_notification(session, lpKey, ulEventMask);
 
457
        status = emsmdb_register_notification(session, lpKey);
445
458
        if (!NT_STATUS_IS_OK(status)) {
446
459
                if (attempt < 5) {
447
460
                        rand++;