[PATCH] Re: 3.0a21: "net ads lookup" for a child domain gotmessy output

Anthony Liguori aliguor at us.ibm.com
Mon Feb 24 21:25:17 GMT 2003





The 0xc018 and 0xc022 are most likely string deliminators and a one byte
flag.  This makes sense since it always seems to be either 0xc018 or 0xc022
(0xc022 == 0xc018 | 0x04)  What the meaning of these flags is remains to be
seen.

The net ads lookup code is really out of date anyway.  I've construct a
patch that reworks most of the parsing such and I think we're at a point
where every field we have a least a pretty good guess as to what it is.

I'll submit the patch once I get an opportunity to test it.

Anthony Liguori
Linux/Active Directory Interoperability
Linux Technology Center (LTC) - IBM Austin
E-mail: aliguor at us.ibm.com
Phone: (512) 838-1208
Tie Line: 678-1208


                                                                                                           
                      Chere Zhou                                                                           
                      <qzhou at isilon.com        To:       Anthony Liguori/Austin/IBM at IBMUS                  
                      >                        cc:       samba-technical at lists.samba.org                   
                                               Subject:  [PATCH] Re: 3.0a21: "net ads lookup" for a child  
                      02/24/2003 02:00          domain got messy output                                    
                      PM                                                                                   
                      Please respond to                                                                    
                      qzhou                                                                                
                                                                                                           
                                                                                                           



With the following patch, it works for me now.   However, there are still
mysteries like what 0xc018 and 0xc022 means in the received netlogon
responses.  My fix is to split the "domain" into "forest" and "domain",
where
the new "domain" is the child/grandchild under "forest".  The ultimate
domain
name should be domain+'.'+forest.

Even if this does not go into the sources eventually, I hope it can be
helpful for other people who had the same problem as I did.

Chere


--- utils/net_ads_cldap.c.orig  Fri Feb 21 15:34:18 2003
+++ utils/net_ads_cldap.c       Mon Feb 24 11:27:47 2003
@@ -27,6 +27,7 @@
        uint32 version;
        uint32 flags;
        GUID guid;
+        char *forest;
        char *domain;
        char *server_name;
        char *domain_flatname;
@@ -42,11 +43,13 @@
 */
 static unsigned pull_len_string(char **ret, const char *p)
 {
-       unsigned len = *p;
+       unsigned char len = *p;
        (*ret) = NULL;
        if (len == 0) return 1;
+       if ((len == 0xc0) && ((unsigned char)(*(p+1)) == 0x18))
+               return 1;
        (*ret) = smb_xstrndup(p+1, len);
-       return len+1;
+       return (unsigned)(len+1);
 }

 /*
@@ -194,8 +197,13 @@
        reply->flags = IVAL(p, 0); p += 4;
        memcpy(&reply->guid.info, p, GUID_SIZE);
        p += GUID_SIZE;
-       p += pull_dotted_string(&reply->domain, p);
-       p += 2; /* 0xc018 - whats this? */
+       p += pull_dotted_string(&reply->forest, p);
+       if ((unsigned char)*p == 0xc0)
+               p += 2; /* 0xc018 - whats this? */
+       else {
+               p += pull_dotted_string(&reply->domain, p);
+               p += 1;
+       }
        p += pull_len_string(&reply->server_name, p);
        p += 2; /* 0xc018 - whats this? */
        p += pull_len_string(&reply->domain_flatname, p);
@@ -218,6 +226,7 @@
 */
 static void cldap_reply_free(struct cldap_netlogon_reply *reply)
 {
+       SAFE_FREE(reply->forest);
        SAFE_FREE(reply->domain);
        SAFE_FREE(reply->server_name);
        SAFE_FREE(reply->domain_flatname);
@@ -258,6 +267,7 @@
        d_printf("GUID: ");
        print_guid(&reply.guid);
        d_printf("Flags:   0x%x\n", reply.flags);
+       d_printf("Forest root: %s\n", reply.forest);
        d_printf("Domain: %s\n", reply.domain);
        d_printf("Server Name: %s\n", reply.server_name);
        d_printf("Flatname: %s\n", reply.domain_flatname);





More information about the samba-technical mailing list