3
3
* Project ___| | | | _ \| |
4
4
* / __| | | | |_) | |
5
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: ldap.c,v 1.57 2006-07-25 13:49:50 yangtse Exp $
21
* $Id: ldap.c,v 1.69 2007-03-12 05:09:25 yangtse Exp $
22
22
***************************************************************************/
372
378
char *dn = (*ldap_get_dn)(server, entryIterator);
375
Curl_client_write(data, CLIENTWRITE_BODY, (char *)"DN: ", 4);
376
Curl_client_write(data, CLIENTWRITE_BODY, (char *)dn, 0);
377
Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1);
381
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
382
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);
383
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
379
385
for (attribute = (*ldap_first_attribute)(server, entryIterator, &ber);
388
394
for (i = 0; (vals[i] != NULL); i++)
390
Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1);
391
Curl_client_write(data, CLIENTWRITE_BODY, (char *) attribute, 0);
392
Curl_client_write(data, CLIENTWRITE_BODY, (char *)": ", 2);
396
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
397
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
398
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
393
399
if ((strlen(attribute) > 7) &&
394
400
(strcmp(";binary",
395
401
(char *)attribute +
396
402
(strlen((char *)attribute) - 7)) == 0)) {
397
403
/* Binary attribute, encode to base64. */
398
val_b64_sz = Curl_base64_encode(vals[i]->bv_val, vals[i]->bv_len,
404
val_b64_sz = Curl_base64_encode(conn->data,
400
408
if (val_b64_sz > 0) {
401
Curl_client_write(data, CLIENTWRITE_BODY, val_b64, val_b64_sz);
409
Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
405
Curl_client_write(data, CLIENTWRITE_BODY, vals[i]->bv_val,
413
Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
406
414
vals[i]->bv_len);
407
Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 0);
415
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
410
418
/* Free memory used to store values */
411
419
(*ldap_value_free_len)((void **)vals);
413
Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1);
421
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
415
423
(*ldap_memfree)(attribute);
433
441
/* no data to transfer */
434
Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
442
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
435
443
conn->bits.close = TRUE;
542
550
* <hostname> already known from 'conn->host.name'.
543
551
* <port> already known from 'conn->remote_port'.
544
* extract the rest from 'conn->path+1'. All fields are optional. e.g.
545
* ldap://<hostname>:<port>/?<attributes>?<scope>?<filter> yields ludp->lud_dn = "".
552
* extract the rest from 'conn->data->reqdata.path+1'. All fields are optional.
554
* ldap://<hostname>:<port>/?<attributes>?<scope>?<filter>
555
* yields ludp->lud_dn = "".
547
557
* Ref. http://developer.netscape.com/docs/manuals/dirsdk/csdk30/url.htm#2831915
554
if (!conn->path || conn->path[0] != '/' ||
565
!conn->data->reqdata.path ||
566
conn->data->reqdata.path[0] != '/' ||
555
567
!checkprefix(conn->protostr, conn->data->change.url))
556
568
return LDAP_INVALID_SYNTAX;