我正在做一个powershell脚本,它在AD中创建新的域用户帐户,并在文件服务器中创建具有相关权限的主目录.
我的问题是我无法获得权限设置.
在下面的代码中,my_fileServer是文件服务器名称; sso表示单点登录ID,在下面的测试代码中设置为"user9999".
任何帮助是极大的赞赏!
Set-Variable homeDir -option Constant -value "\\my_fileServer\Users"
Set-Variable sso -option Constant -value "user9999"
# If the folder for the user does not exist, make a new one and set the correct permissions.
if ( (Test-Path "$homeDir\$sso") -eq $false)
{
try
{
$NewFolder = New-Item -Path $homeDir -Name $sso -ItemType "Directory"
$Rights = [System.Security.AccessControl.FileSystemRights]"FullControl,Modify,ReadAndExecute,ListDirectory,Read,Write"
$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::None
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None
$objType =[System.Security.AccessControl.AccessControlType]::Allow
$objUser = New-Object System.Security.Principal.NTAccount "my_full_domain_name\$sso"
$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule `
($objUser, $Rights, $InheritanceFlag, $PropagationFlag, $objType) …Run Code Online (Sandbox Code Playgroud) 有人可以向我解释如何在 Linux(特别是 Ubuntu)中继承目录权限吗?
例如,如果我有以下目录结构怎么办:
folder_A
folder_B
Run Code Online (Sandbox Code Playgroud)
folder_A 的权限是否总是覆盖 folder_B 的权限?如果folder_A 的权限比folder_B 的权限更严格,反之亦然,这有什么区别吗?
我的猜测是,如果 folder_B 具有更多限制性权限,它将覆盖 folder_A,但如果 folder_A 具有更多限制性权限,那么它将覆盖其子项。
我的服务器上有一个Video文件夹,有755的权限.问题是:当有人去上传视频文件时,由于权限错误,无法上传到该文件夹.
如果我将权限更改为777,则可以上传视频.但出于安全原因,我不想允许777的文件夹权限.
在上传视频时,有没有办法在PHP中临时更改777的权限?
是否可以读取分配给共享文件夹的共享权限?我能够在本地安全设置programmaticaly(在右键单击>属性>安全性下找到的)读取没问题.但是,我想知道如何在右键单击>共享和安全...>权限下读取权限
这是我想要阅读的权限的图像:

这可能吗?如果有帮助,我正在运行XP Pro机器.
编辑:
按我的回答,我能够通过全部股份进行迭代,并获得访问您(即运行程序的人)对这一份额,但还没有找到一种方法来读取权限,其他人都在该共享.这是使用Win32_Share类完成的,但它没有获取其他用户的共享权限的选项.如果有人有任何有用的提示,将是一个巨大的帮助.
尝试创建文件夹并设置其权限时出现以下错误。它无需传递文件元数据中的权限即可工作。
但我想创建具有特定用户权限的文件夹,每个用户都有自己的 g 邮件帐户。我怎样才能做到这一点?谢谢!
错误信息:
代码:
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Drive.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DriveQuickstart
{
class Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/drive-dotnet-quickstart.json
static string[] Scopes = { DriveService.Scope.Drive };
static string ApplicationName = "Drive API .NET Quickstart";
static void Main(string[] args)
{
UserCredential credential;
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.ReadWrite))
{ …Run Code Online (Sandbox Code Playgroud) 我需要为 IIS 用户授予文件夹权限。
其实我写的代码是这样的..
public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights,AccessControlType ControlType)
{
DirectoryInfo dInfo = new DirectoryInfo(FileName);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(
new System.Security.AccessControl.FileSystemAccessRule(objUser, Rights, ControlType));
dInfo.SetAccessControl(dSecurity);
}
Run Code Online (Sandbox Code Playgroud)
我像这样调用上面的方法......
void givepermission()
{
DirectoryInfo a = new DirectoryInfo(Server.MapPath("~/resources"));
AddDirectorySecurity(Server.MapPath("~/"), "IUSR", FileSystemRights.FullControl,AccessControlType.Allow);
}
Run Code Online (Sandbox Code Playgroud)
但在本地它的工作。当去服务器不工作。
我尝试使用帐户名称而不是 IUSR,但这也不起作用..
IIS_IUSRS
IIS_WPG
网络服务
大家
等。
而是 IIS_IUSRS。我也试过这样...
System.Environment.MachineName + "\\IIS_IUSRS"
IIS_IUSRS_System.Environment.MachineName
System.Environment.UserDomainName + "\\IIS_IUSRS"
etc..
Run Code Online (Sandbox Code Playgroud)
但这也不起作用,但它抛出“无法翻译某些或所有身份引用”
注意:我不想手动设置权限
请有人帮我解决这个问题..?