2010-08-20 92 views
0

我写了下面的代码给读取权限的组,但我得到anerror:如何给读/写权限的文件夹为一组

"The trust relationship between the primary domain and the trusted domain failed."

如果我给一个用户名,而不是它正在工作。

DirectoryInfo myDirectoryInfo = new DirectoryInfo(path); 
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl(); 
string group = "groupName"; 
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(group,FileSystemRights.Read, AccessControlType.Deny)); 
myDirectoryInfo.SetAccessControl(myDirectorySecurity); 

回答

0

MSDN文档FileSystemAccessRule:

Initializes a new instance of the FileSystemAccessRule class using the name of a user account, a value that specifies the type of operation associated with the access rule, and a value that describes whether to allow or deny the operation.

编辑:看起来像构造函数只与用户账户中使用(您可能需要为组SID)。你应该使用带有IdentityReference的构造函数。以一个示例为例...

+0

IdentityReference参数还被定义为链接到用户帐户,而不是组。你确定它可以很好地分配组权限吗? – 2010-08-20 14:47:47