question

ShiladityaGangopadhyay-6028 avatar image
0 Votes"
ShiladityaGangopadhyay-6028 asked IanXue-MSFT edited

Windows 2022 Server - File Access Issue - ls command shows <unavailable

In a Windows Server 2022, I am creating a file through remote perl script.

However when I list the files in a non-Administrator mode, I see the file owner and file group showing as <unavail>

Any suggestions on how to fix this using command prompt?
Interacting with the Explorer is not a feasible solution for my use case.
186471-image.png


windows-server
image.png (82.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ShiladityaGangopadhyay-6028 commented

What shell are you using?

"ls" is an alias for "Get-ChildItem" in PowerShell and the parameter "-lrt" is unknown:

Get-ChildItem : A parameter cannot be found that matches parameter name 'lrt'




· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

186898-image.png


This looks like MKS Toolkit, mind you I was not involved with setting up this shell.

Just as a follow-up, I see that when I am running ls -lrt as Administrator on cmd, I can see the file information, but not so as any other use running the cmd.

186865-image.png


0 Votes 0 ·
image.png (7.4 KiB)
image.png (23.0 KiB)
RichMatheisen-8856 avatar image RichMatheisen-8856 ShiladityaGangopadhyay-6028 ·

Whatever "other" user you're using doesn't have the necessary permission to get the data from the Active Directory. See the admin for the site and get a user that has the permission necessary for you to do what you've been asked to do.

0 Votes 0 ·

Hey @RichMatheisen-8856, sorry for the delayed response.

Is there a way to give this User the necessary permission to get the data from Active Directory?

Both chmod commands, and icacls commands seem to be working in a remote Perl execution environment, logged in as this user. Even ls -lrt when executed using a script, displays File Owner and File Group information correctly.

But not so when viewing in Command Prompt manually.

0 Votes 0 ·
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hi @ShiladityaGangopadhyay-6028

chown LIST


Changes the owner (and group) of a list of files. The first two elements of the list must be the numeric uid and gid, in that order. A value of -1 in either position is interpreted by most systems to leave that value unchanged. Returns the number of files successfully changed.

my $cnt = chown $uid, $gid, 'foo', 'bar';
chown $uid, $gid, @filenames;
On systems that support fchown(2), you may pass filehandles among the files. On systems that don't support fchown(2), passing filehandles raises an exception. Filehandles must be passed as globs or glob references to be recognized; barewords are considered filenames.

Here's an example that looks up nonnumeric uids in the passwd file:

print "User: ";
chomp(my $user = <STDIN>);
print "Files: ";
chomp(my $pattern = <STDIN>);

my ($login,$pass,$uid,$gid) = getpwnam($user)
or die "$user not in passwd file";

my @ary = glob($pattern); # expand filenames
chown $uid, $gid, @ary;
On most systems, you are not allowed to change the ownership of the file unless you're the superuser, although you should be able to change the group to any of your secondary groups. On insecure systems, these restrictions may be relaxed, but this is not a portable assumption. On POSIX systems, you can detect this condition this way:

use POSIX qw(sysconf _PC_CHOWN_RESTRICTED);
my $can_chown_giveaway = ! sysconf(_PC_CHOWN_RESTRICTED);


--If the reply is helpful, please Upvote and Accept as answer--

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.