I would like to set folder ACL on remote server for a domain user but get always following error message:
Some or all identity references could not be translated
What am I doing wrong?
This is my code:
string folderPath = @"\\remoteServer\testDirectory"
string accountName = "domainUser"
string domainName = "mydomain";
accountName = domainName + "\\" + accountName;
//What rights are we setting?
//set on dir itself
FileSystemAccessRule accessRule = new FileSystemAccessRule(accountName, FileSystemRights.FullControl, AccessControlType.Allow);
DirectoryInfo dInfo = new DirectoryInfo(folderPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
//dInfo.SetAccessControl(dSecurity);
dSecurity.AddAccessRule(accessRule);`
If I enter only userName
instead of domainname\username
permission will be set but with "unknown account"
Could someone please help...
Thanks in advance.