Show why a LookupName fails (help debugging)
authorAndrew Bartlett <abartlet@samba.org>
Thu, 13 Mar 2008 05:35:11 +0000 (16:35 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 13 Mar 2008 05:35:11 +0000 (16:35 +1100)
Andrew Bartlett

source/rpc_server/lsa/dcesrv_lsa.c
source/rpc_server/lsa/lsa_lookup.c

index 4375088e1703c42a41fe2ef9ddd8e883ef23012a..4d381ea978c1077bbd87e35e2eee9cc6fe05c244 100644 (file)
@@ -644,9 +644,26 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_cal
 
        /* create the trusted_domain */
        ret = ldb_add(trusted_domain_state->policy->sam_ldb, msg);
-       if (ret != LDB_SUCCESS) {
-               DEBUG(0,("Failed to create trusted_domain record %s: %s\n",
-                        ldb_dn_get_linearized(msg->dn), ldb_errstring(trusted_domain_state->policy->sam_ldb)));
+       switch (ret) {
+       case  LDB_SUCCESS:
+               break;
+       case  LDB_ERR_ENTRY_ALREADY_EXISTS:
+               ldb_transaction_cancel(trusted_domain_state->policy->sam_ldb);
+               DEBUG(0,("Failed to create trusted domain record %s: %s\n",
+                        ldb_dn_get_linearized(msg->dn),
+                        ldb_errstring(trusted_domain_state->policy->sam_ldb)));
+               return NT_STATUS_DOMAIN_EXISTS;
+       case  LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS:
+               ldb_transaction_cancel(trusted_domain_state->policy->sam_ldb);
+               DEBUG(0,("Failed to create trusted domain record %s: %s\n",
+                        ldb_dn_get_linearized(msg->dn),
+                        ldb_errstring(trusted_domain_state->policy->sam_ldb)));
+               return NT_STATUS_ACCESS_DENIED;
+       default:
+               ldb_transaction_cancel(trusted_domain_state->policy->sam_ldb);
+               DEBUG(0,("Failed to create user record %s: %s\n",
+                        ldb_dn_get_linearized(msg->dn),
+                        ldb_errstring(trusted_domain_state->policy->sam_ldb)));
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
index bcc2af97a7af2e61c793eaa94386e052df754da6..e01efa823387736d014a6895b75ec46bb4461175 100644 (file)
@@ -220,6 +220,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
        } else if (strchr_m(name, '@')) {
                status = crack_name_to_nt4_name(mem_ctx, lp_ctx, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, name, &domain, &username);
                if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(3, ("Failed to crack name %s into an NT4 name: %s\n", name, nt_errstr(status)));
                        return status;
                }
        } else {