r11194: Use the special ldb attribute "canonicalName" (therefore testing that
authorAndrew Bartlett <abartlet@samba.org>
Thu, 20 Oct 2005 01:48:11 +0000 (01:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:44:59 +0000 (13:44 -0500)
codepath) in DRSUAPI CrackNames.

Fix the NT4 account return value.

Andrew Bartlett
(This used to be commit 2513c02c64b489ebf167e33fdb4ac51ce8783c04)

source4/rpc_server/drsuapi/drsuapi_cracknames.c

index c1a6c19978501f72c4a84dcc17bb45713473b49b..81a10f01e6a36c23cc956d3e2e7c100e826205ae 100644 (file)
@@ -501,7 +501,6 @@ static WERROR DsCrackNameOneFilter(struct drsuapi_bind_state *b_state, TALLOC_CT
        /* here we need to set the attrs lists for domain and result lookups */
        switch (format_desired) {
        case DRSUAPI_DS_NAME_FORMAT_FQDN_1779:
-       case DRSUAPI_DS_NAME_FORMAT_CANONICAL:
        case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX: {
                const char * const _domain_attrs[] = { "ncName", "dnsRoot", NULL};
                const char * const _result_attrs[] = { NULL};
@@ -510,6 +509,14 @@ static WERROR DsCrackNameOneFilter(struct drsuapi_bind_state *b_state, TALLOC_CT
                result_attrs = _result_attrs;
                break;
        }
+       case DRSUAPI_DS_NAME_FORMAT_CANONICAL: {
+               const char * const _domain_attrs[] = { "ncName", "dnsRoot", NULL};
+               const char * const _result_attrs[] = { "canonicalName", NULL };
+               
+               domain_attrs = _domain_attrs;
+               result_attrs = _result_attrs;
+               break;
+       }
        case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT: {
                const char * const _domain_attrs[] = { "ncName", "dnsRoot", "nETBIOSName", NULL};
                const char * const _result_attrs[] = { "sAMAccountName", "objectSid", NULL};
@@ -614,16 +621,18 @@ static WERROR DsCrackNameOneFilter(struct drsuapi_bind_state *b_state, TALLOC_CT
                info1->status           = DRSUAPI_DS_NAME_STATUS_OK;
                return WERR_OK;
        }
-       case DRSUAPI_DS_NAME_FORMAT_CANONICAL:
-               return DsCrackNameOneSyntactical(mem_ctx, 
-                                                DRSUAPI_DS_NAME_FORMAT_FQDN_1779, 
-                                                DRSUAPI_DS_NAME_FORMAT_CANONICAL,
-                                                result_res[0]->dn, name, info1);
-       case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX:
+       case DRSUAPI_DS_NAME_FORMAT_CANONICAL: {
+               info1->result_name      = samdb_result_string(result_res[0], "canonicalName", NULL);
+               info1->status           = DRSUAPI_DS_NAME_STATUS_OK;
+               return WERR_OK;
+       }
+       case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX: {
+               /* Not in the virtual ldb attribute */
                return DsCrackNameOneSyntactical(mem_ctx, 
                                                 DRSUAPI_DS_NAME_FORMAT_FQDN_1779, 
                                                 DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX,
                                                 result_res[0]->dn, name, info1);
+       }
        case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT: {
                const struct dom_sid *sid = samdb_result_dom_sid(mem_ctx, result_res[0], "objectSid");
                const char *_acc = "", *_dom = "";
@@ -651,14 +660,14 @@ static WERROR DsCrackNameOneFilter(struct drsuapi_bind_state *b_state, TALLOC_CT
                                return WERR_OK;
                        }
                        dom_sid->num_auths--;
-                       ldb_ret = gendb_search(b_state->sam_ctx, mem_ctx, NULL, &domain_res2, attrs,
+                       ldb_ret = gendb_search(b_state->sam_ctx, mem_ctx, NULL, &domain_res, attrs,
                                               "(objectSid=%s)", ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
                        if (ldb_ret != 1) {
                                info1->status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND;
                                return WERR_OK;
                        }
-                       ldb_ret = gendb_search(b_state->sam_ctx, mem_ctx, NULL, &domain_res, domain_attrs,
-                                              "(ncName=%s)", ldb_dn_linearize(mem_ctx, domain_res2[0]->dn));
+                       ldb_ret = gendb_search(b_state->sam_ctx, mem_ctx, NULL, &domain_res2, domain_attrs,
+                                              "(ncName=%s)", ldb_dn_linearize(mem_ctx, domain_res[0]->dn));
                        if (ldb_ret != 1) {
                                info1->status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND;
                                return WERR_OK;
@@ -711,7 +720,7 @@ static WERROR DsCrackNameOneFilter(struct drsuapi_bind_state *b_state, TALLOC_CT
   drsuapi_DsCrackNames 
 */
 WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                      struct drsuapi_DsCrackNames *r)
+                                  struct drsuapi_DsCrackNames *r)
 {
        WERROR status;
        struct drsuapi_bind_state *b_state;