问题标签 [directory-security]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
414 浏览

c# - 获取文件夹权限

我正试图找到一个文件夹。目的是当我要求我的程序创建这个文件时,在这个文件夹中创建一个文件。我几乎尝试了所有方法,但仍然无法正常工作。

我的问题是: FileSystemAccessRule 说我有权限但是当我想创建我的文件时,出现“unauthorizedexception”异常。

我尝试使用 DirectoryInfo,如下所示:

而不是直接使用“目录”对象。另外,我认为我的问题与 GetAccessRules 有关,所以我尝试使用 SecurityIdentifier 和 NTAccount,两者都说我在这个文件夹(FullControl)上拥有所有权利,而最后,我没有任何权利. 当然,我的道路很好,我检查了它。

有人知道另一种方法来获得正确的文件夹,或者如果我做错了什么,一点帮助将是一种乐趣。

0 投票
0 回答
88 浏览

c# - 如何为 URL 创建“需要身份验证”?

对于某些站点的下载文件,您必须在“需要验证”窗口中输入您的用户名和密码。这是如何实施的?

像这张图:

认证要求窗口 http://s9.uploads.im/sVCmz.png

使用“UserPrincipal”添加“本地用户”,然后使用“DirectorySecurity”授予权限,是正确的方法吗?

0 投票
0 回答
2413 浏览

c# - .NET 如何更改文件夹/文件权限或访问权限?

我想阻止用户移动/重命名/删除文件夹,但在文件夹内导航以查看其子文件夹和文件;此外,代码可以在设置这些访问权限后在文件夹内创建子文件夹/文件。对于文件,我还想阻止用户更新/移动/重命名/删除,但应用程序可以做到这一点。我玩过 DirectorySecurity,但我无法产生预期的结果。

0 投票
1 回答
1615 浏览

c# - .NET-如何获取有权访问共享文件夹的用户的完整列表?

我正在寻找一种有效的方法来查找所有有权访问共享文件夹的用户。我认为可能需要结合这篇文章的建议查看用户是否是 C# + Asp.net 中 Active Directory 组的一部分,以及如何检查特定用户是否有权使用 C# 访问共享文件夹位置

我发现使用 AuthorizationRuleCollection 只能找到有权访问文件夹的组和用户,但不能找到组成员。如果一个文件夹只授予用户组而不是个人用户帐户,我找不到哪个用户有权访问这个文件夹。在这种情况下,我必须检查这些用户组中的所有成员(子)。

遍历所有组并列出组成员(子)很好,只是想知道是否有更有效/更好的方法可以立即获取完整的用户列表?(不一定是 .NET 方法,可以是命令提示符或 powershell 等任何方法)

谢谢

0 投票
1 回答
682 浏览

c# - DirectorySecurity C#从远程服务器分配本地组的权限

我正在使用以下代码将域组权限分配给 C# 应用程序中的文件夹:

例如,我在名为 server001 的服务器上执行该程序,并使用该代码将域组应用到名为 server002 的服务器上的文件夹的 ACL,它工作正常。

现在我需要将 server002 上的安全组添加到文件夹中,但是使用在服务器 001 上执行的程序,例如添加 server002 的“Guests”本地组,但将该组添加到 ACL 的操作必须从服务器 001 上运行的 C# 程序执行该文件夹。

有人可以告诉我如何实现这一目标吗?

0 投票
1 回答
5090 浏览

c# - 当我在创建的文件夹中写入文件时总是出现访问被拒绝错误

我正在使用 Windows(在 7 和 10 中测试)

和程序首先创建文件夹。之后,我想在创建的文件夹中写一个文件。但总是收到拒绝访问错误。我尝试了操作系统中的每个目录。C:、programfiles、文档和项目文件夹。我总是收到该错误消息。每个代码都在下面,谢谢。

应用程序清单

创建文件夹按钮方法

删除文件夹只读

创建和写入文件按钮方法

文件夹属性方法

0 投票
1 回答
1362 浏览

c# - 获取当前用户 .net 的文件权限

我正在扫描文件夹中的文件,我需要以任何方式获取当前用户的每个文件的权限以表示为字符串。因此,对于附加文件的属性,我想表示类似fmrw 字符串的内容。

我试图在我的扫描循环中完成这个,但是得到空字符串。你能暗示我应该从这里去哪里还是选择另一种方法?提前致谢!

0 投票
0 回答
29 浏览

c# - 有没有办法在子目录中加载文件夹权限

文件夹权限似乎只显示在根文件夹中,而不显示在该根文件夹的子目录中。

测试应用程序时,我获取根文件夹并显示文件夹权限。但是,它也会在根文件夹中显示子目录权限,我希望它显示在子目录下。我搜索了很多论坛并找不到解决方案。

这是我用于加载目录和获取文件夹权限的代码:

对于子目录,我有以下代码:

因此,举一个加载具有权限的目录的示例:

当我尝试加载子目录时,我得到以下信息:

我想达到的目标:

0 投票
1 回答
112 浏览

c# - 本地共享的 C# 文件/目录权限

我需要一个所有本地用户都可以编辑的文件。应用程序将公共信息保存在 ProgramData 下自己的文件夹中的所有用户。我需要保证对所有用户的读写,信息太少了,不值得使用数据库。

我从以下位置获取文件夹的路径:Path.Combine(Application.CommonAppDataPath, "InfoConfig");

所有用户都可以在此文件夹中读取、写入和创建。其他用户创建的文件除外

我已经尝试删除 Creator Owner 但没有成功。所以我最后一次尝试不是从容器文件夹继承,而是从头开始为系统、管理员和用户创建权限。但它也不起作用,这是我的代码。

它仍然不起作用。我究竟做错了什么?

0 投票
1 回答
32 浏览

c# - How can I create a protected directory that I can guarantee has only been modified by a specific user?

I am developing a .NET Windows Service using C# that runs as the SYSTEM user so that it has permissions to install software updates etc.

I want the service to download an executable file to a protected directory and launch it. However, I want to make sure that I've considered security and that it isn't possible for another user to copy a file into the directory that the service uses and then have the file executed with SYSTEM privileges.

I've looked into creating a directory that only the SYSTEM user has access to using an ACL as follows.

Subsequent to this, I check that the owner of the directory is the SYSTEM user before I allow a cached copy of the executable file that has been downloaded to be used.

However, if a user with the right permissions was able to change the owner of the directory to themselves, copy in a file, and then change the owner back to the SYSTEM user, the above check would not be of any benefit.

Perhaps the only option is to always recreate the download folder with the strict ACL and redownload the file every time to prevent the possibility of the scenario above.

In short, my question is as follows; is there a way that I can create a protected directory that I can guarantee has only ever been created or modified by the SYSTEM user?