2010-08-20 73 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