diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index fa301b9fa18..98750754036 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -464,6 +464,7 @@ SMBC_getatr(SMBCCTX * context,
 	struct timespec access_time_ts = {0};
 	struct timespec write_time_ts = {0};
 	struct timespec change_time_ts = {0};
+	struct timespec w_time_ts = {0};
 	time_t write_time = 0;
 	SMB_INO_T ino = 0;
 	struct cli_credentials *creds = NULL;
@@ -506,6 +507,7 @@ SMBC_getatr(SMBCCTX * context,
 	}
 
 	if (!srv->no_pathinfo2) {
+		bool not_supported_error = false;
 		status = cli_qpathinfo2(targetcli,
 					targetpath,
 					&create_time_ts,
@@ -518,11 +520,21 @@ SMBC_getatr(SMBCCTX * context,
 		if (NT_STATUS_IS_OK(status)) {
 			goto setup_stat;
 		}
+		if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) ||
+		    NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+			not_supported_error = true;
+		}
+		if (!not_supported_error) {
+			/* "Normal error". Just return it to caller. */
+			TALLOC_FREE(frame);
+			return status;
+		}
         }
 
 	srv->no_pathinfo2 = True;
 
 	if (!srv->no_pathinfo3) {
+		bool not_supported_error = false;
 		status = cli_qpathinfo3(targetcli,
 					targetpath,
 					&create_time_ts,
@@ -535,6 +547,15 @@ SMBC_getatr(SMBCCTX * context,
 		if (NT_STATUS_IS_OK(status)) {
 			goto setup_stat;
 		}
+		if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) ||
+		    NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+			not_supported_error = true;
+		}
+		if (!not_supported_error) {
+			/* "Normal error". Just return it to caller. */
+			TALLOC_FREE(frame);
+			return status;
+		}
         }
 
 	srv->no_pathinfo3 = True;
@@ -545,14 +566,11 @@ SMBC_getatr(SMBCCTX * context,
         }
 
 	status = cli_getatr(targetcli, targetpath, &attr, &size, &write_time);
-	if (NT_STATUS_IS_OK(status)) {
-		struct timespec w_time_ts =
-			convert_time_t_to_timespec(write_time);
-
-		access_time_ts = change_time_ts = write_time_ts = w_time_ts;
-
-		goto setup_stat;
+	if (!NT_STATUS_IS_OK(status)) {
+		goto all_failed;
 	}
+	w_time_ts = convert_time_t_to_timespec(write_time);
+	access_time_ts = change_time_ts = write_time_ts = w_time_ts;
 
 setup_stat:
 	setup_stat(sb,
@@ -573,7 +591,7 @@ all_failed:
 	srv->no_pathinfo3 = False;
 
 	TALLOC_FREE(frame);
-	return NT_STATUS_ACCESS_DENIED;
+	return status;
 }
 
 /*
