我怎样才能找出使用.NET谁创建的文件在Windows? [英] How can I find out who created a file in Windows using .NET?

查看:221
本文介绍了我怎样才能找出使用.NET谁创建的文件在Windows?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找出谁在使用.NET的文件

I need to find out who created a file using .NET

我已经尝试了以下内容:

I have already tried the following:

string FileLocation = @"C:\test.txt";
FileInfo droppedFile = new FileInfo(FileLocation);
FileSecurity fileSecurity = droppedFile.GetAccessControl();
IdentityReference identityReference = fileSecurity.GetOwner(typeof(NTAccount));
string userName = identityReference.Value;
Console.WriteLine(userName);

这一切,返回的是BUILTIN \管理员

All this returns is "BUILTIN\Administrators"

我是不是做错了什么吗?因为当我看到在C:\在资源管理器中,店主给出了正确的用户名,当我exectute的code以上返回BUILTIN \管理员

Am I doing something wrong here? Because when I look at the C:\ in explorer, the owner shows the correct username, when I exectute the code above it returns "BUILTIN\Administrators"

这甚至不是一个域和用户名,我认为这是一个安全组。

Which isn't even a domain and username, I think it's a security group.

任何帮助AP preciated。

Any help appreciated.

推荐答案

如果一个用户是管理员,那么他们创造了被认为是由整个管理员组,而不是个人用户。

If a user is an administrator, then the files they created are considered to be owned by the whole administrators group, not the individual user.

您可以看到在资源管理器的属性对话框中相同的行为。烦人,我不认为有任何解决办法,除了不使用户管理员。

You can see the same behaviour in Explorer's properties dialog. Annoyingly, I don't think there is any workaround, other than not making users admins.

编辑: 此Technet文章更详细地解释这种行为。的理由是,Windows将所有管理员作为一个单一的实体;系统上的任何管理员可以做任何事情,其他管理员可以。

This Technet article explains this behaviour in more detail. The rationale is that Windows treats all administrators as a single entity; any administrator on the system can do anything that the other administrators can.

  • 如果一个管理员的许可管理上的一个文件,所以是所有其他的管理员
  • 如果一个管理员被拒绝访问时,管理员的话也休息
  • 如果一个管理员拥有的文件 - 文件的拥有者被赋予特权访问该文件 - 那么所有其他管理员都必须拥有该文件

这篇关于我怎样才能找出使用.NET谁创建的文件在Windows?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆