Author: brad
Date: 2005-07-30 01:20:33 +0000 (Sat, 30 Jul 2005)
New Revision: 8856

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8856

Log:
I think I have the ldb code down in test_CompleteJoin (not complete yet though)
Modified:
   branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c


Changeset:
Modified: branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c
===================================================================
--- branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c  2005-07-30 00:14:48 UTC 
(rev 8855)
+++ branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c  2005-07-30 01:20:33 UTC 
(rev 8856)
@@ -321,12 +321,8 @@
 static BOOL test_CompleteJoin(struct DsSyncTest *ctx)
 {
        NTSTATUS status;
-       //const char *ldif;
-       // * struct ldap_message *req, *rep;
        BOOL ret = True;
        int rtn;
-       //struct ldb_message *ldb_msg;
-       //struct ldb_ldif *ldb_req;
        
        rtn = ldb_connect(ctx->ldb_ctx,ctx->ldap_url,0,NULL);
        if (rtn != 0) {
@@ -346,33 +342,23 @@
        //      "userAccountControl: %u\n",
        //      ctx->new_dc.dc_info2.computer_dn,
        //      UF_SERVER_TRUST_ACCOUNT|UF_TRUSTED_FOR_DELEGATION);
-       //printf("dn: %s.\n",ctx->new_dc.dc_info2.computer_dn);
-       //ldb_req = ldb_ldif_read_string(ldb_ctx,&ldif);        
-       // * req = ldap_ldif2msg(ctx, ldif);
-       // * req->type = LDAP_TAG_ModifyRequest;
-       // * req->r.ModifyRequest.dn = ctx->new_dc.dc_info2.computer_dn;
-       // * req->r.ModifyRequest.num_mods = 1;
-       // * req->r.ModifyRequest.mods->type = LDAP_MODIFY_REPLACE;
-       // * req->r.ModifyRequest.mods->attrib.flags = LDB_FLAG_MOD_REPLACE;
-       // * req->r.ModifyRequest.mods->attrib.name = "userAccountControl";
-       // * req->r.ModifyRequest.mods->attrib.num_values = 1;
-       // * req->r.ModifyRequest.mods->attrib.values->data = 
UF_SERVER_TRUST_ACCOUNT|UF_TRUSTED_FOR_DELEGATION;
-       // * req->r.ModifyRequest.mods->attrib.values->length = 
sizeof(req->r.ModifyRequest.mods->attrib.values->data);
        
 // = UF_SERVER_TRUST_ACCOUNT|UF_TRUSTED_FOR_DELEGATION;        
+
+       ctx->ldb_msg = ldb_msg_new(ctx);
+       
ldb_msg_add_fmt(ctx->ldb_ctx,ctx->ldb_msg,"userAccountControl","%u",UF_SERVER_TRUST_ACCOUNT|UF_TRUSTED_FOR_DELEGATION);
 
        ctx->ldb_msg->dn = ctx->new_dc.dc_info2.computer_dn;
-       ctx->ldb_msg->num_elements = 1;
        ctx->ldb_msg->elements->flags = LDB_FLAG_MOD_REPLACE;
-       ctx->ldb_msg->elements->name = "userAccountControl";
-       ctx->ldb_msg->elements->num_values = 1;
-       ctx->ldb_msg->elements->values->data = 
UF_SERVER_TRUST_ACCOUNT|UF_TRUSTED_FOR_DELEGATION;
-       
+
        rtn = ldb_modify(ctx->ldb_ctx,ctx->ldb_msg);
        if (rtn != 0) {
                printf("test_CompleteJoin() ldb_modify() failed: %s.\n",
                 ldb_errstring(ctx->ldb_ctx));
                return False;
        }
+       printf("ldb_modify() succeeded.\n");
+       ldb_msg_free(ctx->ldb_ctx,ctx->ldb_msg);
+
        // * rtn = ldap_transaction(ctx->admin.ldap.conn, req);
 
        /* add entry CN=<NETBIOSNAME>,CN=Servers
@@ -392,7 +378,9 @@
                ctx->new_dc.dc_info2.computer_dn);      
        ldb_req = ldb_ldif_read_string(ldb_ctx,&ldif);  
        */
+
        printf("dn: %s\nserverReference: 
%s.\n",ctx->new_dc.dc_info2.server_dn,ctx->new_dc.dc_info2.computer_dn);
+
 // *   req = ldap_ldif2msg(ctx, ldif);
 // *   req->type = LDAP_TAG_AddRequest;
 // *   req.r.AddRequest.dn = ctx->new_dc.dc_info2.server_dn;
@@ -412,15 +400,22 @@
 // *   req.r.AddRequest.attributes.name = 'serverReference';
 // *   req.r.AddRequest.attributes.num_values = 1;
 // *   req.r.AddRequest.attributes.values = ctx->new_dc.dc_info2.computer_dn;
-       printf("test\n");
+
        //rtn = ldb_modify(ldb_ctx,ldb_req->msg);
+       ctx->ldb_msg = ldb_msg_new(ctx);
+       ldb_msg_add_string(ctx->ldb_ctx,ctx->ldb_msg,"objectClass","server");
+       ldb_msg_add_string(ctx->ldb_ctx,ctx->ldb_msg,"systemFlags","50000000");
+       
ldb_msg_add_string(ctx->ldb_ctx,ctx->ldb_msg,"serverReference",ctx->new_dc.dc_info2.computer_dn);
+       ctx->ldb_msg->dn = ctx->new_dc.dc_info2.server_dn;
+       ctx->ldb_msg->elements->flags = LDB_FLAG_MOD_REPLACE;
+       
        rtn = ldb_add(ctx->ldb_ctx,ctx->ldb_msg);
        if (rtn != 0) {
                printf("test_CompleteJoin(): ldb_add() failed: %s.\n",
                 ldb_errstring(ctx->ldb_ctx));
                return False;
        }
-       printf("test2\n");
+       printf("ldb_add() succeeded.\n");
        // rtn = ldap_transaction(ctx->admin.ldap.conn, req);
 
        /* add entry CN=NTDS Settings
@@ -805,11 +800,13 @@
        
        mem_ctx = talloc_init("torture_rpc_dssync");
        ctx = test_create_context(mem_ctx);
+       ctx->ldb_ctx = ldb_init(mem_ctx);
+       //ctx->ldb_msg = talloc_init("ldb_message");
        
 //     url = talloc_asprintf(mem_ctx, "ldap://%s/",host);
 
 // ldb method  
-       ctx->ldb_ctx = ldb_init(mem_ctx);
+       
        //printf("ctx->ldap_url: %s.\n",ctx->ldap_url);
        rtn = ldb_connect(ctx->ldb_ctx,ctx->ldap_url,0,NULL);
        printf("Connected to %s.\n",ctx->ldap_url);

Reply via email to