Changeset 745 for trunk/server/source4/torture/ldap
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/torture/ldap/basic.c
r414 r745 5 5 Copyright (C) Stefan Metzmacher 2004 6 6 Copyright (C) Simo Sorce 2004 7 Copyright (C) Matthias Dieter Wallnöfer 2009 7 Copyright (C) Matthias Dieter Wallnöfer 2009-2010 8 8 9 9 This program is free software; you can redistribute it and/or modify … … 23 23 24 24 #include "includes.h" 25 #include "ldb_wrap.h" 25 26 #include "libcli/ldap/ldap_client.h" 26 27 #include "lib/cmdline/popt_common.h" … … 29 30 #include "torture/ldap/proto.h" 30 31 31 #include "param/param.h"32 32 33 33 static bool test_bind_simple(struct ldap_connection *conn, const char *userdn, const char *password) … … 64 64 bool ret = true; 65 65 66 printf("Testing multiple binds on a single conn nection as anonymous and user\n");66 printf("Testing multiple binds on a single connection as anonymous and user\n"); 67 67 68 68 ret = test_bind_simple(conn, NULL, NULL); … … 80 80 } 81 81 82 static bool test_search_rootDSE(struct ldap_connection *conn, char **basedn) 82 static bool test_search_rootDSE(struct ldap_connection *conn, const char **basedn, 83 const char ***partitions) 83 84 { 84 85 bool ret = true; … … 92 93 93 94 *basedn = NULL; 95 96 if (partitions != NULL) { 97 *partitions = const_str_list(str_list_make_empty(conn)); 98 } 94 99 95 100 msg = new_ldap_message(conn); … … 139 144 (char *)r->attributes[i].values[j].data); 140 145 } 146 if ((partitions != NULL) && 147 (strcasecmp("namingContexts", r->attributes[i].name) == 0)) { 148 char *entry = talloc_asprintf(conn, "%.*s", 149 (int)r->attributes[i].values[j].length, 150 (char *)r->attributes[i].values[j].data); 151 *partitions = str_list_add(*partitions, entry); 152 } 141 153 } 142 154 } 143 144 talloc_free(req);145 155 146 156 return ret; … … 209 219 } 210 220 221 /* This has to be done using the LDAP API since the LDB API does only transmit 222 * the error code and not the error message. */ 211 223 static bool test_error_codes(struct torture_context *tctx, 212 224 struct ldap_connection *conn, const char *basedn) … … 214 226 struct ldap_message *msg, *rep; 215 227 struct ldap_request *req; 216 char *err_code_str, *endptr; 228 const char *err_code_str; 229 char *endptr; 217 230 WERROR err; 218 231 NTSTATUS status; 219 232 220 printf("Testing error codes - to make this test pass against SAMBA 4 you have to specify the target!\n");233 printf("Testing the most important error code -> error message conversions!\n"); 221 234 222 235 if (!basedn) { … … 243 256 status = ldap_result_one(req, &rep, LDAP_TAG_AddResponse); 244 257 if (!NT_STATUS_IS_OK(status)) { 245 printf("error in ldap add itionrequest - %s\n", nt_errstr(status));258 printf("error in ldap add request - %s\n", nt_errstr(status)); 246 259 return false; 247 260 } … … 258 271 err_code_str = win_errstr(err); 259 272 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 260 if (!torture_setting_bool(tctx, "samba4", false)) { 261 if ((!W_ERROR_EQUAL(err, WERR_DS_REFERRAL)) 262 || (rep->r.AddResponse.resultcode != 10)) { 273 if ((!W_ERROR_EQUAL(err, WERR_DS_REFERRAL)) 274 || (rep->r.AddResponse.resultcode != LDAP_REFERRAL)) { 263 275 return false; 264 } 265 } else { 266 if ((!W_ERROR_EQUAL(err, WERR_DS_GENERIC_ERROR)) 267 || (rep->r.AddResponse.resultcode != 80)) { 276 } 277 if ((rep->r.AddResponse.referral == NULL) 278 || (strstr(rep->r.AddResponse.referral, basedn) == NULL)) { 268 279 return false; 269 } 280 } 281 282 printf(" Try another wrong addition\n"); 283 284 msg->type = LDAP_TAG_AddRequest; 285 msg->r.AddRequest.dn = ""; 286 msg->r.AddRequest.num_attributes = 0; 287 msg->r.AddRequest.attributes = NULL; 288 289 req = ldap_request_send(conn, msg); 290 if (!req) { 291 return false; 292 } 293 294 status = ldap_result_one(req, &rep, LDAP_TAG_AddResponse); 295 if (!NT_STATUS_IS_OK(status)) { 296 printf("error in ldap add request - %s\n", nt_errstr(status)); 297 return false; 298 } 299 300 if ((rep->r.AddResponse.resultcode == 0) 301 || (rep->r.AddResponse.errormessage == NULL) 302 || (strtol(rep->r.AddResponse.errormessage, &endptr,16) <= 0) 303 || (*endptr != ':')) { 304 printf("Invalid error message!\n"); 305 return false; 306 } 307 308 err = ad_error(rep->r.AddResponse.errormessage, &endptr); 309 err_code_str = win_errstr(err); 310 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 311 if ((!W_ERROR_EQUAL(err, WERR_DS_ROOT_MUST_BE_NC) && 312 !W_ERROR_EQUAL(err, WERR_DS_NAMING_VIOLATION)) 313 || (rep->r.AddResponse.resultcode != LDAP_NAMING_VIOLATION)) { 314 return false; 270 315 } 271 316 272 317 printf(" Try a wrong modification\n"); 318 319 msg->type = LDAP_TAG_ModifyRequest; 320 msg->r.ModifyRequest.dn = basedn; 321 msg->r.ModifyRequest.num_mods = 0; 322 msg->r.ModifyRequest.mods = NULL; 323 324 req = ldap_request_send(conn, msg); 325 if (!req) { 326 return false; 327 } 328 329 status = ldap_result_one(req, &rep, LDAP_TAG_ModifyResponse); 330 if (!NT_STATUS_IS_OK(status)) { 331 printf("error in ldap modifification request - %s\n", nt_errstr(status)); 332 return false; 333 } 334 335 if ((rep->r.ModifyResponse.resultcode == 0) 336 || (rep->r.ModifyResponse.errormessage == NULL) 337 || (strtol(rep->r.ModifyResponse.errormessage, &endptr,16) <= 0) 338 || (*endptr != ':')) { 339 printf("Invalid error message!\n"); 340 return false; 341 } 342 343 err = ad_error(rep->r.ModifyResponse.errormessage, &endptr); 344 err_code_str = win_errstr(err); 345 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 346 if ((!W_ERROR_EQUAL(err, WERR_INVALID_PARAM) && 347 !W_ERROR_EQUAL(err, WERR_DS_UNWILLING_TO_PERFORM)) 348 || (rep->r.ModifyResponse.resultcode != LDAP_UNWILLING_TO_PERFORM)) { 349 return false; 350 } 351 352 printf(" Try another wrong modification\n"); 273 353 274 354 msg->type = LDAP_TAG_ModifyRequest; … … 299 379 err_code_str = win_errstr(err); 300 380 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 301 if (!torture_setting_bool(tctx, "samba4", false)) { 302 if ((!W_ERROR_EQUAL(err, WERR_INVALID_PARAM)) 303 || (rep->r.ModifyResponse.resultcode != 53)) { 304 return false; 305 } 306 } else { 307 if ((!W_ERROR_EQUAL(err, WERR_DS_GENERIC_ERROR)) 308 || (rep->r.ModifyResponse.resultcode != 80)) { 309 return false; 310 } 381 if ((!W_ERROR_EQUAL(err, WERR_INVALID_PARAM) && 382 !W_ERROR_EQUAL(err, WERR_DS_UNWILLING_TO_PERFORM)) 383 || (rep->r.ModifyResponse.resultcode != LDAP_UNWILLING_TO_PERFORM)) { 384 return false; 311 385 } 312 386 … … 314 388 315 389 msg->type = LDAP_TAG_DelRequest; 316 msg->r.DelRequest.dn = "";390 msg->r.DelRequest.dn = basedn; 317 391 318 392 req = ldap_request_send(conn, msg); … … 334 408 return false; 335 409 } 410 411 err = ad_error(rep->r.DelResponse.errormessage, &endptr); 412 err_code_str = win_errstr(err); 413 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 414 if ((!W_ERROR_EQUAL(err, WERR_DS_CANT_DELETE) && 415 !W_ERROR_EQUAL(err, WERR_DS_UNWILLING_TO_PERFORM)) 416 || (rep->r.DelResponse.resultcode != LDAP_UNWILLING_TO_PERFORM)) { 417 return false; 418 } 419 420 printf(" Try another wrong removal\n"); 421 422 msg->type = LDAP_TAG_DelRequest; 423 msg->r.DelRequest.dn = ""; 424 425 req = ldap_request_send(conn, msg); 426 if (!req) { 427 return false; 428 } 429 430 status = ldap_result_one(req, &rep, LDAP_TAG_DelResponse); 431 if (!NT_STATUS_IS_OK(status)) { 432 printf("error in ldap removal request - %s\n", nt_errstr(status)); 433 return false; 434 } 435 436 if ((rep->r.DelResponse.resultcode == 0) 437 || (rep->r.DelResponse.errormessage == NULL) 438 || (strtol(rep->r.DelResponse.errormessage, &endptr,16) <= 0) 439 || (*endptr != ':')) { 440 printf("Invalid error message!\n"); 441 return false; 442 } 336 443 337 444 err = ad_error(rep->r.DelResponse.errormessage, &endptr); 338 445 err_code_str = win_errstr(err); 339 446 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 340 if (!torture_setting_bool(tctx, "samba4", false)) { 341 if ((!W_ERROR_EQUAL(err, WERR_DS_OBJ_NOT_FOUND)) 342 || (rep->r.DelResponse.resultcode != 32)) { 447 if ((!W_ERROR_EQUAL(err, WERR_DS_OBJ_NOT_FOUND) && 448 !W_ERROR_EQUAL(err, WERR_DS_NO_SUCH_OBJECT)) 449 || (rep->r.DelResponse.resultcode != LDAP_NO_SUCH_OBJECT)) { 450 return false; 451 } 452 453 printf(" Try a wrong rename\n"); 454 455 msg->type = LDAP_TAG_ModifyDNRequest; 456 msg->r.ModifyDNRequest.dn = basedn; 457 msg->r.ModifyDNRequest.newrdn = "dc=test"; 458 msg->r.ModifyDNRequest.deleteolddn = true; 459 msg->r.ModifyDNRequest.newsuperior = NULL; 460 461 req = ldap_request_send(conn, msg); 462 if (!req) { 463 return false; 464 } 465 466 status = ldap_result_one(req, &rep, LDAP_TAG_ModifyDNResponse); 467 if (!NT_STATUS_IS_OK(status)) { 468 printf("error in ldap rename request - %s\n", nt_errstr(status)); 469 return false; 470 } 471 472 if ((rep->r.ModifyDNResponse.resultcode == 0) 473 || (rep->r.ModifyDNResponse.errormessage == NULL) 474 || (strtol(rep->r.ModifyDNResponse.errormessage, &endptr,16) <= 0) 475 || (*endptr != ':')) { 476 printf("Invalid error message!\n"); 477 return false; 478 } 479 480 err = ad_error(rep->r.ModifyDNResponse.errormessage, &endptr); 481 err_code_str = win_errstr(err); 482 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 483 if ((!W_ERROR_EQUAL(err, WERR_DS_NO_PARENT_OBJECT) && 484 !W_ERROR_EQUAL(err, WERR_DS_GENERIC_ERROR)) 485 || (rep->r.ModifyDNResponse.resultcode != LDAP_OTHER)) { 486 return false; 487 } 488 489 printf(" Try another wrong rename\n"); 490 491 msg->type = LDAP_TAG_ModifyDNRequest; 492 msg->r.ModifyDNRequest.dn = basedn; 493 msg->r.ModifyDNRequest.newrdn = basedn; 494 msg->r.ModifyDNRequest.deleteolddn = true; 495 msg->r.ModifyDNRequest.newsuperior = NULL; 496 497 req = ldap_request_send(conn, msg); 498 if (!req) { 499 return false; 500 } 501 502 status = ldap_result_one(req, &rep, LDAP_TAG_ModifyDNResponse); 503 if (!NT_STATUS_IS_OK(status)) { 504 printf("error in ldap rename request - %s\n", nt_errstr(status)); 505 return false; 506 } 507 508 if ((rep->r.ModifyDNResponse.resultcode == 0) 509 || (rep->r.ModifyDNResponse.errormessage == NULL) 510 || (strtol(rep->r.ModifyDNResponse.errormessage, &endptr,16) <= 0) 511 || (*endptr != ':')) { 512 printf("Invalid error message!\n"); 513 return false; 514 } 515 516 err = ad_error(rep->r.ModifyDNResponse.errormessage, &endptr); 517 err_code_str = win_errstr(err); 518 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 519 if ((!W_ERROR_EQUAL(err, WERR_INVALID_PARAM) && 520 !W_ERROR_EQUAL(err, WERR_DS_NAMING_VIOLATION)) 521 || (rep->r.ModifyDNResponse.resultcode != LDAP_NAMING_VIOLATION)) { 522 return false; 523 } 524 525 printf(" Try another wrong rename\n"); 526 527 msg->type = LDAP_TAG_ModifyDNRequest; 528 msg->r.ModifyDNRequest.dn = basedn; 529 msg->r.ModifyDNRequest.newrdn = ""; 530 msg->r.ModifyDNRequest.deleteolddn = true; 531 msg->r.ModifyDNRequest.newsuperior = NULL; 532 533 req = ldap_request_send(conn, msg); 534 if (!req) { 535 return false; 536 } 537 538 status = ldap_result_one(req, &rep, LDAP_TAG_ModifyDNResponse); 539 if (!NT_STATUS_IS_OK(status)) { 540 printf("error in ldap rename request - %s\n", nt_errstr(status)); 541 return false; 542 } 543 544 if ((rep->r.ModifyDNResponse.resultcode == 0) 545 || (rep->r.ModifyDNResponse.errormessage == NULL) 546 || (strtol(rep->r.ModifyDNResponse.errormessage, &endptr,16) <= 0) 547 || (*endptr != ':')) { 548 printf("Invalid error message!\n"); 549 return false; 550 } 551 552 err = ad_error(rep->r.ModifyDNResponse.errormessage, &endptr); 553 err_code_str = win_errstr(err); 554 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 555 if ((!W_ERROR_EQUAL(err, WERR_INVALID_PARAM) && 556 !W_ERROR_EQUAL(err, WERR_DS_PROTOCOL_ERROR)) 557 || (rep->r.ModifyDNResponse.resultcode != LDAP_PROTOCOL_ERROR)) { 558 return false; 559 } 560 561 printf(" Try another wrong rename\n"); 562 563 msg->type = LDAP_TAG_ModifyDNRequest; 564 msg->r.ModifyDNRequest.dn = ""; 565 msg->r.ModifyDNRequest.newrdn = "cn=temp"; 566 msg->r.ModifyDNRequest.deleteolddn = true; 567 msg->r.ModifyDNRequest.newsuperior = NULL; 568 569 req = ldap_request_send(conn, msg); 570 if (!req) { 571 return false; 572 } 573 574 status = ldap_result_one(req, &rep, LDAP_TAG_ModifyDNResponse); 575 if (!NT_STATUS_IS_OK(status)) { 576 printf("error in ldap rename request - %s\n", nt_errstr(status)); 577 return false; 578 } 579 580 if ((rep->r.ModifyDNResponse.resultcode == 0) 581 || (rep->r.ModifyDNResponse.errormessage == NULL) 582 || (strtol(rep->r.ModifyDNResponse.errormessage, &endptr,16) <= 0) 583 || (*endptr != ':')) { 584 printf("Invalid error message!\n"); 585 return false; 586 } 587 588 err = ad_error(rep->r.ModifyDNResponse.errormessage, &endptr); 589 err_code_str = win_errstr(err); 590 printf(" - Errorcode: %s; Reason: %s\n", err_code_str, endptr); 591 if ((!W_ERROR_EQUAL(err, WERR_DS_OBJ_NOT_FOUND) && 592 !W_ERROR_EQUAL(err, WERR_DS_NO_SUCH_OBJECT)) 593 || (rep->r.ModifyDNResponse.resultcode != LDAP_NO_SUCH_OBJECT)) { 594 return false; 595 } 596 597 return true; 598 } 599 600 static bool test_referrals(struct torture_context *tctx, TALLOC_CTX *mem_ctx, 601 const char *url, const char *basedn, const char **partitions) 602 { 603 struct ldb_context *ldb; 604 struct ldb_result *res; 605 const char * const *attrs = { NULL }; 606 struct ldb_dn *dn1, *dn2; 607 int ret; 608 int i, j, k; 609 char *tempstr; 610 bool found, l_found; 611 612 printf("Testing referrals\n"); 613 614 if (partitions[0] == NULL) { 615 printf("Partitions list empty!\n"); 616 return false; 617 } 618 619 if (strcmp(partitions[0], basedn) != 0) { 620 printf("The first (root) partition DN should be the base DN!\n"); 621 return false; 622 } 623 624 ldb = ldb_wrap_connect(mem_ctx, tctx->ev, tctx->lp_ctx, url, 625 NULL, cmdline_credentials, 0); 626 627 /* "partitions[i]" are the partitions for which we search the parents */ 628 for (i = 1; partitions[i] != NULL; i++) { 629 dn1 = ldb_dn_new(mem_ctx, ldb, partitions[i]); 630 if (dn1 == NULL) { 631 printf("Out of memory\n"); 632 talloc_free(ldb); 343 633 return false; 344 634 } 345 } else { 346 if ((!W_ERROR_EQUAL(err, WERR_DS_INVALID_DN_SYNTAX)) 347 || (rep->r.DelResponse.resultcode != 34)) { 348 return false; 635 636 /* search using base scope */ 637 /* "partitions[j]" are the parent candidates */ 638 for (j = str_list_length(partitions) - 1; j >= 0; --j) { 639 dn2 = ldb_dn_new(mem_ctx, ldb, partitions[j]); 640 if (dn2 == NULL) { 641 printf("Out of memory\n"); 642 talloc_free(ldb); 643 return false; 644 } 645 646 ret = ldb_search(ldb, mem_ctx, &res, dn2, 647 LDB_SCOPE_BASE, attrs, 648 "(foo=bar)"); 649 if (ret != LDB_SUCCESS) { 650 printf("%s", ldb_errstring(ldb)); 651 talloc_free(ldb); 652 return false; 653 } 654 655 if (res->refs != NULL) { 656 printf("There shouldn't be generated any referrals in the base scope!\n"); 657 talloc_free(ldb); 658 return false; 659 } 660 661 talloc_free(res); 662 talloc_free(dn2); 349 663 } 350 } 664 665 /* search using onelevel scope */ 666 found = false; 667 /* "partitions[j]" are the parent candidates */ 668 for (j = str_list_length(partitions) - 1; j >= 0; --j) { 669 dn2 = ldb_dn_new(mem_ctx, ldb, partitions[j]); 670 if (dn2 == NULL) { 671 printf("Out of memory\n"); 672 talloc_free(ldb); 673 return false; 674 } 675 676 ret = ldb_search(ldb, mem_ctx, &res, dn2, 677 LDB_SCOPE_ONELEVEL, attrs, 678 "(foo=bar)"); 679 if (ret != LDB_SUCCESS) { 680 printf("%s", ldb_errstring(ldb)); 681 talloc_free(ldb); 682 return false; 683 } 684 685 tempstr = talloc_asprintf(mem_ctx, "/%s??base", 686 partitions[i]); 687 if (tempstr == NULL) { 688 printf("Out of memory\n"); 689 talloc_free(ldb); 690 return false; 691 } 692 693 /* Try to find or find not a matching referral */ 694 l_found = false; 695 for (k = 0; (!l_found) && (res->refs != NULL) 696 && (res->refs[k] != NULL); k++) { 697 if (strstr(res->refs[k], tempstr) != NULL) { 698 l_found = true; 699 } 700 } 701 702 talloc_free(tempstr); 703 704 if ((!found) && (ldb_dn_compare_base(dn2, dn1) == 0) 705 && (ldb_dn_compare(dn2, dn1) != 0)) { 706 /* This is a referral candidate */ 707 if (!l_found) { 708 printf("A required referral hasn't been found on onelevel scope (%s -> %s)!\n", partitions[j], partitions[i]); 709 talloc_free(ldb); 710 return false; 711 } 712 found = true; 713 } else { 714 /* This isn't a referral candidate */ 715 if (l_found) { 716 printf("A unrequired referral has been found on onelevel scope (%s -> %s)!\n", partitions[j], partitions[i]); 717 talloc_free(ldb); 718 return false; 719 } 720 } 721 722 talloc_free(res); 723 talloc_free(dn2); 724 } 725 726 /* search using subtree scope */ 727 found = false; 728 /* "partitions[j]" are the parent candidates */ 729 for (j = str_list_length(partitions) - 1; j >= 0; --j) { 730 dn2 = ldb_dn_new(mem_ctx, ldb, partitions[j]); 731 if (dn2 == NULL) { 732 printf("Out of memory\n"); 733 talloc_free(ldb); 734 return false; 735 } 736 737 ret = ldb_search(ldb, mem_ctx, &res, dn2, 738 LDB_SCOPE_SUBTREE, attrs, 739 "(foo=bar)"); 740 if (ret != LDB_SUCCESS) { 741 printf("%s", ldb_errstring(ldb)); 742 talloc_free(ldb); 743 return false; 744 } 745 746 tempstr = talloc_asprintf(mem_ctx, "/%s", 747 partitions[i]); 748 if (tempstr == NULL) { 749 printf("Out of memory\n"); 750 talloc_free(ldb); 751 return false; 752 } 753 754 /* Try to find or find not a matching referral */ 755 l_found = false; 756 for (k = 0; (!l_found) && (res->refs != NULL) 757 && (res->refs[k] != NULL); k++) { 758 if (strstr(res->refs[k], tempstr) != NULL) { 759 l_found = true; 760 } 761 } 762 763 talloc_free(tempstr); 764 765 if ((!found) && (ldb_dn_compare_base(dn2, dn1) == 0) 766 && (ldb_dn_compare(dn2, dn1) != 0)) { 767 /* This is a referral candidate */ 768 if (!l_found) { 769 printf("A required referral hasn't been found on subtree scope (%s -> %s)!\n", partitions[j], partitions[i]); 770 talloc_free(ldb); 771 return false; 772 } 773 found = true; 774 } else { 775 /* This isn't a referral candidate */ 776 if (l_found) { 777 printf("A unrequired referral has been found on subtree scope (%s -> %s)!\n", partitions[j], partitions[i]); 778 talloc_free(ldb); 779 return false; 780 } 781 } 782 783 talloc_free(res); 784 talloc_free(dn2); 785 } 786 787 talloc_free(dn1); 788 } 789 790 talloc_free(ldb); 351 791 352 792 return true; 353 793 } 794 795 static bool test_abandom_request(struct torture_context *tctx, 796 struct ldap_connection *conn, const char *basedn) 797 { 798 struct ldap_message *msg; 799 struct ldap_request *req; 800 NTSTATUS status; 801 802 printf("Testing the AbandonRequest with an old message id!\n"); 803 804 if (!basedn) { 805 return false; 806 } 807 808 msg = new_ldap_message(conn); 809 if (!msg) { 810 return false; 811 } 812 813 printf(" Try a AbandonRequest for an old message id\n"); 814 815 msg->type = LDAP_TAG_AbandonRequest; 816 msg->r.AbandonRequest.messageid = 1; 817 818 req = ldap_request_send(conn, msg); 819 if (!req) { 820 return false; 821 } 822 823 status = ldap_request_wait(req); 824 if (!NT_STATUS_IS_OK(status)) { 825 printf("error in ldap abandon request - %s\n", nt_errstr(status)); 826 return false; 827 } 828 829 return true; 830 } 831 354 832 355 833 bool torture_ldap_basic(struct torture_context *torture) … … 362 840 const char *userdn = torture_setting_string(torture, "ldap_userdn", NULL); 363 841 const char *secret = torture_setting_string(torture, "ldap_secret", NULL); 364 char *url; 365 char *basedn; 842 const char *url; 843 const char *basedn; 844 const char **partitions; 366 845 367 846 mem_ctx = talloc_init("torture_ldap_basic"); … … 374 853 } 375 854 376 if (!test_search_rootDSE(conn, &basedn )) {855 if (!test_search_rootDSE(conn, &basedn, &partitions)) { 377 856 ret = false; 378 857 } … … 395 874 396 875 if (!test_error_codes(torture, conn, basedn)) { 876 ret = false; 877 } 878 879 /* referrals test here */ 880 881 if (!test_referrals(torture, mem_ctx, url, basedn, partitions)) { 882 ret = false; 883 } 884 885 if (!test_abandom_request(torture, conn, basedn)) { 397 886 ret = false; 398 887 } -
trunk/server/source4/torture/ldap/cldap.c
r414 r745 5 5 6 6 Copyright (C) Andrew Tridgell 2005 7 Copyright (C) Matthias Dieter Wallnöfer 2009 7 8 8 9 This program is free software; you can redistribute it and/or modify … … 23 24 #include "includes.h" 24 25 #include "libcli/cldap/cldap.h" 25 #include "libcli/ldap/ldap.h" 26 #include "librpc/gen_ndr/ndr_nbt.h" 26 #include "libcli/ldap/libcli_ldap.h" 27 27 #include "librpc/gen_ndr/netlogon.h" 28 28 #include "torture/torture.h" 29 #include "lib/ldb/include/ldb.h"30 29 #include "param/param.h" 31 30 #include "../lib/tsocket/tsocket.h" … … 47 46 struct GUID guid; 48 47 int i; 49 struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);50 48 struct tsocket_address *dest_addr; 51 49 int ret; … … 53 51 ret = tsocket_address_inet_from_strings(tctx, "ip", 54 52 dest, 55 lp _cldap_port(tctx->lp_ctx),53 lpcfg_cldap_port(tctx->lp_ctx), 56 54 &dest_addr); 57 55 CHECK_VAL(ret, 0); … … 71 69 printf("Trying without any attributes\n"); 72 70 search = empty_search; 73 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);71 status = cldap_netlogon(cldap, tctx, &search); 74 72 CHECK_STATUS(status, NT_STATUS_OK); 75 73 … … 84 82 search.in.version = i; 85 83 printf("Trying netlogon level %d\n", i); 86 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);84 status = cldap_netlogon(cldap, tctx, &search); 87 85 CHECK_STATUS(status, NT_STATUS_OK); 88 86 } … … 92 90 search.in.version = (1<<i); 93 91 printf("Trying netlogon level 0x%x\n", i); 94 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);92 status = cldap_netlogon(cldap, tctx, &search); 95 93 CHECK_STATUS(status, NT_STATUS_OK); 96 94 } 97 95 98 96 search.in.version = NETLOGON_NT_VERSION_5|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_IP; 99 100 status = cldap_netlogon(cldap, iconv_convenience, tctx, &search); 97 status = cldap_netlogon(cldap, tctx, &search); 101 98 CHECK_STATUS(status, NT_STATUS_OK); 102 99 103 100 printf("Trying with User=NULL\n"); 104 105 101 search.in.user = NULL; 106 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);107 CHECK_STATUS(status, NT_STATUS_OK); 108 CHECK_ STRING(search.out.netlogon.data.nt5_ex.user_name, "");109 CHECK_ VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);102 status = cldap_netlogon(cldap, tctx, &search); 103 CHECK_STATUS(status, NT_STATUS_OK); 104 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 105 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 110 106 111 107 printf("Trying with User=Administrator\n"); 112 113 108 search.in.user = "Administrator"; 114 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);115 CHECK_STATUS(status, NT_STATUS_OK); 116 109 status = cldap_netlogon(cldap, tctx, &search); 110 CHECK_STATUS(status, NT_STATUS_OK); 111 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); 117 112 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); 118 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX);119 113 120 114 search.in.version = NETLOGON_NT_VERSION_5; 121 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);115 status = cldap_netlogon(cldap, tctx, &search); 122 116 CHECK_STATUS(status, NT_STATUS_OK); 123 117 124 118 printf("Trying with User=NULL\n"); 125 126 119 search.in.user = NULL; 127 status = cldap_netlogon(cldap, iconv_convenience, tctx, &search); 128 CHECK_STATUS(status, NT_STATUS_OK); 129 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 120 status = cldap_netlogon(cldap, tctx, &search); 121 CHECK_STATUS(status, NT_STATUS_OK); 130 122 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE); 123 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 131 124 132 125 printf("Trying with User=Administrator\n"); 133 134 126 search.in.user = "Administrator"; 135 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);136 CHECK_STATUS(status, NT_STATUS_OK); 137 127 status = cldap_netlogon(cldap, tctx, &search); 128 CHECK_STATUS(status, NT_STATUS_OK); 129 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN); 138 130 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); 139 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN);140 131 141 132 search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; … … 144 135 search.in.realm = NULL; 145 136 search.in.domain_guid = GUID_string(tctx, &n1.data.nt5_ex.domain_uuid); 146 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);137 status = cldap_netlogon(cldap, tctx, &search); 147 138 CHECK_STATUS(status, NT_STATUS_OK); 148 139 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); … … 153 144 search.in.user = NULL; 154 145 search.in.domain_guid = GUID_string(tctx, &guid); 155 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);146 status = cldap_netlogon(cldap, tctx, &search); 156 147 CHECK_STATUS(status, NT_STATUS_NOT_FOUND); 157 148 … … 159 150 search.in.acct_control = ACB_WSTRUST|ACB_SVRTRUST; 160 151 search.in.realm = n1.data.nt5_ex.dns_domain; 161 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);152 status = cldap_netlogon(cldap, tctx, &search); 162 153 CHECK_STATUS(status, NT_STATUS_OK); 163 154 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); … … 167 158 search.in.acct_control = 0x0; 168 159 search.in.realm = n1.data.nt5_ex.dns_domain; 169 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);160 status = cldap_netlogon(cldap, tctx, &search); 170 161 CHECK_STATUS(status, NT_STATUS_OK); 171 162 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); … … 176 167 search.in.user = "Administrator"; 177 168 search.in.realm = n1.data.nt5_ex.dns_domain; 178 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);169 status = cldap_netlogon(cldap, tctx, &search); 179 170 CHECK_STATUS(status, NT_STATUS_OK); 180 171 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); … … 185 176 search.in.acct_control = 0xFF00FF00; 186 177 search.in.realm = n1.data.nt5_ex.dns_domain; 187 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);178 status = cldap_netlogon(cldap, tctx, &search); 188 179 CHECK_STATUS(status, NT_STATUS_OK); 189 180 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); … … 193 184 search = empty_search; 194 185 search.in.user = "Administrator"; 195 status = cldap_netlogon(cldap, iconv_convenience, tctx, &search); 196 CHECK_STATUS(status, NT_STATUS_OK); 186 status = cldap_netlogon(cldap, tctx, &search); 187 CHECK_STATUS(status, NT_STATUS_OK); 188 CHECK_STRING(search.out.netlogon.data.nt5_ex.forest, n1.data.nt5_ex.dns_domain); 197 189 CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); 190 CHECK_STRING(search.out.netlogon.data.nt5_ex.domain_name, n1.data.nt5_ex.domain_name); 191 CHECK_STRING(search.out.netlogon.data.nt5_ex.pdc_name, n1.data.nt5_ex.pdc_name); 198 192 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); 193 CHECK_STRING(search.out.netlogon.data.nt5_ex.server_site, n1.data.nt5_ex.server_site); 194 CHECK_STRING(search.out.netlogon.data.nt5_ex.client_site, n1.data.nt5_ex.client_site); 199 195 200 196 printf("Trying with just a bad username\n"); 201 197 search.in.user = "___no_such_user___"; 202 status = cldap_netlogon(cldap, iconv_convenience, tctx, &search); 203 CHECK_STATUS(status, NT_STATUS_OK); 198 status = cldap_netlogon(cldap, tctx, &search); 199 CHECK_STATUS(status, NT_STATUS_OK); 200 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); 201 CHECK_STRING(search.out.netlogon.data.nt5_ex.forest, n1.data.nt5_ex.dns_domain); 202 CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); 203 CHECK_STRING(search.out.netlogon.data.nt5_ex.domain_name, n1.data.nt5_ex.domain_name); 204 CHECK_STRING(search.out.netlogon.data.nt5_ex.pdc_name, n1.data.nt5_ex.pdc_name); 204 205 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); 205 CHECK_STRING(search.out.netlogon.data.nt5_ex. dns_domain, n1.data.nt5_ex.dns_domain);206 CHECK_ VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX);206 CHECK_STRING(search.out.netlogon.data.nt5_ex.server_site, n1.data.nt5_ex.server_site); 207 CHECK_STRING(search.out.netlogon.data.nt5_ex.client_site, n1.data.nt5_ex.client_site); 207 208 208 209 printf("Trying with just a bad domain\n"); 209 210 search = empty_search; 210 211 search.in.realm = "___no_such_domain___"; 211 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);212 status = cldap_netlogon(cldap, tctx, &search); 212 213 CHECK_STATUS(status, NT_STATUS_NOT_FOUND); 213 214 214 215 printf("Trying with a incorrect domain and correct guid\n"); 215 216 search.in.domain_guid = GUID_string(tctx, &n1.data.nt5_ex.domain_uuid); 216 status = cldap_netlogon(cldap, iconv_convenience, tctx, &search); 217 CHECK_STATUS(status, NT_STATUS_OK); 217 status = cldap_netlogon(cldap, tctx, &search); 218 CHECK_STATUS(status, NT_STATUS_OK); 219 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 220 CHECK_STRING(search.out.netlogon.data.nt5_ex.forest, n1.data.nt5_ex.dns_domain); 218 221 CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); 219 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 220 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 222 CHECK_STRING(search.out.netlogon.data.nt5_ex.domain_name, n1.data.nt5_ex.domain_name); 223 CHECK_STRING(search.out.netlogon.data.nt5_ex.pdc_name, n1.data.nt5_ex.pdc_name); 224 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 225 CHECK_STRING(search.out.netlogon.data.nt5_ex.server_site, n1.data.nt5_ex.server_site); 226 CHECK_STRING(search.out.netlogon.data.nt5_ex.client_site, n1.data.nt5_ex.client_site); 221 227 222 228 printf("Trying with a incorrect domain and incorrect guid\n"); 223 229 search.in.domain_guid = GUID_string(tctx, &guid); 224 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);230 status = cldap_netlogon(cldap, tctx, &search); 225 231 CHECK_STATUS(status, NT_STATUS_NOT_FOUND); 232 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 233 CHECK_STRING(search.out.netlogon.data.nt5_ex.forest, n1.data.nt5_ex.dns_domain); 226 234 CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); 227 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 228 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 235 CHECK_STRING(search.out.netlogon.data.nt5_ex.domain_name, n1.data.nt5_ex.domain_name); 236 CHECK_STRING(search.out.netlogon.data.nt5_ex.pdc_name, n1.data.nt5_ex.pdc_name); 237 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 238 CHECK_STRING(search.out.netlogon.data.nt5_ex.server_site, n1.data.nt5_ex.server_site); 239 CHECK_STRING(search.out.netlogon.data.nt5_ex.client_site, n1.data.nt5_ex.client_site); 229 240 230 241 printf("Trying with a incorrect GUID and correct domain\n"); 231 242 search.in.domain_guid = GUID_string(tctx, &guid); 232 243 search.in.realm = n1.data.nt5_ex.dns_domain; 233 status = cldap_netlogon(cldap, iconv_convenience, tctx, &search); 234 CHECK_STATUS(status, NT_STATUS_OK); 244 status = cldap_netlogon(cldap, tctx, &search); 245 CHECK_STATUS(status, NT_STATUS_OK); 246 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 247 CHECK_STRING(search.out.netlogon.data.nt5_ex.forest, n1.data.nt5_ex.dns_domain); 235 248 CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); 236 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 237 CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); 249 CHECK_STRING(search.out.netlogon.data.nt5_ex.domain_name, n1.data.nt5_ex.domain_name); 250 CHECK_STRING(search.out.netlogon.data.nt5_ex.pdc_name, n1.data.nt5_ex.pdc_name); 251 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); 252 CHECK_STRING(search.out.netlogon.data.nt5_ex.server_site, n1.data.nt5_ex.server_site); 253 CHECK_STRING(search.out.netlogon.data.nt5_ex.client_site, n1.data.nt5_ex.client_site); 254 255 printf("Proof other results\n"); 256 search.in.user = "Administrator"; 257 status = cldap_netlogon(cldap, tctx, &search); 258 CHECK_STATUS(status, NT_STATUS_OK); 259 CHECK_STRING(search.out.netlogon.data.nt5_ex.forest, n1.data.nt5_ex.dns_domain); 260 CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); 261 CHECK_STRING(search.out.netlogon.data.nt5_ex.domain_name, n1.data.nt5_ex.domain_name); 262 CHECK_STRING(search.out.netlogon.data.nt5_ex.pdc_name, n1.data.nt5_ex.pdc_name); 263 CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); 264 CHECK_STRING(search.out.netlogon.data.nt5_ex.server_site, n1.data.nt5_ex.server_site); 265 CHECK_STRING(search.out.netlogon.data.nt5_ex.client_site, n1.data.nt5_ex.client_site); 238 266 239 267 return true; … … 251 279 struct netlogon_samlogon_response n1; 252 280 uint32_t server_type; 253 struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(tctx->lp_ctx); 281 struct tsocket_address *dest_addr; 282 int ret; 283 284 ret = tsocket_address_inet_from_strings(tctx, "ip", 285 dest, 286 lpcfg_cldap_port(tctx->lp_ctx), 287 &dest_addr); 288 CHECK_VAL(ret, 0); 254 289 255 290 /* cldap_socket_init should now know about the dest. address */ 256 status = cldap_socket_init(tctx, NULL, NULL, NULL, &cldap);291 status = cldap_socket_init(tctx, NULL, NULL, dest_addr, &cldap); 257 292 CHECK_STATUS(status, NT_STATUS_OK); 258 293 … … 260 295 261 296 ZERO_STRUCT(search); 262 search.in.dest_address = dest;263 search.in.dest_port = lp_cldap_port(tctx->lp_ctx);297 search.in.dest_address = NULL; 298 search.in.dest_port = 0; 264 299 search.in.acct_control = -1; 265 300 search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; 266 301 search.in.map_response = true; 267 302 268 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);303 status = cldap_netlogon(cldap, tctx, &search); 269 304 CHECK_STATUS(status, NT_STATUS_OK); 270 305 … … 304 339 if (server_type & DS_DNS_DOMAIN) 305 340 printf("DS_DNS_DOMAIN "); 306 if (server_type & DS_DNS_FOREST )307 printf("DS_DNS_FOREST ");341 if (server_type & DS_DNS_FOREST_ROOT) 342 printf("DS_DNS_FOREST_ROOT "); 308 343 309 344 printf("\n"); … … 353 388 354 389 /* 355 test cldap netlogon server type flag "NBT_SERVER_ DS_DNS_FOREST"390 test cldap netlogon server type flag "NBT_SERVER_FOREST_ROOT" 356 391 */ 357 392 static bool test_cldap_netlogon_flag_ds_dns_forest(struct torture_context *tctx, … … 363 398 uint32_t server_type; 364 399 struct netlogon_samlogon_response n1; 365 struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);366 400 bool result = true; 401 struct tsocket_address *dest_addr; 402 int ret; 403 404 ret = tsocket_address_inet_from_strings(tctx, "ip", 405 dest, 406 lpcfg_cldap_port(tctx->lp_ctx), 407 &dest_addr); 408 CHECK_VAL(ret, 0); 367 409 368 410 /* cldap_socket_init should now know about the dest. address */ 369 status = cldap_socket_init(tctx, NULL, NULL, NULL, &cldap);370 CHECK_STATUS(status, NT_STATUS_OK); 371 372 printf("Testing netlogon server type flag NBT_SERVER_ DS_DNS_FOREST: ");411 status = cldap_socket_init(tctx, NULL, NULL, dest_addr, &cldap); 412 CHECK_STATUS(status, NT_STATUS_OK); 413 414 printf("Testing netlogon server type flag NBT_SERVER_FOREST_ROOT: "); 373 415 374 416 ZERO_STRUCT(search); 375 search.in.dest_address = dest;376 search.in.dest_port = lp_cldap_port(tctx->lp_ctx);417 search.in.dest_address = NULL; 418 search.in.dest_port = 0; 377 419 search.in.acct_control = -1; 378 420 search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; 379 421 search.in.map_response = true; 380 422 381 status = cldap_netlogon(cldap, iconv_convenience,tctx, &search);423 status = cldap_netlogon(cldap, tctx, &search); 382 424 CHECK_STATUS(status, NT_STATUS_OK); 383 425 … … 388 430 server_type = n1.data.nt5_ex.server_type; 389 431 390 if (server_type & DS_DNS_FOREST ) {432 if (server_type & DS_DNS_FOREST_ROOT) { 391 433 struct cldap_search search2; 392 434 const char *attrs[] = { "defaultNamingContext", "rootDomainNamingContext", … … 399 441 ZERO_STRUCT(search2); 400 442 search2.in.dest_address = dest; 401 search2.in.dest_port = lp _cldap_port(tctx->lp_ctx);443 search2.in.dest_port = lpcfg_cldap_port(tctx->lp_ctx); 402 444 search2.in.timeout = 10; 403 445 search2.in.retries = 3; … … 439 481 const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL }; 440 482 const char *attrs3[] = { "netlogon", NULL }; 483 struct tsocket_address *dest_addr; 484 int ret; 485 486 ret = tsocket_address_inet_from_strings(tctx, "ip", 487 dest, 488 lpcfg_cldap_port(tctx->lp_ctx), 489 &dest_addr); 490 CHECK_VAL(ret, 0); 441 491 442 492 /* cldap_socket_init should now know about the dest. address */ 443 status = cldap_socket_init(tctx, NULL, NULL, NULL, &cldap);493 status = cldap_socket_init(tctx, NULL, NULL, dest_addr, &cldap); 444 494 CHECK_STATUS(status, NT_STATUS_OK); 445 495 446 496 ZERO_STRUCT(search); 447 search.in.dest_address = dest;448 search.in.dest_port = lp_cldap_port(tctx->lp_ctx);497 search.in.dest_address = NULL; 498 search.in.dest_port = 0; 449 499 search.in.timeout = 10; 450 500 search.in.retries = 3; -
trunk/server/source4/torture/ldap/cldapbench.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include <tevent.h>24 23 #include "libcli/cldap/cldap.h" 25 24 #include "libcli/resolve/resolve.h" … … 42 41 TALLOC_CTX *tmp_ctx = talloc_new(NULL); 43 42 io.in.version = 6; 44 status = cldap_netlogon_recv(req, 45 lp_iconv_convenience(state->tctx->lp_ctx), 46 tmp_ctx, &io); 43 status = cldap_netlogon_recv(req, tmp_ctx, &io); 47 44 talloc_free(req); 48 45 if (NT_STATUS_IS_OK(status)) { … … 71 68 ret = tsocket_address_inet_from_strings(tctx, "ip", 72 69 address, 73 lp _cldap_port(tctx->lp_ctx),70 lpcfg_cldap_port(tctx->lp_ctx), 74 71 &dest_addr); 75 72 CHECK_VAL(ret, 0); … … 82 79 83 80 ZERO_STRUCT(search); 84 search.in.dest_address = address;85 search.in.dest_port = lp_cldap_port(tctx->lp_ctx);81 search.in.dest_address = NULL; 82 search.in.dest_port = 0; 86 83 search.in.acct_control = -1; 87 84 search.in.version = 6; … … 149 146 struct bench_state *state; 150 147 NTSTATUS status; 148 struct tsocket_address *dest_addr; 149 int ret; 150 151 ret = tsocket_address_inet_from_strings(tctx, "ip", 152 address, 153 lpcfg_cldap_port(tctx->lp_ctx), 154 &dest_addr); 155 CHECK_VAL(ret, 0); 151 156 152 157 /* cldap_socket_init should now know about the dest. address */ 153 status = cldap_socket_init(tctx, tctx->ev, NULL, NULL, &cldap);158 status = cldap_socket_init(tctx, tctx->ev, NULL, dest_addr, &cldap); 154 159 torture_assert_ntstatus_ok(tctx, status, "cldap_socket_init"); 155 160 … … 157 162 158 163 ZERO_STRUCT(search); 159 search.in.dest_address = address;160 search.in.dest_port = lp_cldap_port(tctx->lp_ctx);164 search.in.dest_address = NULL; 165 search.in.dest_port = 0; 161 166 search.in.filter = "(objectClass=*)"; 162 167 search.in.timeout = 2; … … 211 216 212 217 /* do an initial name resolution to find its IP */ 213 status = resolve_name(lp _resolve_context(torture->lp_ctx), &name, torture, &address, torture->ev);218 status = resolve_name(lpcfg_resolve_context(torture->lp_ctx), &name, torture, &address, torture->ev); 214 219 if (!NT_STATUS_IS_OK(status)) { 215 220 printf("Failed to resolve %s - %s\n", -
trunk/server/source4/torture/ldap/common.c
r414 r745 97 97 NTSTATUS torture_ldap_close(struct ldap_connection *conn) 98 98 { 99 struct ldap_message *msg; 100 struct ldap_request *req; 101 NTSTATUS status; 102 103 printf("Testing the most important error code -> error message conversions!\n"); 104 105 msg = new_ldap_message(conn); 106 if (!msg) { 107 talloc_free(conn); 108 return NT_STATUS_NO_MEMORY; 109 } 110 111 printf(" Try a AbandonRequest for an old message id\n"); 112 113 msg->type = LDAP_TAG_UnbindRequest; 114 115 req = ldap_request_send(conn, msg); 116 if (!req) { 117 talloc_free(conn); 118 return NT_STATUS_NO_MEMORY; 119 } 120 121 status = ldap_request_wait(req); 122 if (!NT_STATUS_IS_OK(status)) { 123 printf("error in ldap unbind request - %s\n", nt_errstr(status)); 124 talloc_free(conn); 125 return status; 126 } 127 99 128 talloc_free(conn); 100 129 return NT_STATUS_OK; … … 103 132 NTSTATUS torture_ldap_init(void) 104 133 { 105 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "LDAP"); 106 torture_suite_add_simple_test(suite, "BENCH-CLDAP", torture_bench_cldap); 107 torture_suite_add_simple_test(suite, "BASIC", torture_ldap_basic); 108 torture_suite_add_simple_test(suite, "SORT", torture_ldap_sort); 109 torture_suite_add_simple_test(suite, "CLDAP", torture_cldap); 110 torture_suite_add_simple_test(suite, "SCHEMA", torture_ldap_schema); 111 torture_suite_add_simple_test(suite, "UPTODATEVECTOR", torture_ldap_uptodatevector); 134 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ldap"); 135 torture_suite_add_simple_test(suite, "bench-cldap", torture_bench_cldap); 136 torture_suite_add_simple_test(suite, "basic", torture_ldap_basic); 137 torture_suite_add_simple_test(suite, "sort", torture_ldap_sort); 138 torture_suite_add_simple_test(suite, "cldap", torture_cldap); 139 torture_suite_add_simple_test(suite, "schema", torture_ldap_schema); 140 torture_suite_add_simple_test(suite, "uptodatevector", torture_ldap_uptodatevector); 141 torture_suite_add_simple_test(suite, "nested-search", test_ldap_nested_search); 112 142 113 143 suite->description = talloc_strdup(suite, "LDAP and CLDAP tests"); -
trunk/server/source4/torture/ldap/ldap_sort.c
r414 r745 23 23 #include "includes.h" 24 24 #include "lib/events/events.h" 25 #include "lib/ldb/include/ldb.h"26 #include "lib/ldb/include/ldb_errors.h"25 #include <ldb.h> 26 #include <ldb_errors.h> 27 27 #include "ldb_wrap.h" 28 28 #include "param/param.h" … … 31 31 #include "torture/local/proto.h" 32 32 #include <ctype.h> 33 33 34 bool torture_ldap_sort(struct torture_context *torture) 34 35 { 35 36 36 struct ldb_context *ldb; 37 37 … … 47 47 struct ldb_request *req; 48 48 struct ldb_result *ctx; 49 struct ldb_val *prev = NULL;49 struct ldb_val *prev = NULL; 50 50 const char *prev_txt = NULL; 51 51 int prev_len = 0; 52 struct ldb_val *cur = NULL;52 struct ldb_val *cur = NULL; 53 53 const char *cur_txt = NULL; 54 54 int cur_len = 0; 55 struct ldb_dn *dn;55 struct ldb_dn *dn; 56 56 57 57 … … 63 63 NULL, 64 64 cmdline_credentials, 65 0 , NULL);65 0); 66 66 torture_assert(torture, ldb, "Failed to make LDB connection to target"); 67 67 … … 75 75 control[1] = NULL; 76 76 77 dn = ldb_get_ root_basedn(ldb);77 dn = ldb_get_default_basedn(ldb); 78 78 ldb_dn_add_child_fmt(dn, "cn=users"); 79 79 ret = ldb_build_search_req(&req, ldb, ctx, … … 104 104 { 105 105 /* Do only the ascii case right now ... */ 106 cur_txt =cur->data;107 cur_len =cur->length;108 prev_txt =prev->data;109 prev_len =prev->length;106 cur_txt = (const char *) cur->data; 107 cur_len = cur->length; 108 prev_txt = (const char *) prev->data; 109 prev_len = prev->length; 110 110 /* Remove leading whitespace as the sort function do so ... */ 111 111 while ( cur_txt[0] == cur_txt[1] ) { cur_txt++; cur_len--;} -
trunk/server/source4/torture/ldap/schema.c
r414 r745 24 24 #include "lib/cmdline/popt_common.h" 25 25 #include "ldb_wrap.h" 26 #include "lib/ldb/include/ldb.h"27 #include "lib/ldb/include/ldb_errors.h"28 26 #include "dsdb/samdb/samdb.h" 29 27 #include "../lib/util/dlinklist.h" 30 28 31 29 #include "torture/torture.h" 32 #include "torture/ldap/proto.h" 33 34 #include "param/param.h" 30 35 31 36 32 struct test_rootDSE { … … 216 212 { 217 213 struct dsdb_schema *schema = talloc_get_type(ptr, struct dsdb_schema); 218 struct dsdb_attribute *attr = NULL;219 214 WERROR status; 220 215 221 attr = talloc_zero(schema, struct dsdb_attribute); 222 if (!attr) { 223 goto failed; 224 } 225 226 status = dsdb_attribute_from_ldb(ldb, schema, msg, attr, attr); 216 status = dsdb_attribute_from_ldb(ldb, schema, msg); 227 217 if (!W_ERROR_IS_OK(status)) { 228 218 goto failed; 229 219 } 230 220 231 DLIST_ADD_END(schema->attributes, attr, struct dsdb_attribute *);232 221 return LDB_SUCCESS; 233 222 failed: 234 talloc_free(attr);235 223 return LDB_ERR_OTHER; 236 224 } … … 239 227 { 240 228 struct dsdb_schema *schema = talloc_get_type(ptr, struct dsdb_schema); 241 struct dsdb_class *obj;242 229 WERROR status; 243 230 244 obj = talloc_zero(schema, struct dsdb_class); 245 if (!obj) { 246 goto failed; 247 } 248 249 status = dsdb_class_from_ldb(schema, msg, obj, obj); 231 status = dsdb_class_from_ldb(schema, msg); 250 232 if (!W_ERROR_IS_OK(status)) { 251 233 goto failed; 252 234 } 253 235 254 DLIST_ADD_END(schema->classes, obj, struct dsdb_class *);255 236 return LDB_SUCCESS; 256 237 failed: … … 361 342 if (strcmp(syntaxes[i], a->attributeSyntax_oid) != 0) continue; 362 343 363 om_hex = data_blob_hex_string (ldb, &a->oMObjectClass);344 om_hex = data_blob_hex_string_upper(ldb, &a->oMObjectClass); 364 345 if (!om_hex) { 365 346 return false; … … 373 354 } 374 355 356 return true; 357 } 358 359 static bool test_dump_not_in_filtered_replica(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) 360 { 361 struct dsdb_attribute *a; 362 uint32_t a_i = 1; 363 364 d_printf("Dumping attributes not in filtered replica\n"); 365 366 for (a=schema->attributes; a; a = a->next) { 367 if (!dsdb_attribute_is_attr_in_filtered_replica(a)) { 368 d_printf("attr[%4u]: '%s'\n", a_i++, 369 a->lDAPDisplayName); 370 } 371 } 375 372 return true; 376 373 } … … 392 389 NULL, 393 390 cmdline_credentials, 394 0 , NULL);391 0); 395 392 if (!ldb) goto failed; 396 393 … … 404 401 ret &= test_dump_contructed(ldb, &rootDSE, schema); 405 402 ret &= test_dump_sorted_syntax(ldb, &rootDSE, schema); 403 ret &= test_dump_not_in_filtered_replica(ldb, &rootDSE, schema); 406 404 407 405 failed: -
trunk/server/source4/torture/ldap/uptodatevector.c
r414 r745 24 24 #include "lib/cmdline/popt_common.h" 25 25 #include "ldb_wrap.h" 26 #include "lib/ldb/include/ldb.h"27 #include "lib/ldb/include/ldb_errors.h"28 26 #include "dsdb/samdb/samdb.h" 29 #include "../lib/util/dlinklist.h"30 27 31 28 #include "torture/torture.h" 32 #include "torture/ldap/proto.h"33 29 34 #include "librpc/ndr/libndr.h"35 30 #include "librpc/gen_ndr/ndr_drsblobs.h" 36 31 … … 71 66 if (utdv_val1) { 72 67 ndr_err = ndr_pull_struct_blob_all(utdv_val1, torture, 73 lp_iconv_convenience(torture->lp_ctx),&utdv1,68 &utdv1, 74 69 (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); 75 70 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 117 112 if (utdv_val) { 118 113 ndr_err = ndr_pull_struct_blob_all(utdv_val, torture, 119 lp_iconv_convenience(torture->lp_ctx),&utdv,114 &utdv, 120 115 (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); 121 116 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 136 131 137 132 torture_comment(torture, "[%u]: uSNChanged[%llu] description[%s] replUpToDateVector[%s]\n", i, 138 (unsigned long long) samdb_result_uint64(r->msgs[0], "uSNChanged", 0),139 samdb_result_string(r->msgs[0], "description", NULL),133 (unsigned long long)ldb_msg_find_attr_as_uint64(r->msgs[0], "uSNChanged", 0), 134 ldb_msg_find_attr_as_string(r->msgs[0], "description", NULL), 140 135 (no_match ? "changed!: not ok" : "not changed: ok")); 141 136 … … 165 160 NULL, 166 161 cmdline_credentials, 167 0 , NULL);162 0); 168 163 if (!ldb) goto failed; 169 164 170 ret &= test_check_uptodatevector(torture, ldb, samdb_base_dn(ldb));171 ret &= test_check_uptodatevector(torture, ldb, samdb_config_dn(ldb));172 ret &= test_check_uptodatevector(torture, ldb, samdb_schema_dn(ldb));165 ret &= test_check_uptodatevector(torture, ldb, ldb_get_default_basedn(ldb)); 166 ret &= test_check_uptodatevector(torture, ldb, ldb_get_config_basedn(ldb)); 167 ret &= test_check_uptodatevector(torture, ldb, ldb_get_schema_basedn(ldb)); 173 168 174 169 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.