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

Chere Zhou qzhou at isilon.com
Mon Feb 24 20:00:28 GMT 2003


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