The branch, master has been updated
       via  1fd7c28 Extend DsBind and DsGetDomainControllerInfo to work with 
w2k8.
       via  6ded4f5 drsuapi tests for DsBind with w2k8
      from  bc3fcb2 s3: docs: Add documentation for posix_whoami command in 
smbclient.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1fd7c28d5fb575e75b5085e8589aef2525c8e784
Author: Dirk Godau <voidswi...@gmail.com>
Date:   Wed May 25 11:49:24 2016 +1200

    Extend DsBind and DsGetDomainControllerInfo to work with w2k8.
    
    W2K8 Clients ask for DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2 on DsBind. W2K8
    expect this to be set (with server fl 2k8) or else they do not call
    DsGetDomainControllerInfo.
    
    If DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2 is set, DsGetDomainControllerInfo
    must be able to return DCInfo Level 3.
    
    If Samba4 AD ist set to work as 2k8, with >2k8 clients the following
    will not work as expected:
    
      * Group Policy Editor Infrastructure Discovery
      * nltest /dclist:<domain>
      * w32tm /monitor
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=9971
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=9976
    
    Signed-off-by: Dirk Godau <voidswi...@gmail.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Garming Sam <garm...@catalyst.net.nz>
    
    Autobuild-User(master): Douglas Bagnall <dbagn...@samba.org>
    Autobuild-Date(master): Thu May 26 06:21:10 CEST 2016 on sn-devel-144

commit 6ded4f52302d5f2c127d94c9853fcc0df1017ee7
Author: Dirk Godau <voidswi...@gmail.com>
Date:   Wed May 25 11:50:09 2016 +1200

    drsuapi tests for DsBind with w2k8
    
    These are marked as known_fail pending the next patch ("Extend DsBind
    and DsGetDomainControllerInfo to work with w2k8").
    
    Signed-off-by: Dirk Godau <voidswi...@gmail.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Garming Sam <garm...@catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 source4/rpc_server/drsuapi/dcesrv_drsuapi.c | 266 +++++++++++++++++-----
 source4/rpc_server/drsuapi/dcesrv_drsuapi.h |   4 +-
 source4/selftest/tests.py                   |   2 +-
 source4/torture/rpc/drsuapi.h               |  18 ++
 source4/torture/rpc/drsuapi_w2k8.c          | 334 ++++++++++++++++++++++++++++
 source4/torture/rpc/rpc.c                   |   1 +
 source4/torture/wscript_build               |   1 +
 7 files changed, 565 insertions(+), 61 deletions(-)
 create mode 100644 source4/torture/rpc/drsuapi_w2k8.c


Changeset truncated at 500 lines:

diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c 
b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
index 3fe6c13..949dea8 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
@@ -56,15 +56,19 @@ static WERROR dcesrv_drsuapi_DsBind(struct 
dcesrv_call_state *dce_call, TALLOC_C
        struct drsuapi_bind_state *b_state;
        struct dcesrv_handle *handle;
        struct drsuapi_DsBindInfoCtr *bind_info;
-       struct GUID site_guid;
-       struct ldb_result *site_res;
-       struct ldb_dn *server_site_dn;
+       struct drsuapi_DsBindInfoCtr *local_info;
+       struct GUID site_guid, config_guid;
+       struct ldb_result *site_res, *config_res;
+       struct ldb_dn *server_site_dn, *config_dn;
        static const char *site_attrs[] = { "objectGUID", NULL };
+       static const char *config_attrs[] = { "objectGUID", NULL };
        struct ldb_result *ntds_res;
        struct ldb_dn *ntds_dn;
        static const char *ntds_attrs[] = { "ms-DS-ReplicationEpoch", NULL };
        uint32_t pid;
        uint32_t repl_epoch;
+       uint32_t supported_extensions;
+       uint32_t req_length;
        int ret;
        struct auth_session_info *auth_info;
        WERROR werr;
@@ -166,73 +170,112 @@ static WERROR dcesrv_drsuapi_DsBind(struct 
dcesrv_call_state *dce_call, TALLOC_C
         * store the clients bind_info
         */
        if (r->in.bind_info) {
-               switch (r->in.bind_info->length) {
-               case 24: {
-                       struct drsuapi_DsBindInfo24 *info24;
-                       info24 = &r->in.bind_info->info.info24;
-                       b_state->remote_info28.supported_extensions     = 
info24->supported_extensions;
-                       b_state->remote_info28.site_guid                = 
info24->site_guid;
-                       b_state->remote_info28.pid                      = 
info24->pid;
-                       b_state->remote_info28.repl_epoch               = 0;
-                       break;
-               }
-               case 28:
-                       b_state->remote_info28 = r->in.bind_info->info.info28;
-                       break;
-               }
+               b_state->remote_info = r->in.bind_info;
        }
 
        /*
-        * fill in our local bind info 28
+        * fill in our local bind info
+        */
+       local_info = talloc_zero(mem_ctx, struct drsuapi_DsBindInfoCtr);
+       W_ERROR_HAVE_NO_MEMORY(local_info);
+
+       /*
+        * Fill in supported extensions
         */
-       b_state->local_info28.supported_extensions      = 0;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_BASE;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
+       supported_extensions = 0;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
 #if 0 /* we don't support MSZIP compression (only decompression) */
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
 #endif
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
+       supported_extensions |= 
DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
+       supported_extensions |= 
DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
+       supported_extensions |= 
DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
+       supported_extensions |= 
DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
 #if 0 /* we don't support XPRESS compression yet */
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
 #endif
-       b_state->local_info28.supported_extensions      |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10;
-       b_state->local_info28.site_guid                 = site_guid;
-       b_state->local_info28.pid                       = pid;
-       b_state->local_info28.repl_epoch                = repl_epoch;
+       supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10;
+
+       /*
+        * There is a chance for r->in.bind_info == NULL
+        * Currently we don't care, since it seems to be used nowhere else.
+        * But we need a request length. So use 28 as default.
+        */
+       req_length = 28;
+       if (r->in.bind_info) {
+               req_length = r->in.bind_info->length;
+       }
+
+       /*
+        * fill 28 or 48 info, depends on request
+        */
+       if (req_length < 48) {
+               local_info->length = 28;
+               local_info->info.info28.supported_extensions = 
supported_extensions;
+               local_info->info.info28.site_guid = site_guid;
+               local_info->info.info28.pid = pid;
+               local_info->info.info28.repl_epoch = repl_epoch;
+       } else {
+               local_info->length = 48;
+               local_info->info.info48.supported_extensions = 
supported_extensions;
+               local_info->info.info48.site_guid = site_guid;
+               local_info->info.info48.pid = pid;
+               local_info->info.info48.repl_epoch = repl_epoch;
+
+               local_info->info.info48.supported_extensions_ext = 0;
+               local_info->info.info48.supported_extensions_ext |= 
DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2;
+
+               /*
+                * find out the guid of our own site
+                */
+               config_dn = ldb_get_config_basedn(b_state->sam_ctx);
+               W_ERROR_HAVE_NO_MEMORY(config_dn);
+
+               ret = ldb_search(b_state->sam_ctx, mem_ctx, &config_res,
+                            config_dn, LDB_SCOPE_BASE, config_attrs,
+                            "(objectClass=*)");
+               if (ret != LDB_SUCCESS) {
+                       return WERR_DS_DRA_INTERNAL_ERROR;
+               }
+               if (config_res->count != 1) {
+                       return WERR_DS_DRA_INTERNAL_ERROR;
+               }
+               config_guid = samdb_result_guid(config_res->msgs[0], 
"objectGUID");
+               local_info->info.info48.config_dn_guid = config_guid;
+       }
 
        /*
-        * allocate the return bind_info
+        * set local_info
         */
-       bind_info = talloc_zero(mem_ctx, struct drsuapi_DsBindInfoCtr);
-       W_ERROR_HAVE_NO_MEMORY(bind_info);
+       b_state->local_info = local_info;
 
-       bind_info->length       = 28;
-       bind_info->info.info28  = b_state->local_info28;
+       /*
+        * set bind_info
+        */
+       bind_info = local_info;
 
        /*
         * allocate a bind handle
@@ -580,6 +623,7 @@ static WERROR 
dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
 
        struct drsuapi_DsGetDCInfoCtr1 *ctr1;
        struct drsuapi_DsGetDCInfoCtr2 *ctr2;
+       struct drsuapi_DsGetDCInfoCtr3 *ctr3;
 
        int ret;
        unsigned int i;
@@ -596,6 +640,7 @@ static WERROR 
dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
                attrs = attrs_1;
                break;
        case 2:
+       case 3:
                attrs = attrs_2;
                break;
        default:
@@ -781,6 +826,111 @@ static WERROR 
dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
 
                }
                break;
+       case 3:
+               ctr3 = &r->out.ctr->ctr3;
+               ctr3->count = res->count;
+               ctr3->array = talloc_zero_array(mem_ctx,
+                                                struct drsuapi_DsGetDCInfo3,
+                                                res->count);
+               for (i=0; i<res->count; i++) {
+                       struct ldb_dn *domain_dn;
+                       struct ldb_result *res_domain;
+                       struct ldb_result *res_account;
+                       struct ldb_dn *ntds_dn = ldb_dn_copy(mem_ctx, 
res->msgs[i]->dn);
+                       struct ldb_result *res_ntds;
+                       struct ldb_dn *site_dn = ldb_dn_copy(mem_ctx, 
res->msgs[i]->dn);
+                       struct ldb_result *res_site;
+                       bool is_rodc;
+                       struct ldb_dn *ref_dn
+                               = ldb_msg_find_attr_as_dn(b_state->sam_ctx,
+                                                         mem_ctx, res->msgs[i],
+                                                         "serverReference");
+
+                       if (!ntds_dn || !ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS 
Settings")) {
+                               return WERR_NOMEM;
+                       }
+
+                       /* Format is cn=<NETBIOS 
name>,cn=Servers,cn=<site>,cn=sites.... */
+                       if (!site_dn || 
!ldb_dn_remove_child_components(site_dn, 2)) {
+                               return WERR_NOMEM;
+                       }
+
+                       ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_ntds, 
ntds_dn,
+                                                LDB_SCOPE_BASE, attrs_ntds, 
"objectClass=nTDSDSA");
+                       if (ret == LDB_SUCCESS && res_ntds->count == 1) {
+                               ctr3->array[i].is_gc
+                                       = 
(ldb_msg_find_attr_as_uint(res_ntds->msgs[0], "options", 0) & 
DS_NTDSDSA_OPT_IS_GC);
+                               ctr3->array[i].ntds_guid
+                                       = samdb_result_guid(res_ntds->msgs[0], 
"objectGUID");
+                               ctr3->array[i].ntds_dn = 
ldb_dn_get_linearized(res_ntds->msgs[0]->dn);
+                       }
+                       if ((ret != LDB_SUCCESS) && (ret != 
LDB_ERR_NO_SUCH_OBJECT)) {
+                               DEBUG(5, ("warning: searching for NTDS DN %s 
failed: %s\n",
+                                         ldb_dn_get_linearized(ntds_dn), 
ldb_errstring(b_state->sam_ctx)));
+                       }
+
+                       ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_site, 
site_dn,
+                                                LDB_SCOPE_BASE, attrs_site, 
"objectClass=site");
+                       if (ret == LDB_SUCCESS && res_site->count == 1) {
+                               ctr3->array[i].site_guid
+                                       = samdb_result_guid(res_site->msgs[0], 
"objectGUID");
+                               ctr3->array[i].site_dn = 
ldb_dn_get_linearized(res_site->msgs[0]->dn);
+                       }
+                       if ((ret != LDB_SUCCESS) && (ret != 
LDB_ERR_NO_SUCH_OBJECT)) {
+                               DEBUG(5, ("warning: searching for site DN %s 
failed: %s\n",
+                                         ldb_dn_get_linearized(site_dn), 
ldb_errstring(b_state->sam_ctx)));
+                       }
+
+                       ret = ldb_search(b_state->sam_ctx, mem_ctx, 
&res_account, ref_dn,
+                                                LDB_SCOPE_BASE, 
attrs_account_2, "objectClass=computer");
+                       if (ret == LDB_SUCCESS && res_account->count == 1) {
+                               const char *errstr;
+                               ctr3->array[i].dns_name
+                                       = 
ldb_msg_find_attr_as_string(res_account->msgs[0], "dNSHostName", NULL);
+                               ctr3->array[i].netbios_name
+                                       = 
ldb_msg_find_attr_as_string(res_account->msgs[0], "cn", NULL);
+                               ctr3->array[i].computer_dn = 
ldb_dn_get_linearized(res_account->msgs[0]->dn);
+                               ctr3->array[i].computer_guid
+                                       = 
samdb_result_guid(res_account->msgs[0], "objectGUID");
+
+                               /* Determine if this is the PDC */
+                               ret = 
samdb_search_for_parent_domain(b_state->sam_ctx,
+                                                                    mem_ctx, 
res_account->msgs[0]->dn,
+                                                                    
&domain_dn, &errstr);
+
+                               if (ret == LDB_SUCCESS) {
+                                       ret = ldb_search(b_state->sam_ctx, 
mem_ctx, &res_domain, domain_dn,
+                                                                
LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
+                                                                
ldb_dn_get_linearized(ntds_dn));
+                                       if (ret == LDB_SUCCESS && 
res_domain->count == 1) {
+                                               ctr3->array[i].is_pdc = true;
+                                       }
+                                       if ((ret != LDB_SUCCESS) && (ret != 
LDB_ERR_NO_SUCH_OBJECT)) {
+                                               DEBUG(5, ("warning: searching 
for domain DN %s failed: %s\n",
+                                                         
ldb_dn_get_linearized(domain_dn), ldb_errstring(b_state->sam_ctx)));
+                                       }
+                               }
+                       }
+                       if ((ret != LDB_SUCCESS) && (ret != 
LDB_ERR_NO_SUCH_OBJECT)) {
+                               DEBUG(5, ("warning: searching for computer 
account DN %s failed: %s\n",
+                                         ldb_dn_get_linearized(ref_dn), 
ldb_errstring(b_state->sam_ctx)));
+                       }
+
+                       /* Look at server DN and extract site component */
+                       ctr3->array[i].site_name = 
result_site_name(res->msgs[i]->dn);
+                       ctr3->array[i].server_dn = 
ldb_dn_get_linearized(res->msgs[i]->dn);
+                       ctr3->array[i].server_guid
+                               = samdb_result_guid(res->msgs[i], "objectGUID");
+
+                       ctr3->array[i].is_enabled = true;
+
+                       /* rodc? */
+                       ret = samdb_is_rodc(b_state->sam_ctx, 
&ctr3->array[i].server_guid, &is_rodc);
+                       if (ret == LDB_SUCCESS && is_rodc) {
+                               ctr3->array[i].is_rodc = true;
+                       }
+               }
+               break;
        default:
                return WERR_UNKNOWN_LEVEL;
        }
diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h 
b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
index 49d1d42..d376f7e 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
@@ -33,8 +33,8 @@ struct drsuapi_bind_state {
        struct ldb_context *sam_ctx;
        struct ldb_context *sam_ctx_system;
        struct GUID remote_bind_guid;
-       struct drsuapi_DsBindInfo28 remote_info28;
-       struct drsuapi_DsBindInfo28 local_info28;
+       struct drsuapi_DsBindInfoCtr *remote_info;
+       struct drsuapi_DsBindInfoCtr *local_info;
        struct drsuapi_getncchanges_state *getncchanges_state;
 };
 
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 15e7d19..fb66af9 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -147,7 +147,7 @@ else:
 ncacn_np_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", 
"rpc.altercontext", "rpc.netlogon", "rpc.netlogon.admin", "rpc.handles", 
"rpc.samsync", "rpc.samba3-sessionkey", "rpc.samba3-getusername", 
"rpc.samba3-lsa", "rpc.samba3-bind", "rpc.samba3-netlogon", "rpc.asyncbind", 
"rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext"]
 ncalrpc_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", 
"rpc.altercontext", "rpc.netlogon", "rpc.netlogon.admin", "rpc.asyncbind", 
"rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext"]
 drs_rpc_tests = smbtorture4_testsuites("drs.rpc")
-ncacn_ip_tcp_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", 
"rpc.drsuapi", "rpc.netlogon", "rpc.netlogon.admin", "rpc.asyncbind", 
"rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext", 
"rpc.samr.passwords.validate"] + drs_rpc_tests
+ncacn_ip_tcp_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", 
"rpc.drsuapi", "rpc.drsuapi_w2k8", "rpc.netlogon", "rpc.netlogon.admin", 
"rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", 
"rpc.authcontext", "rpc.samr.passwords.validate"] + drs_rpc_tests
 slow_ncacn_np_tests = ["rpc.samlogon", "rpc.samr", "rpc.samr.users", 
"rpc.samr.large-dc", "rpc.samr.users.privileges", "rpc.samr.passwords", 
"rpc.samr.passwords.pwdlastset", "rpc.samr.passwords.lockout", 
"rpc.samr.passwords.badpwdcount"]
 slow_ncacn_ip_tcp_tests = ["rpc.cracknames"]
 
diff --git a/source4/torture/rpc/drsuapi.h b/source4/torture/rpc/drsuapi.h
index 6ce3009..f1a5bba 100644
--- a/source4/torture/rpc/drsuapi.h
+++ b/source4/torture/rpc/drsuapi.h
@@ -40,6 +40,24 @@ struct DsPrivate {
        struct test_join *join;
 };
 
+/**
+ * Data structure of DRSUAPI W2K8 tests
+ * W2K8 Clients use different versions of structs
+ */
+struct DsPrivate_w2k8 {
+       struct dcerpc_pipe *drs_pipe;
+       struct policy_handle bind_handle;
+       struct GUID bind_guid;
+       struct drsuapi_DsBindInfoCtr srv_bind_info;
+
+       const char *domain_obj_dn;
+       const char *domain_guid_str;
+       const char *domain_dns_name;
+       struct GUID domain_guid;
+       struct drsuapi_DsGetDCInfo3 dcinfo;
+       struct test_join *join;
+};
+
 
 /**
  * Custom torture macro to check dcerpc_drsuapi_ call
diff --git a/source4/torture/rpc/drsuapi_w2k8.c 
b/source4/torture/rpc/drsuapi_w2k8.c
new file mode 100644
index 0000000..9ff37ed
--- /dev/null
+++ b/source4/torture/rpc/drsuapi_w2k8.c
@@ -0,0 +1,334 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   DRSUapi tests
+
+   Copyright (C) Andrew Tridgell 2003
+   Copyright (C) Stefan (metze) Metzmacher 2004
+   Copyright (C) Andrew Bartlett <abart...@samba.org> 2005-2006
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_drsuapi_c.h"
+#include "torture/rpc/torture_rpc.h"
+#include "param/param.h"
+
+#define TEST_MACHINE_NAME "torturetest"
+
+/*
+ * DsBind as sent from W2K8 Client.
+ * This should work regardless of functional level, and accept
+ * any info <=48
+ */
+bool test_DsBind_w2k8(struct torture_context *tctx,
+                     struct DsPrivate_w2k8 *priv)
+{
+       NTSTATUS status;
+       struct dcerpc_pipe *p = priv->drs_pipe;
+       struct drsuapi_DsBind r;
+       struct drsuapi_DsBindInfo48 *bind_info48;
+       struct drsuapi_DsBindInfoCtr bind_info_ctr;
+
+       /* We send info48 */
+       ZERO_STRUCT(bind_info_ctr);
+       bind_info_ctr.length = 48;
+
+       bind_info48 = &bind_info_ctr.info.info48;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_BASE;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
+       bind_info48->supported_extensions       |= 
DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
+
+       /*
+        * We wish for DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2,
+        * needed for DsGetDomainControllerInfo level 3
+        */
+       bind_info48->supported_extensions_ext  |= 
DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2;
+
+       GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid);
+
+       r.in.bind_guid = &priv->bind_guid;
+       r.in.bind_info = &bind_info_ctr;
+       r.out.bind_handle = &priv->bind_handle;
+
+       torture_comment(tctx, "Testing DsBind W2K8\n");
+
+       status = dcerpc_drsuapi_DsBind_r(p->binding_handle, tctx, &r);
+       torture_drsuapi_assert_call(tctx, p, status, &r, 
"dcerpc_drsuapi_DsBind");
+
+       torture_assert_not_null(tctx, r.out.bind_info,
+                               "DsBind with info48 results in NULL");
+
+       /* cache server supported extensions, i.e. bind_info */
+       priv->srv_bind_info = *r.out.bind_info;
+
+       /*
+        * We do not check for length here, because it should be valid to return
+        * any valid info
+        */
+
+       return true;
+}
+
+static bool test_DsGetDomainControllerInfo_w2k8(struct torture_context *tctx,
+                                               struct DsPrivate_w2k8 *priv)
+{
+       NTSTATUS status;
+       struct dcerpc_pipe *p = priv->drs_pipe;


-- 
Samba Shared Repository

Reply via email to